2025-06-24 11:29:01 +08:00
|
|
|
#include <gtest/gtest.h>
|
|
|
|
#include <yycc.hpp>
|
2025-06-30 08:45:18 +08:00
|
|
|
#include <yycc/num/parse.hpp>
|
2025-06-24 11:29:01 +08:00
|
|
|
|
|
|
|
#include <yycc/prelude/rust.hpp>
|
|
|
|
|
2025-06-30 08:45:18 +08:00
|
|
|
#define PARSE ::yycc::num::parse
|
2025-06-24 11:29:01 +08:00
|
|
|
|
2025-06-30 08:45:18 +08:00
|
|
|
namespace yycctest::num::parse {
|
2025-06-24 11:29:01 +08:00
|
|
|
|
|
|
|
// These 2 test macros build string container via given string.
|
|
|
|
// Check `try_parse` first, and then check `parse`.
|
|
|
|
|
2025-07-14 09:43:23 +08:00
|
|
|
#define TEST_NS NumParse
|
|
|
|
|
2025-06-26 10:27:33 +08:00
|
|
|
#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__)); \
|
|
|
|
}
|
2025-06-24 11:29:01 +08:00
|
|
|
|
2025-07-14 09:43:23 +08:00
|
|
|
#include "../../shared/parse_template.hpp"
|
2025-06-24 11:29:01 +08:00
|
|
|
|
2025-07-14 09:43:23 +08:00
|
|
|
} // namespace yycctest::num::parse
|