Electroneum
Loading...
Searching...
No Matches
decompose_amount_into_digits.cpp File Reference
#include "gtest/gtest.h"
#include <cstdint>
#include <vector>
#include "cryptonote_basic/cryptonote_format_utils.h"
Include dependency graph for decompose_amount_into_digits.cpp:

Go to the source code of this file.

Macros

#define VEC_FROM_ARR(vec)

Functions

 TEST_F (decompose_amount_into_digits_test, is_correct_0)
 TEST_F (decompose_amount_into_digits_test, is_correct_1)
 TEST_F (decompose_amount_into_digits_test, is_correct_2)
 TEST_F (decompose_amount_into_digits_test, is_correct_3)
 TEST_F (decompose_amount_into_digits_test, is_correct_4)
 TEST_F (decompose_amount_into_digits_test, is_correct_5)
 TEST_F (decompose_amount_into_digits_test, is_correct_6)

Macro Definition Documentation

◆ VEC_FROM_ARR

#define VEC_FROM_ARR ( vec)
Value:
std::vector<uint64_t> vec; \
for (size_t i = 0; i < sizeof(vec##_arr) / sizeof(vec##_arr[0]); ++i) \
{ \
vec.push_back(vec##_arr[i]); \
}

Definition at line 39 of file decompose_amount_into_digits.cpp.

39#define VEC_FROM_ARR(vec) \
40 std::vector<uint64_t> vec; \
41 for (size_t i = 0; i < sizeof(vec##_arr) / sizeof(vec##_arr[0]); ++i) \
42 { \
43 vec.push_back(vec##_arr[i]); \
44 }

Function Documentation

◆ TEST_F() [1/7]

TEST_F ( decompose_amount_into_digits_test ,
is_correct_0  )

Definition at line 84 of file decompose_amount_into_digits.cpp.

85{
86 std::vector<uint64_t> expected_chunks;
87 cryptonote::decompose_amount_into_digits(0, 0, m_chunk_handler, m_dust_handler);
88 ASSERT_EQ(m_chunk_handler.m_chunks, expected_chunks);
89 ASSERT_EQ(m_dust_handler.m_has_dust, false);
90}
#define ASSERT_EQ(val1, val2)
Definition gtest.h:1956
void decompose_amount_into_digits(uint64_t amount, uint64_t dust_threshold, const chunk_handler_t &chunk_handler, const dust_handler_t &dust_handler)
Here is the call graph for this function:

◆ TEST_F() [2/7]

TEST_F ( decompose_amount_into_digits_test ,
is_correct_1  )

Definition at line 92 of file decompose_amount_into_digits.cpp.

93{
94 std::vector<uint64_t> expected_chunks;
95 cryptonote::decompose_amount_into_digits(0, 10, m_chunk_handler, m_dust_handler);
96 ASSERT_EQ(m_chunk_handler.m_chunks, expected_chunks);
97 ASSERT_EQ(m_dust_handler.m_has_dust, false);
98}
Here is the call graph for this function:

◆ TEST_F() [3/7]

TEST_F ( decompose_amount_into_digits_test ,
is_correct_2  )

Definition at line 100 of file decompose_amount_into_digits.cpp.

101{
102 uint64_t expected_chunks_arr[] = {10};
103 VEC_FROM_ARR(expected_chunks);
104 cryptonote::decompose_amount_into_digits(10, 0, m_chunk_handler, m_dust_handler);
105 ASSERT_EQ(m_chunk_handler.m_chunks, expected_chunks);
106 ASSERT_EQ(m_dust_handler.m_has_dust, false);
107}
#define VEC_FROM_ARR(vec)
unsigned __int64 uint64_t
Definition stdint.h:136
Here is the call graph for this function:

◆ TEST_F() [4/7]

TEST_F ( decompose_amount_into_digits_test ,
is_correct_3  )

Definition at line 109 of file decompose_amount_into_digits.cpp.

110{
111 std::vector<uint64_t> expected_chunks;
112 uint64_t expected_dust = 10;
113 cryptonote::decompose_amount_into_digits(10, 10, m_chunk_handler, m_dust_handler);
114 ASSERT_EQ(m_chunk_handler.m_chunks, expected_chunks);
115 ASSERT_EQ(m_dust_handler.m_dust, expected_dust);
116}
Here is the call graph for this function:

◆ TEST_F() [5/7]

TEST_F ( decompose_amount_into_digits_test ,
is_correct_4  )

Definition at line 118 of file decompose_amount_into_digits.cpp.

119{
120 uint64_t expected_dust = 8100;
121 std::vector<uint64_t> expected_chunks;
122 cryptonote::decompose_amount_into_digits(8100, 1000000, m_chunk_handler, m_dust_handler);
123 ASSERT_EQ(m_chunk_handler.m_chunks, expected_chunks);
124 ASSERT_EQ(m_dust_handler.m_dust, expected_dust);
125}
Here is the call graph for this function:

◆ TEST_F() [6/7]

TEST_F ( decompose_amount_into_digits_test ,
is_correct_5  )

Definition at line 127 of file decompose_amount_into_digits.cpp.

128{
129 uint64_t expected_chunks_arr[] = {100, 900000, 8000000};
130 VEC_FROM_ARR(expected_chunks);
131 cryptonote::decompose_amount_into_digits(8900100, 10, m_chunk_handler, m_dust_handler);
132 ASSERT_EQ(m_chunk_handler.m_chunks, expected_chunks);
133 ASSERT_EQ(m_dust_handler.m_has_dust, false);
134}
Here is the call graph for this function:

◆ TEST_F() [7/7]

TEST_F ( decompose_amount_into_digits_test ,
is_correct_6  )

Definition at line 136 of file decompose_amount_into_digits.cpp.

137{
138 uint64_t expected_chunks_arr[] = {900000, 8000000};
139 VEC_FROM_ARR(expected_chunks);
140 uint64_t expected_dust = 100;
141 cryptonote::decompose_amount_into_digits(8900100, 1000, m_chunk_handler, m_dust_handler);
142 ASSERT_EQ(m_chunk_handler.m_chunks, expected_chunks);
143 ASSERT_EQ(m_dust_handler.m_dust, expected_dust);
144}
Here is the call graph for this function: