diff options
author | crupest <crupest@outlook.com> | 2022-01-19 22:55:22 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2022-01-19 22:55:22 +0800 |
commit | 2028bc4914638360fb756079dbddbdbe52676821 (patch) | |
tree | bcbcf8d2d7eead39689324a06767e83faef72dfe /test | |
parent | a42609c6cc6d89501d0421f371e4a2dc10dd1685 (diff) | |
download | cru-2028bc4914638360fb756079dbddbdbe52676821.tar.gz cru-2028bc4914638360fb756079dbddbdbe52676821.tar.bz2 cru-2028bc4914638360fb756079dbddbdbe52676821.zip |
...
Diffstat (limited to 'test')
-rw-r--r-- | test/common/StringTest.cpp | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/test/common/StringTest.cpp b/test/common/StringTest.cpp index 7198f47b..737a93ad 100644 --- a/test/common/StringTest.cpp +++ b/test/common/StringTest.cpp @@ -1,5 +1,5 @@ -#include "cru/common/String.hpp" #include "cru/common/Format.hpp" +#include "cru/common/String.hpp" #include <gtest/gtest.h> @@ -69,3 +69,15 @@ TEST(String, SplitToLinesRemoveSpaceLine) { ASSERT_EQ(lines[1], String(u"def")); ASSERT_EQ(lines[2], String(u"ghi")); } + +TEST(String, ParseToFloat) { + using cru::String; + ASSERT_EQ(String(u"3.14159").ParseToDouble(), 3.14159); + ASSERT_EQ(String(u" 3.14159").ParseToDouble(), 3.14159); + ASSERT_EQ(String(u" 3.14159 ").ParseToDouble(), 3.14159); + + cru::Index processed_char_count = 0; + ASSERT_EQ(String(u" 3.14159 garbege").ParseToDouble(&processed_char_count), + 3.14159); + ASSERT_EQ(processed_char_count, 9); +} |