18 #ifndef ABSL_STRINGS_INTERNAL_NUMBERS_TEST_COMMON_H_
19 #define ABSL_STRINGS_INTERNAL_NUMBERS_TEST_COMMON_H_
26 #include "absl/base/config.h"
30 namespace strings_internal {
32 template <
typename IntType>
35 if (base <= 1 || base > 36) {
40 destination->push_back(
'0');
51 char c = remainder < 10 ?
'0' + remainder :
'A' + remainder - 10;
52 destination->insert(0, 1, c);
57 destination->insert(0, 1,
'-');
70 static const std::array<uint32_test_case, 27>
test_cases{{
72 {
"0x34234324",
true, 16, 0x34234324},
73 {
"34234324",
true, 16, 0x34234324},
76 {
" \f\v 46",
true, 10, 46},
77 {
" \t\n 72717222",
true, 8, 072717222},
78 {
" \t\n 072717222",
true, 8, 072717222},
79 {
" \t\n 072717228",
false, 8, 07271722},
83 {
"34234324",
true, 0, 34234324},
85 {
"34234324 \n\t",
true, 10, 34234324},
96 {
"34234324a",
false, 0, 34234324},
97 {
"34234.3",
false, 0, 34234},
99 {
" -123",
false, 0, 0},
100 {
" \t\n -123",
false, 0, 0},
105 {
nullptr,
false, 0, 0},
118 static const std::array<uint64_test_case, 34>
test_cases{{
119 {
"0x3423432448783446",
true, 16,
int64_t{0x3423432448783446}},
120 {
"3423432448783446",
true, 16,
int64_t{0x3423432448783446}},
125 {
" \t\n 0xffffffffffffffff",
true, 16,
128 {
"012345670123456701234",
true, 8,
int64_t{012345670123456701234}},
129 {
"12345670123456701234",
true, 8,
int64_t{012345670123456701234}},
131 {
"12845670123456701234",
false, 8, 0},
134 {
"34234324487834466",
true, 0,
int64_t{34234324487834466}},
136 {
" \t\n 18446744073709551615",
true, 0,
139 {
"34234324487834466 \n\t ",
true, 0,
int64_t{34234324487834466}},
141 {
" \f\v 46",
true, 10, 46},
153 {
"abc",
false, 0, 0},
154 {
"34234324487834466a",
false, 0, 0},
155 {
"34234487834466.3",
false, 0, 0},
157 {
" -123",
false, 0, 0},
158 {
" \t\n -123",
false, 0, 0},
161 {
"18446744073709551616",
false, 10, 0},
162 {
"18446744073709551616",
false, 0, 0},
163 {
"0x10000000000000000",
false, 16,
165 {
"0X10000000000000000",
false, 16,
168 {
"0X10000000000000000",
false, 0,
171 {
"0x1234",
true, 16, 0x1234},
174 {
"1234",
true, 0, 1234},
175 {
nullptr,
false, 0, 0},
184 #endif // ABSL_STRINGS_INTERNAL_NUMBERS_TEST_COMMON_H_