MCPcopy Create free account
hub / github.com/chen3feng/toft / TEST

Function TEST

base/string/number_test.cpp:45–77  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

43INSTANTIATE_TYPED_TEST_CASE_P(NumericTypes, StringNumberTest, NumericTypes);
44
45TEST(StringNumber, IntegerToStringBuffer)
46{
47 char buffer[1024];
48 int32_t n1 = INT_MAX;
49 int32_t n2 = -INT_MAX;
50 int32_t n3 = 0;
51 int32_t n4 = 100000;
52 uint32_t n5 = 3147483647U;
53 int32_t n6 = -123456789;
54
55 int64_t s1 = LLONG_MAX;
56 int64_t s2 = INT_MAX;
57 int64_t s3 = 0;
58 int64_t s4 = 1234567890123LL;
59 int64_t s5 = 1000000000000LL;
60 int64_t s6 = -1234567890034500LL;
61 int64_t s7 = LLONG_MIN;
62
63 ASSERT_STREQ("2147483647", IntegerToString(n1, buffer));
64 ASSERT_STREQ("-2147483647", IntegerToString(n2, buffer));
65 ASSERT_STREQ("0", IntegerToString(n3, buffer));
66 ASSERT_STREQ("100000", IntegerToString(n4, buffer));
67 ASSERT_STREQ("3147483647", IntegerToString(n5, buffer));
68 ASSERT_STREQ("-123456789", IntegerToString(n6, buffer));
69
70 ASSERT_STREQ("9223372036854775807", IntegerToString(s1, buffer));
71 ASSERT_STREQ("2147483647", IntegerToString(s2, buffer));
72 ASSERT_STREQ("0", IntegerToString(s3, buffer));
73 ASSERT_STREQ("1234567890123", IntegerToString(s4, buffer));
74 ASSERT_STREQ("1000000000000", IntegerToString(s5, buffer));
75 ASSERT_STREQ("-1234567890034500", IntegerToString(s6, buffer));
76 ASSERT_STREQ("-9223372036854775808", IntegerToString(s7, buffer));
77}
78
79TEST(StringNumber, IntegerToString)
80{

Callers

nothing calls this directly

Calls 10

IntegerToStringFunction · 0.85
UInt16ToHexStringFunction · 0.85
UInt32ToHexStringFunction · 0.85
UInt64ToHexStringFunction · 0.85
DoubleToStringFunction · 0.85
FloatToStringFunction · 0.85
FormatMeasureFunction · 0.85
FormatBinaryMeasureFunction · 0.85
StringToNumberFunction · 0.70
ParseNumberFunction · 0.70

Tested by

no test coverage detected