2025-06-26 10:27:33 +08:00
|
|
|
#include <gtest/gtest.h>
|
|
|
|
#include <yycc.hpp>
|
2025-06-30 08:45:18 +08:00
|
|
|
#include <yycc/rust/num/parse.hpp>
|
2025-06-26 10:27:33 +08:00
|
|
|
|
|
|
|
#include <yycc/prelude/rust.hpp>
|
|
|
|
|
2025-06-30 08:45:18 +08:00
|
|
|
#define PARSE ::yycc::rust::num::parse
|
2025-06-26 10:27:33 +08:00
|
|
|
|
2025-07-14 09:43:23 +08:00
|
|
|
namespace yycctest::rust::num::parse {
|
2025-06-26 10:27:33 +08:00
|
|
|
|
|
|
|
// We only want to test it if C++ support it.
|
|
|
|
#if defined(YYCC_CPPFEAT_EXPECTED)
|
|
|
|
|
2025-07-14 09:43:23 +08:00
|
|
|
#define TEST_NS RustNumParse
|
2025-06-26 10:27:33 +08:00
|
|
|
|
|
|
|
#define TEST_SUCCESS(type_t, expected_value, string_value, ...) \
|
|
|
|
{ \
|
|
|
|
u8string cache_string(YYCC_U8(string_value)); \
|
|
|
|
auto rv = PARSE::parse<type_t>(cache_string, ##__VA_ARGS__); \
|
|
|
|
ASSERT_TRUE(rv.has_value()); \
|
|
|
|
EXPECT_EQ(rv.value(), expected_value); \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define TEST_FAIL(type_t, string_value, ...) \
|
|
|
|
{ \
|
|
|
|
u8string cache_string(YYCC_U8(string_value)); \
|
|
|
|
auto rv = PARSE::parse<type_t>(cache_string, ##__VA_ARGS__); \
|
|
|
|
EXPECT_FALSE(rv.has_value()); \
|
|
|
|
}
|
|
|
|
|
2025-07-14 09:43:23 +08:00
|
|
|
#include "../../../shared/parse_template.hpp"
|
2025-06-26 10:27:33 +08:00
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
} // namespace yycctest::rust::parse
|