30 #include <gtest/gtest.h> 34 TEST(StringUtilTests, ToDouble_0)
38 EXPECT_FLOAT_EQ(0, value);
42 EXPECT_FLOAT_EQ(0, value);
46 EXPECT_FLOAT_EQ(0, value);
50 EXPECT_FLOAT_EQ(0, value);
54 EXPECT_FLOAT_EQ(0, value);
58 EXPECT_FLOAT_EQ(0, value);
62 EXPECT_FLOAT_EQ(0, value);
66 EXPECT_FLOAT_EQ(0, value);
70 EXPECT_FLOAT_EQ(0, value);
74 EXPECT_FLOAT_EQ(0, value);
78 EXPECT_FLOAT_EQ(0, value);
82 EXPECT_FLOAT_EQ(0, value);
86 EXPECT_FLOAT_EQ(0, value);
90 EXPECT_FLOAT_EQ(0, value);
94 EXPECT_FLOAT_EQ(0, value);
98 EXPECT_FLOAT_EQ(0, value);
102 EXPECT_FLOAT_EQ(0, value);
106 EXPECT_FLOAT_EQ(0, value);
110 EXPECT_FLOAT_EQ(0, value);
114 EXPECT_FLOAT_EQ(0, value);
118 EXPECT_FLOAT_EQ(0, value);
122 EXPECT_FLOAT_EQ(0, value);
126 EXPECT_FLOAT_EQ(0, value);
130 EXPECT_FLOAT_EQ(0, value);
134 EXPECT_FLOAT_EQ(0, value);
138 EXPECT_FLOAT_EQ(0, value);
142 EXPECT_FLOAT_EQ(0, value);
146 EXPECT_FLOAT_EQ(0, value);
150 EXPECT_FLOAT_EQ(0, value);
154 EXPECT_FLOAT_EQ(0, value);
158 EXPECT_FLOAT_EQ(0, value);
162 EXPECT_FLOAT_EQ(0, value);
166 EXPECT_FLOAT_EQ(0, value);
170 EXPECT_FLOAT_EQ(0, value);
174 EXPECT_FLOAT_EQ(0, value);
178 EXPECT_FLOAT_EQ(0, value);
182 EXPECT_FLOAT_EQ(0, value);
186 EXPECT_FLOAT_EQ(0, value);
190 EXPECT_FLOAT_EQ(0, value);
194 EXPECT_FLOAT_EQ(0, value);
198 EXPECT_FLOAT_EQ(0, value);
202 EXPECT_FLOAT_EQ(0, value);
205 TEST(StringUtilTests, ToDouble_1)
209 EXPECT_FLOAT_EQ(1, value);
213 EXPECT_FLOAT_EQ(1, value);
217 EXPECT_FLOAT_EQ(1, value);
221 EXPECT_FLOAT_EQ(1, value);
225 EXPECT_FLOAT_EQ(1, value);
229 EXPECT_FLOAT_EQ(1, value);
233 EXPECT_FLOAT_EQ(1, value);
237 EXPECT_FLOAT_EQ(1, value);
241 EXPECT_FLOAT_EQ(1, value);
245 EXPECT_FLOAT_EQ(1, value);
249 EXPECT_FLOAT_EQ(1, value);
253 EXPECT_FLOAT_EQ(1, value);
257 EXPECT_FLOAT_EQ(1, value);
261 EXPECT_FLOAT_EQ(1, value);
265 EXPECT_FLOAT_EQ(-1, value);
269 EXPECT_FLOAT_EQ(-1, value);
273 EXPECT_FLOAT_EQ(-1, value);
277 EXPECT_FLOAT_EQ(-1, value);
281 EXPECT_FLOAT_EQ(-1, value);
285 EXPECT_FLOAT_EQ(-1, value);
289 EXPECT_FLOAT_EQ(-1, value);
293 EXPECT_FLOAT_EQ(1, value);
297 EXPECT_FLOAT_EQ(1, value);
301 EXPECT_FLOAT_EQ(1, value);
305 EXPECT_FLOAT_EQ(1, value);
309 EXPECT_FLOAT_EQ(1, value);
313 EXPECT_FLOAT_EQ(1, value);
317 EXPECT_FLOAT_EQ(1, value);
321 EXPECT_FLOAT_EQ(1, value);
325 EXPECT_FLOAT_EQ(1, value);
329 EXPECT_FLOAT_EQ(1, value);
333 EXPECT_FLOAT_EQ(1, value);
337 EXPECT_FLOAT_EQ(1, value);
341 EXPECT_FLOAT_EQ(1, value);
345 EXPECT_FLOAT_EQ(1, value);
349 EXPECT_FLOAT_EQ(-1, value);
353 EXPECT_FLOAT_EQ(-1, value);
357 EXPECT_FLOAT_EQ(-1, value);
361 EXPECT_FLOAT_EQ(-1, value);
365 EXPECT_FLOAT_EQ(-1, value);
369 EXPECT_FLOAT_EQ(-1, value);
373 EXPECT_FLOAT_EQ(-1, value);
377 EXPECT_FLOAT_EQ(1, value);
381 EXPECT_FLOAT_EQ(1, value);
385 EXPECT_FLOAT_EQ(1, value);
389 EXPECT_FLOAT_EQ(1, value);
393 EXPECT_FLOAT_EQ(1, value);
400 EXPECT_FLOAT_EQ(0.123456789, value);
404 EXPECT_FLOAT_EQ(123456789, value);
408 EXPECT_FLOAT_EQ(12345678.9, value);
412 EXPECT_FLOAT_EQ(123456789, value);
416 EXPECT_FLOAT_EQ(12345.6789, value);
420 EXPECT_FLOAT_EQ(1e308, value);
424 EXPECT_FLOAT_EQ(1e-307, value);
427 TEST(StringUtilTests, ToDoubleInvalid)
439 TEST(StringUtilTests, ToFloat_0)
443 EXPECT_FLOAT_EQ(0, value);
447 EXPECT_FLOAT_EQ(0, value);
451 EXPECT_FLOAT_EQ(0, value);
455 EXPECT_FLOAT_EQ(0, value);
459 EXPECT_FLOAT_EQ(0, value);
463 EXPECT_FLOAT_EQ(0, value);
467 EXPECT_FLOAT_EQ(0, value);
471 EXPECT_FLOAT_EQ(0, value);
475 EXPECT_FLOAT_EQ(0, value);
479 EXPECT_FLOAT_EQ(0, value);
483 EXPECT_FLOAT_EQ(0, value);
487 EXPECT_FLOAT_EQ(0, value);
491 EXPECT_FLOAT_EQ(0, value);
495 EXPECT_FLOAT_EQ(0, value);
499 EXPECT_FLOAT_EQ(0, value);
503 EXPECT_FLOAT_EQ(0, value);
507 EXPECT_FLOAT_EQ(0, value);
511 EXPECT_FLOAT_EQ(0, value);
515 EXPECT_FLOAT_EQ(0, value);
519 EXPECT_FLOAT_EQ(0, value);
523 EXPECT_FLOAT_EQ(0, value);
527 EXPECT_FLOAT_EQ(0, value);
531 EXPECT_FLOAT_EQ(0, value);
535 EXPECT_FLOAT_EQ(0, value);
539 EXPECT_FLOAT_EQ(0, value);
543 EXPECT_FLOAT_EQ(0, value);
547 EXPECT_FLOAT_EQ(0, value);
551 EXPECT_FLOAT_EQ(0, value);
555 EXPECT_FLOAT_EQ(0, value);
559 EXPECT_FLOAT_EQ(0, value);
563 EXPECT_FLOAT_EQ(0, value);
567 EXPECT_FLOAT_EQ(0, value);
571 EXPECT_FLOAT_EQ(0, value);
575 EXPECT_FLOAT_EQ(0, value);
579 EXPECT_FLOAT_EQ(0, value);
583 EXPECT_FLOAT_EQ(0, value);
587 EXPECT_FLOAT_EQ(0, value);
591 EXPECT_FLOAT_EQ(0, value);
595 EXPECT_FLOAT_EQ(0, value);
599 EXPECT_FLOAT_EQ(0, value);
603 EXPECT_FLOAT_EQ(0, value);
607 EXPECT_FLOAT_EQ(0, value);
610 TEST(StringUtilTests, ToFloat_1)
614 EXPECT_FLOAT_EQ(1, value);
618 EXPECT_FLOAT_EQ(1, value);
622 EXPECT_FLOAT_EQ(1, value);
626 EXPECT_FLOAT_EQ(1, value);
630 EXPECT_FLOAT_EQ(1, value);
634 EXPECT_FLOAT_EQ(1, value);
638 EXPECT_FLOAT_EQ(1, value);
642 EXPECT_FLOAT_EQ(1, value);
646 EXPECT_FLOAT_EQ(1, value);
650 EXPECT_FLOAT_EQ(1, value);
654 EXPECT_FLOAT_EQ(1, value);
658 EXPECT_FLOAT_EQ(1, value);
662 EXPECT_FLOAT_EQ(1, value);
666 EXPECT_FLOAT_EQ(1, value);
670 EXPECT_FLOAT_EQ(-1, value);
674 EXPECT_FLOAT_EQ(-1, value);
678 EXPECT_FLOAT_EQ(-1, value);
682 EXPECT_FLOAT_EQ(-1, value);
686 EXPECT_FLOAT_EQ(-1, value);
690 EXPECT_FLOAT_EQ(-1, value);
694 EXPECT_FLOAT_EQ(-1, value);
698 EXPECT_FLOAT_EQ(1, value);
702 EXPECT_FLOAT_EQ(1, value);
706 EXPECT_FLOAT_EQ(1, value);
710 EXPECT_FLOAT_EQ(1, value);
714 EXPECT_FLOAT_EQ(1, value);
718 EXPECT_FLOAT_EQ(1, value);
722 EXPECT_FLOAT_EQ(1, value);
726 EXPECT_FLOAT_EQ(1, value);
730 EXPECT_FLOAT_EQ(1, value);
734 EXPECT_FLOAT_EQ(1, value);
738 EXPECT_FLOAT_EQ(1, value);
742 EXPECT_FLOAT_EQ(1, value);
746 EXPECT_FLOAT_EQ(1, value);
750 EXPECT_FLOAT_EQ(1, value);
754 EXPECT_FLOAT_EQ(-1, value);
758 EXPECT_FLOAT_EQ(-1, value);
762 EXPECT_FLOAT_EQ(-1, value);
766 EXPECT_FLOAT_EQ(-1, value);
770 EXPECT_FLOAT_EQ(-1, value);
774 EXPECT_FLOAT_EQ(-1, value);
778 EXPECT_FLOAT_EQ(-1, value);
782 EXPECT_FLOAT_EQ(1, value);
786 EXPECT_FLOAT_EQ(1, value);
790 EXPECT_FLOAT_EQ(1, value);
794 EXPECT_FLOAT_EQ(1, value);
798 EXPECT_FLOAT_EQ(1, value);
805 EXPECT_FLOAT_EQ(0.123456789, value);
809 EXPECT_FLOAT_EQ(123456789, value);
813 EXPECT_FLOAT_EQ(12345678.9, value);
817 EXPECT_FLOAT_EQ(123456789, value);
821 EXPECT_FLOAT_EQ(12345.6789, value);
825 EXPECT_FLOAT_EQ(1e38, value);
829 EXPECT_FLOAT_EQ(1e-37, value);
832 TEST(StringUtilTests, ToFloatInvalid)
846 TEST(StringUtilTests, ToInt32Base10)
873 EXPECT_EQ(-1, value);
877 EXPECT_EQ(12345678, value);
881 EXPECT_EQ(12345678, value);
885 EXPECT_EQ(-123456789, value);
889 EXPECT_EQ(2147483647, value);
892 TEST(StringUtilTests, ToInt32Base10Invalid)
912 TEST(StringUtilTests, ToInt32Base16)
939 EXPECT_EQ(-1, value);
943 EXPECT_EQ(0x12345678, value);
947 EXPECT_EQ(0x12345678, value);
951 EXPECT_EQ(-0x12345678, value);
955 EXPECT_EQ(0xaff, value);
958 TEST(StringUtilTests, ToInt32Base16Invalid)
973 TEST(StringUtilTests, ToUInt32Base10)
1000 EXPECT_EQ(12345678, value);
1004 EXPECT_EQ(12345678, value);
1008 EXPECT_EQ(4294967295, value);
1011 TEST(StringUtilTests, ToUInt32Base10Invalid)
1036 testing::InitGoogleTest(&argc, argv);
1038 return RUN_ALL_TESTS();
int main(int argc, char **argv)
bool ToInt32(const std::string &string, int32_t &value, int32_t base=10)
TEST(StringUtilTests, ToDouble_0)
bool ToUInt32(const std::string &string, uint32_t &value, int32_t base=10)
bool ToFloat(const std::string &string, float &value)
bool ToDouble(const std::string &string, double &value)