aboutsummaryrefslogtreecommitdiff
path: root/test/common/StringToNumberConverterTest.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'test/common/StringToNumberConverterTest.cpp')
-rw-r--r--test/common/StringToNumberConverterTest.cpp70
1 files changed, 35 insertions, 35 deletions
diff --git a/test/common/StringToNumberConverterTest.cpp b/test/common/StringToNumberConverterTest.cpp
index dc37bac0..d4bb36f4 100644
--- a/test/common/StringToNumberConverterTest.cpp
+++ b/test/common/StringToNumberConverterTest.cpp
@@ -5,79 +5,79 @@
TEST_CASE("StringToIntegerConverterImpl Base0", "[string]") {
using namespace cru;
- StringToIntegerConverterImpl converter(0, 0);
+ StringToIntegerConverter converter({}, 0);
Index processed_characters_count;
REQUIRE(converter.Parse("12345678", &processed_characters_count) ==
- StringToIntegerConverterImplResult(false, 12345678));
+ StringToIntegerResult(false, 12345678));
REQUIRE(processed_characters_count == 8);
REQUIRE(converter.Parse("0", &processed_characters_count) ==
- StringToIntegerConverterImplResult(false, 0));
+ StringToIntegerResult(false, 0));
REQUIRE(processed_characters_count == 1);
REQUIRE(converter.Parse("012", &processed_characters_count) ==
- StringToIntegerConverterImplResult(false, 012));
+ StringToIntegerResult(false, 012));
REQUIRE(processed_characters_count == 3);
REQUIRE(converter.Parse("0x12", &processed_characters_count) ==
- StringToIntegerConverterImplResult(false, 0x12));
+ StringToIntegerResult(false, 0x12));
REQUIRE(processed_characters_count == 4);
REQUIRE(converter.Parse("0X12", &processed_characters_count) ==
- StringToIntegerConverterImplResult(false, 0x12));
+ StringToIntegerResult(false, 0x12));
REQUIRE(processed_characters_count == 4);
REQUIRE(converter.Parse("0b101", &processed_characters_count) ==
- StringToIntegerConverterImplResult(false, 0b101));
+ StringToIntegerResult(false, 0b101));
REQUIRE(processed_characters_count == 5);
REQUIRE(converter.Parse("0B101", &processed_characters_count) ==
- StringToIntegerConverterImplResult(false, 0b101));
+ StringToIntegerResult(false, 0b101));
REQUIRE(processed_characters_count == 5);
REQUIRE(converter.Parse("-123", &processed_characters_count) ==
- StringToIntegerConverterImplResult(true, 123));
+ StringToIntegerResult(true, 123));
REQUIRE(processed_characters_count == 4);
REQUIRE(converter.Parse("-0x10", &processed_characters_count) ==
- StringToIntegerConverterImplResult(true, 0x10));
+ StringToIntegerResult(true, 0x10));
REQUIRE(processed_characters_count == 5);
}
TEST_CASE("StringToIntegerConverterImpl Base0ForError", "[string]") {
using namespace cru;
- StringToIntegerConverterImpl converter(0, 0);
+ StringToIntegerConverter converter({}, 0);
Index processed_characters_count;
REQUIRE(converter.Parse("a", &processed_characters_count) ==
- StringToIntegerConverterImplResult(false, 0));
+ StringToIntegerResult(false, 0));
REQUIRE(processed_characters_count == 0);
REQUIRE(converter.Parse("0a", &processed_characters_count) ==
- StringToIntegerConverterImplResult(false, 0));
+ StringToIntegerResult(false, 0));
REQUIRE(processed_characters_count == 0);
REQUIRE(converter.Parse("0x", &processed_characters_count) ==
- StringToIntegerConverterImplResult(false, 0));
+ StringToIntegerResult(false, 0));
REQUIRE(processed_characters_count == 0);
REQUIRE(converter.Parse("0xx", &processed_characters_count) ==
- StringToIntegerConverterImplResult(false, 0));
+ StringToIntegerResult(false, 0));
REQUIRE(processed_characters_count == 0);
REQUIRE(converter.Parse(" 0", &processed_characters_count) ==
- StringToIntegerConverterImplResult(false, 0));
+ StringToIntegerResult(false, 0));
REQUIRE(processed_characters_count == 0);
REQUIRE(converter.Parse("0 ", &processed_characters_count) ==
- StringToIntegerConverterImplResult(false, 0));
+ StringToIntegerResult(false, 0));
REQUIRE(processed_characters_count == 0);
}
TEST_CASE("StringToIntegerConverterImpl ThrowOnErrorFlag", "[string]") {
using namespace cru;
- StringToIntegerConverterImpl converter(StringToNumberFlags::kThrowOnError, 0);
+ StringToIntegerConverter converter(StringToNumberFlags::kThrowOnError, 0);
Index processed_characters_count;
REQUIRE_THROWS_AS(converter.Parse("?", &processed_characters_count),
Exception);
@@ -85,56 +85,56 @@ TEST_CASE("StringToIntegerConverterImpl ThrowOnErrorFlag", "[string]") {
TEST_CASE("StringToIntegerConverterImpl AllowLeadingZeroFlag", "[string]") {
using namespace cru;
- StringToIntegerConverterImpl converter(
+ StringToIntegerConverter converter(
StringToNumberFlags::kAllowLeadingSpaces, 0);
Index processed_characters_count;
REQUIRE(converter.Parse(" 123", &processed_characters_count) ==
- StringToIntegerConverterImplResult(false, 123));
+ StringToIntegerResult(false, 123));
REQUIRE(processed_characters_count == 6);
}
TEST_CASE("StringToIntegerConverterImpl AllowTrailingZeroFlag", "[string]") {
using namespace cru;
- StringToIntegerConverterImpl converter(
+ StringToIntegerConverter converter(
StringToNumberFlags::kAllowTrailingSpaces, 0);
Index processed_characters_count;
REQUIRE(converter.Parse("123 ", &processed_characters_count) ==
- StringToIntegerConverterImplResult(false, 123));
+ StringToIntegerResult(false, 123));
REQUIRE(processed_characters_count == 6);
}
TEST_CASE("StringToIntegerConverterImpl AllowTrailingJunk", "[string]") {
using namespace cru;
- StringToIntegerConverterImpl converter(
- StringToNumberFlags::kAllowLeadingZeroForInteger, 0);
+ StringToIntegerConverter converter(
+ StringToNumberFlags::kAllowTrailingJunk, 0);
Index processed_characters_count;
REQUIRE(converter.Parse("123 12", &processed_characters_count) ==
- StringToIntegerConverterImplResult(false, 123));
+ StringToIntegerResult(false, 123));
REQUIRE(processed_characters_count == 3);
}
TEST_CASE("StringToIntegerConverterImpl AllowLeadingZeroForInteger",
"[string]") {
using namespace cru;
- StringToIntegerConverterImpl converter(
+ StringToIntegerConverter converter(
StringToNumberFlags::kAllowLeadingZeroForInteger, 0);
Index processed_characters_count;
REQUIRE(converter.Parse("0x0012", &processed_characters_count) ==
- StringToIntegerConverterImplResult(false, 0x12));
+ StringToIntegerResult(false, 0x12));
REQUIRE(processed_characters_count == 6);
REQUIRE(converter.Parse("000011", &processed_characters_count) ==
- StringToIntegerConverterImplResult(false, 000011));
+ StringToIntegerResult(false, 000011));
REQUIRE(processed_characters_count == 6);
REQUIRE(converter.Parse("0b0011", &processed_characters_count) ==
- StringToIntegerConverterImplResult(false, 0b0011));
+ StringToIntegerResult(false, 0b0011));
REQUIRE(processed_characters_count == 6);
}
TEST_CASE("StringToIntegerConverterImpl CompositeFlags", "[string]") {
using namespace cru;
- StringToIntegerConverterImpl converter(
+ StringToIntegerConverter converter(
StringToNumberFlags::kAllowLeadingSpaces |
StringToNumberFlags::kAllowTrailingJunk |
StringToNumberFlags::kAllowLeadingZeroForInteger,
@@ -142,25 +142,25 @@ TEST_CASE("StringToIntegerConverterImpl CompositeFlags", "[string]") {
Index processed_characters_count;
REQUIRE(converter.Parse(" 0x00123!!!", &processed_characters_count) ==
- StringToIntegerConverterImplResult(false, 0x00123));
+ StringToIntegerResult(false, 0x00123));
REQUIRE(processed_characters_count == 10);
}
TEST_CASE("StringToIntegerConverterImpl OtherBase", "[string]") {
using namespace cru;
- StringToIntegerConverterImpl converter(0, 7);
+ StringToIntegerConverter converter({}, 7);
Index processed_characters_count;
REQUIRE(converter.Parse("12", &processed_characters_count) ==
- StringToIntegerConverterImplResult(false, 9));
+ StringToIntegerResult(false, 9));
REQUIRE(processed_characters_count == 2);
REQUIRE(converter.Parse("-12", &processed_characters_count) ==
- StringToIntegerConverterImplResult(true, 9));
+ StringToIntegerResult(true, 9));
REQUIRE(processed_characters_count == 3);
converter.base = 11;
REQUIRE(converter.Parse("1a", &processed_characters_count) ==
- StringToIntegerConverterImplResult(false, 21));
+ StringToIntegerResult(false, 21));
REQUIRE(processed_characters_count == 2);
}