From e0d6dac4b103a557b37f4850fe76dacf87df7cb9 Mon Sep 17 00:00:00 2001 From: Roland Reichwein Date: Sun, 1 Nov 2020 16:26:22 +0100 Subject: Update cppbnf.cpp --- tests/test-cpp.cpp | 19 +++++++++++++++++-- tests/test-grammer.cpp | 6 +++--- 2 files changed, 20 insertions(+), 5 deletions(-) (limited to 'tests') diff --git a/tests/test-cpp.cpp b/tests/test-cpp.cpp index e5b2a1a..adfa54b 100644 --- a/tests/test-cpp.cpp +++ b/tests/test-cpp.cpp @@ -24,7 +24,7 @@ class CppTest: public ::testing::Test { protected: CppTest() { - //debug = true; + debug = true; } ~CppTest() { } @@ -42,7 +42,22 @@ TEST_F(CppTest, preprocessing_tokenize) { auto nodes = cpp.analysis(tokens); - ASSERT_EQ(nodes.size(), 60/*44*/); + ASSERT_EQ(nodes.size(), 58/*44*/); +} + +TEST_F(CppTest, preprocessing_tokenize_empty) { + CPP cpp; + auto pp_tokens = cpp.preprocessing_tokenize(""); + + ASSERT_EQ(pp_tokens.size(), 0); + + auto tokens = cpp.tokens_from_pptokens(pp_tokens); + + ASSERT_EQ(tokens.size(), 0); + + auto nodes = cpp.analysis(tokens); + + ASSERT_EQ(nodes.size(), 0); } TEST_F(CppTest, preprocessing_tokenize_compile_error) { diff --git a/tests/test-grammer.cpp b/tests/test-grammer.cpp index 1734da2..6af6992 100644 --- a/tests/test-grammer.cpp +++ b/tests/test-grammer.cpp @@ -50,7 +50,7 @@ TEST_F(GrammerTest, minimumSymbolsNeeded) { EXPECT_EQ(minimumSymbolsNeeded(compiler, "logical-or-expression"), 1); EXPECT_EQ(minimumSymbolsNeeded(compiler, "assignment-expression"), 1); EXPECT_EQ(minimumSymbolsNeeded(compiler, "declaration"), 1); - EXPECT_EQ(minimumSymbolsNeeded(compiler, "block-declaration"), 3); + EXPECT_EQ(minimumSymbolsNeeded(compiler, "block-declaration"), 2); EXPECT_EQ(minimumSymbolsNeeded(compiler, "simple-declaration"), 2); EXPECT_EQ(minimumSymbolsNeeded(compiler, "asm-declaration"), 5); EXPECT_EQ(minimumSymbolsNeeded(compiler, "namespace-alias-definition"), 5); @@ -58,8 +58,8 @@ TEST_F(GrammerTest, minimumSymbolsNeeded) { EXPECT_EQ(minimumSymbolsNeeded(compiler, "using-enum-declaration"), 4); EXPECT_EQ(minimumSymbolsNeeded(compiler, "using-directive"), 4); EXPECT_EQ(minimumSymbolsNeeded(compiler, "static_assert-declaration"), 5); - EXPECT_EQ(minimumSymbolsNeeded(compiler, "alias-declaration"), 7); + EXPECT_EQ(minimumSymbolsNeeded(compiler, "alias-declaration"), 5); EXPECT_EQ(minimumSymbolsNeeded(compiler, "opaque-enum-declaration"), 3); - EXPECT_EQ(minimumSymbolsNeeded(compiler, "function-definition"), 4); + EXPECT_EQ(minimumSymbolsNeeded(compiler, "function-definition"), 3); } -- cgit v1.2.3