mirror of
https://github.com/yhirose/cpp-peglib.git
synced 2024-12-22 11:55:30 +00:00
Added unit test
This commit is contained in:
parent
9dfbbc5671
commit
45ba08b576
@ -934,3 +934,20 @@ TEST_CASE("Negated Class test", "[general]") {
|
|||||||
REQUIRE_FALSE(parser.parse("ABCZ_"));
|
REQUIRE_FALSE(parser.parse("ABCZ_"));
|
||||||
REQUIRE_FALSE(parser.parse(""));
|
REQUIRE_FALSE(parser.parse(""));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_CASE("`token_to_number<float>` test", "[general]") {
|
||||||
|
parser parser(R"(
|
||||||
|
S <- '1.1'
|
||||||
|
)");
|
||||||
|
parser.enable_ast();
|
||||||
|
|
||||||
|
std::shared_ptr<Ast> ast;
|
||||||
|
auto ret = parser.parse("1.1", ast);
|
||||||
|
|
||||||
|
REQUIRE(ret == true);
|
||||||
|
REQUIRE(ast->is_token == true);
|
||||||
|
REQUIRE(ast->token == "1.1");
|
||||||
|
REQUIRE(ast->token_to_number<float>() == 1.1f);
|
||||||
|
REQUIRE(ast->nodes.empty());
|
||||||
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user