mirror of
https://github.com/EQEmu/Server.git
synced 2026-05-19 13:28:25 +00:00
[Utility] Add std::string_view overloads for std::from_chars (#2392)
* Add std::string_view overloads for std::from_chars std::from_chars floating point support is still pour, so we provide some fall backs. These fall backs currently lack error handling. (since GCC 11 and MSVC 2019 16.4 FP support is added, clang with libc++ still doesn't support FP) GCC's floating point support is still rather pour (performance) and probably shouldn't be used, but we have support to if people want to now. Probably need more test cases ... * Fix issue with std::chars_format define lacking My test case for lacking FP support was clang with libc++ which defined this enum anyways.
This commit is contained in:
committed by
GitHub
parent
786a7e2169
commit
edda5ef811
@@ -30,6 +30,7 @@ public:
|
||||
TEST_ADD(StringUtilTest::EscapeStringTest);
|
||||
TEST_ADD(StringUtilTest::SearchDeliminatedStringTest);
|
||||
TEST_ADD(StringUtilTest::SplitStringTest);
|
||||
TEST_ADD(StringUtilTest::FromCharsTest);
|
||||
}
|
||||
|
||||
~StringUtilTest() {
|
||||
@@ -100,6 +101,21 @@ public:
|
||||
TEST_ASSERT(v[1] == "456");
|
||||
TEST_ASSERT(v[2] == "789");
|
||||
}
|
||||
|
||||
void FromCharsTest() {
|
||||
char int_chars[] = "123";
|
||||
int int_value = 0;
|
||||
|
||||
char float_chars[] = "3.14";
|
||||
float float_value = 0.0f;
|
||||
|
||||
Strings::from_chars(int_chars, int_value);
|
||||
TEST_ASSERT(int_value == 123);
|
||||
|
||||
Strings::from_chars(float_chars, float_value);
|
||||
TEST_ASSERT(float_value == 3.14f);
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user