refactor: finish rust parse and add testbench for it.
This commit is contained in:
@ -12,20 +12,22 @@ namespace yycctest::string::parse {
|
||||
// These 2 test macros build string container via given string.
|
||||
// Check `try_parse` first, and then check `parse`.
|
||||
|
||||
#define TEST_SUCCESS(type_t, value, string_value, ...) { \
|
||||
u8string cache_string(YYCC_U8(string_value)); \
|
||||
type_t cache; \
|
||||
ASSERT_TRUE(PARSE::try_parse<type_t>(cache_string, cache, ##__VA_ARGS__)); \
|
||||
EXPECT_EQ(cache, value); \
|
||||
EXPECT_EQ(PARSE::parse<type_t>(cache_string, ##__VA_ARGS__), value); \
|
||||
}
|
||||
#define TEST_SUCCESS(type_t, value, string_value, ...) \
|
||||
{ \
|
||||
u8string cache_string(YYCC_U8(string_value)); \
|
||||
type_t cache; \
|
||||
ASSERT_TRUE(PARSE::try_parse<type_t>(cache_string, cache, ##__VA_ARGS__)); \
|
||||
EXPECT_EQ(cache, value); \
|
||||
EXPECT_EQ(PARSE::parse<type_t>(cache_string, ##__VA_ARGS__), value); \
|
||||
}
|
||||
|
||||
#define TEST_FAIL(type_t, string_value, ...) { \
|
||||
u8string cache_string(YYCC_U8(string_value)); \
|
||||
type_t cache; \
|
||||
EXPECT_FALSE(PARSE::try_parse<type_t>(cache_string, cache, ##__VA_ARGS__)); \
|
||||
EXPECT_ANY_THROW(PARSE::parse<type_t>(cache_string, ##__VA_ARGS__)); \
|
||||
}
|
||||
#define TEST_FAIL(type_t, string_value, ...) \
|
||||
{ \
|
||||
u8string cache_string(YYCC_U8(string_value)); \
|
||||
type_t cache; \
|
||||
EXPECT_FALSE(PARSE::try_parse<type_t>(cache_string, cache, ##__VA_ARGS__)); \
|
||||
EXPECT_ANY_THROW(PARSE::parse<type_t>(cache_string, ##__VA_ARGS__)); \
|
||||
}
|
||||
|
||||
TEST(StringParse, Common) {
|
||||
TEST_SUCCESS(i8, INT8_C(-61), "-61");
|
||||
@ -79,4 +81,4 @@ namespace yycctest::string::parse {
|
||||
TEST_FAIL(bool, "hello, world!");
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace yycctest::string::parse
|
||||
|
Reference in New Issue
Block a user