diff options
author | Sven Gothel <[email protected]> | 2021-02-10 13:15:54 +0100 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2021-02-10 13:15:54 +0100 |
commit | ebdd8181e364d2ad890bf23d990f11c98efc5a8c (patch) | |
tree | 4596e929858a01e2afdee9ac37504f2183d848b2 /test | |
parent | dfe5528b8a19f28405960a2372fee145a71528cb (diff) |
Consolidate conversion to hex and decimal string: template<> to_hexstring() and to_decstring(), drop <type>[Hex|Dec]String(..)
Diffstat (limited to 'test')
-rw-r--r-- | test/test_basictypeconv.cpp | 12 | ||||
-rw-r--r-- | test/test_cow_darray_perf01.cpp | 2 | ||||
-rw-r--r-- | test/test_cow_iterator_01.cpp | 16 | ||||
-rw-r--r-- | test/test_hashset_perf01.cpp | 2 | ||||
-rw-r--r-- | test/test_intdecstring01.cpp | 8 | ||||
-rw-r--r-- | test/test_to_string.cpp | 4 |
6 files changed, 22 insertions, 22 deletions
diff --git a/test/test_basictypeconv.cpp b/test/test_basictypeconv.cpp index 6d56287..6859089 100644 --- a/test/test_basictypeconv.cpp +++ b/test/test_basictypeconv.cpp @@ -112,9 +112,9 @@ static void test_byteorder(const Value_type v_cpu, { if( VERBOSE ) { fprintf(stderr, "test_byteorder: sizeof %zu; platform littleEndian %d", sizeof(Value_type), jau::isLittleEndian()); - fprintf(stderr, "\ncpu: %s: ", jau::to_hex_string(v_cpu).c_str()); print(v_cpu); - fprintf(stderr, "\nle_: %s: ", jau::to_hex_string(v_le).c_str()); print(v_le); - fprintf(stderr, "\nbe_: %s: ", jau::to_hex_string(v_be).c_str()); print(v_be); + fprintf(stderr, "\ncpu: %s: ", jau::to_hexstring(v_cpu).c_str()); print(v_cpu); + fprintf(stderr, "\nle_: %s: ", jau::to_hexstring(v_le).c_str()); print(v_le); + fprintf(stderr, "\nbe_: %s: ", jau::to_hexstring(v_be).c_str()); print(v_be); fprintf(stderr, "\n"); } { @@ -284,9 +284,9 @@ template<typename Value_type> static void test_value_littlebig(const Value_type v_cpu, const Value_type v_le, const Value_type v_be) { if( VERBOSE ) { fprintf(stderr, "test_value_littlebig: sizeof %zu; platform littleEndian %d", sizeof(Value_type), jau::isLittleEndian()); - fprintf(stderr, "\ncpu: %s: ", jau::to_hex_string(v_cpu).c_str()); print(v_cpu); - fprintf(stderr, "\nle_: %s: ", jau::to_hex_string(v_le).c_str()); print(v_le); - fprintf(stderr, "\nbe_: %s: ", jau::to_hex_string(v_be).c_str()); print(v_be); + fprintf(stderr, "\ncpu: %s: ", jau::to_hexstring(v_cpu).c_str()); print(v_cpu); + fprintf(stderr, "\nle_: %s: ", jau::to_hexstring(v_le).c_str()); print(v_le); + fprintf(stderr, "\nbe_: %s: ", jau::to_hexstring(v_be).c_str()); print(v_be); fprintf(stderr, "\n"); } uint8_t buffer[2 * sizeof(Value_type)]; diff --git a/test/test_cow_darray_perf01.cpp b/test/test_cow_darray_perf01.cpp index 4de9906..ca121e5 100644 --- a/test/test_cow_darray_perf01.cpp +++ b/test/test_cow_darray_perf01.cpp @@ -298,7 +298,7 @@ static void print_mem(const std::string& pre, const T& data) { std::size_t bytes_total = data.get_allocator().memory_usage; double overhead = 0 == bytes_total ? 0.0 : ( 0 == bytes_net ? 10.0 : (double)bytes_total / (double)bytes_net ); printf("Mem: %s: Elements %s x %zu bytes; %s, %lf ratio\n", - pre.c_str(), int64DecString(elements, ',', 5).c_str(), + pre.c_str(), to_decstring(elements, ',', 5).c_str(), bytes_element, data.get_allocator().toString(10, 5).c_str(), overhead); // 5: 1,000 // 7: 100,000 diff --git a/test/test_cow_iterator_01.cpp b/test/test_cow_iterator_01.cpp index 48c5a6b..da82e5d 100644 --- a/test/test_cow_iterator_01.cpp +++ b/test/test_cow_iterator_01.cpp @@ -66,7 +66,7 @@ template<class T> static void print_list(T& data) { printf("list: %d { ", (int)data.size()); jau::for_each_const(data, [](const uint64_t & e) { - printf("%s, ", uint64DecString(e, ',', 2).c_str()); + printf("%s, ", to_decstring(e, ',', 2).c_str()); } ); printf("}\n"); } @@ -75,7 +75,7 @@ template<class T> static void print_list(const std::string& pre, T& data) { printf("%s: %d { ", pre.c_str(), (int)data.size()); jau::for_each_const(data, [](const uint64_t & e) { - printf("%s, ", uint64DecString(e, ',', 2).c_str()); + printf("%s, ", to_decstring(e, ',', 2).c_str()); } ); printf("}\n"); } @@ -1214,7 +1214,7 @@ static bool test_01_cow_iterator_properties(const std::string& type_id) { REQUIRE( c_begin1 == m_begin1); REQUIRE( ( c_begin1 - m_begin1 ) == 0); printf(" 1st store: %s == %s, dist %u\n", - uint64DecString(*c_begin1, ',', 2).c_str(), uint64DecString(*m_begin1, ',', 2).c_str(), (unsigned int)(c_begin1 - m_begin1)); + to_decstring(*c_begin1, ',', 2).c_str(), to_decstring(*m_begin1, ',', 2).c_str(), (unsigned int)(c_begin1 - m_begin1)); citer_type c_begin2; { iter_type m_begin2 = data.begin(); // mutable new_store non-const iterator, gets held until write_back() or destruction @@ -1224,13 +1224,13 @@ static bool test_01_cow_iterator_properties(const std::string& type_id) { REQUIRE( c_begin2 == m_begin2); REQUIRE( ( c_begin2 - m_begin2 ) == 0); printf(" 2nd store: %s == %s, dist %u\n", - uint64DecString(*c_begin2, ',', 2).c_str(), uint64DecString(*m_begin2, ',', 2).c_str(), (unsigned int)(c_begin2 - m_begin2)); + to_decstring(*c_begin2, ',', 2).c_str(), to_decstring(*m_begin2, ',', 2).c_str(), (unsigned int)(c_begin2 - m_begin2)); REQUIRE(*c_begin2 == *c_begin1); REQUIRE( c_begin2 != c_begin1); REQUIRE( ( c_begin2 - c_begin1 ) != 0); printf("2nd -> 1st store: %s == %s, dist %u\n", - uint64DecString(*c_begin2, ',', 2).c_str(), uint64DecString(*c_begin1, ',', 2).c_str(), (unsigned int)(c_begin2 - c_begin1)); + to_decstring(*c_begin2, ',', 2).c_str(), to_decstring(*c_begin1, ',', 2).c_str(), (unsigned int)(c_begin2 - c_begin1)); m_begin2.write_back(); // write back storage of m_begin2 to parent CoW and invalidate m_begin2 } @@ -1240,16 +1240,16 @@ static bool test_01_cow_iterator_properties(const std::string& type_id) { REQUIRE( c_begin2 == c_begin2b); REQUIRE( ( c_begin2 - c_begin2b ) == 0); printf("2nd -> cow == cbegin: %s == %s, dist %u\n", - uint64DecString(*c_begin2, ',', 2).c_str(), uint64DecString(*c_begin2b, ',', 2).c_str(), (unsigned int)(c_begin2 - c_begin2b)); + to_decstring(*c_begin2, ',', 2).c_str(), to_decstring(*c_begin2b, ',', 2).c_str(), (unsigned int)(c_begin2 - c_begin2b)); printf("2nd -> 1st : %s == %s, dist %u\n", - uint64DecString(*c_begin1, ',', 2).c_str(), uint64DecString(*c_begin2, ',', 2).c_str(), (unsigned int)(c_begin1 - c_begin2)); + to_decstring(*c_begin1, ',', 2).c_str(), to_decstring(*c_begin2, ',', 2).c_str(), (unsigned int)(c_begin1 - c_begin2)); m_begin1.write_back(); // write back storage of m_begin1 to parent CoW and invalidate m_begin2 } // 1st store -> cow_xxx citer_type c_begin1b = data.cbegin(); printf("1st -> cow == cbegin: %s == %s, dist %u\n", - uint64DecString(*c_begin1, ',', 2).c_str(), uint64DecString(*c_begin1b, ',', 2).c_str(), (unsigned int)(c_begin1 - c_begin1b)); + to_decstring(*c_begin1, ',', 2).c_str(), to_decstring(*c_begin1b, ',', 2).c_str(), (unsigned int)(c_begin1 - c_begin1b)); REQUIRE(*c_begin1 == *c_begin1b); REQUIRE( c_begin1 == c_begin1b); REQUIRE( ( c_begin1 - c_begin1b ) == 0); diff --git a/test/test_hashset_perf01.cpp b/test/test_hashset_perf01.cpp index 223c05d..0ae3e4f 100644 --- a/test/test_hashset_perf01.cpp +++ b/test/test_hashset_perf01.cpp @@ -156,7 +156,7 @@ static void print_mem(const std::string& pre, const T& data) { std::size_t bytes_total = data.get_allocator().memory_usage; double overhead = 0 == bytes_total ? 0.0 : ( 0 == bytes_net ? 10.0 : (double)bytes_total / (double)bytes_net ); printf("Mem: %s: Elements %s x %zu bytes; %s, %lf ratio\n", - pre.c_str(), int64DecString(elements, ',', 5).c_str(), + pre.c_str(), to_decstring(elements, ',', 5).c_str(), bytes_element, data.get_allocator().toString(10, 5).c_str(), overhead); // 5: 1,000 // 7: 100,000 diff --git a/test/test_intdecstring01.cpp b/test/test_intdecstring01.cpp index 2f4dd5c..64abffb 100644 --- a/test/test_intdecstring01.cpp +++ b/test/test_intdecstring01.cpp @@ -66,7 +66,7 @@ using namespace jau; INFO(msg+": value commas "+std::to_string(comma_count)); INFO(msg+": value net_chars "+std::to_string(net_chars)); INFO(msg+": value total_chars "+std::to_string(total_chars)); - std::string s = to_decimal_string<T>(value, use_separator ? ',' : 0, min_width); + std::string s = to_decstring<T>(value, use_separator ? ',' : 0, min_width); INFO(msg+": result '"+s+"', len "+std::to_string(s.length())); } #endif @@ -75,7 +75,7 @@ static void test_int32_t(const std::string msg, const int32_t v, const size_t ex #if SHOW_DECIMAL_STRING_STATS show_decimal_string_stats<int32_t>(msg, v, true /* use_separator */, 0 /* min_width */); #endif - const std::string str = int32DecString(v); + const std::string str = to_decstring(v); INFO(msg+": has '"+str+"', len "+std::to_string(str.length())); INFO(msg+": exp '"+expStr+"', len "+std::to_string(expStr.length())+", equal: "+std::to_string(str==expStr)); REQUIRE(str.length() == expStrLen); @@ -87,7 +87,7 @@ static void test_uint32_t(const std::string msg, const uint32_t v, const size_t show_decimal_string_stats<uint32_t>(msg, v, true /* use_separator */, 0 /* min_width */); #endif - const std::string str = uint32DecString(v); + const std::string str = to_decstring(v); INFO(msg+": has '"+str+"', len "+std::to_string(str.length())); INFO(msg+": exp '"+expStr+"', len "+std::to_string(expStr.length())+", equal: "+std::to_string(str==expStr)); REQUIRE(str.length() == expStrLen); @@ -99,7 +99,7 @@ static void test_uint64_t(const std::string msg, const uint64_t v, const size_t show_decimal_string_stats<uint64_t>(msg, v, true /* use_separator */, 0 /* min_width */); #endif - const std::string str = uint64DecString(v); + const std::string str = to_decstring(v); INFO(msg+": has '"+str+"', len "+std::to_string(str.length())); INFO(msg+": exp '"+expStr+"', len "+std::to_string(expStr.length())+", equal: "+std::to_string(str==expStr)); REQUIRE(str.length() == expStrLen); diff --git a/test/test_to_string.cpp b/test/test_to_string.cpp index e00d2f0..a08f7c8 100644 --- a/test/test_to_string.cpp +++ b/test/test_to_string.cpp @@ -80,11 +80,11 @@ TEST_CASE( "JAU to_string() Test 00 - jau::to_string() std::string conversion", vec_int_1.push_back(1); vec_int_1.push_back(2); vec_int_1.push_back(3); std_vec_int_citer vec_int_citer_1B = vec_int_1.cbegin(); uint8_t* vec_int_citer_1B_ptr = (uint8_t*)(vec_int_citer_1B.operator->()); - std::string vec_int_citer_1B_str = aptrHexString(vec_int_citer_1B_ptr); + std::string vec_int_citer_1B_str = to_hexstring(vec_int_citer_1B_ptr); std_vec_int_citer vec_int_citer_1E = vec_int_1.cend(); uint8_t* vec_int_citer_1E_ptr = (uint8_t*)(vec_int_citer_1E.operator->()); - std::string vec_int_citer_1E_str = aptrHexString(vec_int_citer_1E_ptr); + std::string vec_int_citer_1E_str = to_hexstring(vec_int_citer_1E_ptr); std::ptrdiff_t vec_int_citer_1E_1B_ptrdiff = vec_int_citer_1E_ptr - vec_int_citer_1B_ptr; int vec_int_citer_1E_1B_ptr_count = vec_int_citer_1E_1B_ptrdiff / sizeof(int); |