From 7edbd99775416a32c88acf8e9379518436905f02 Mon Sep 17 00:00:00 2001 From: Roland Reichwein Date: Sat, 21 Nov 2020 15:19:45 +0100 Subject: Support gcc 10 and clang 11 --- tests/test-asm.cpp | 60 +++++++++++++++++++++++++------------------------- tests/test-cpp.cpp | 14 ++++++------ tests/test-elf.cpp | 4 ++-- tests/test-grammer.cpp | 32 +++++++++++++-------------- tests/test-lexer.cpp | 2 +- 5 files changed, 56 insertions(+), 56 deletions(-) (limited to 'tests') diff --git a/tests/test-asm.cpp b/tests/test-asm.cpp index 019f89c..650a48a 100644 --- a/tests/test-asm.cpp +++ b/tests/test-asm.cpp @@ -57,7 +57,7 @@ TEST_F(AsmTest, Intel64_add) { Asm::Args args{{Asm::Args::Register32("eax"), Asm::Args::Immediate32(1)}}; segment.push_back(makeOp("add", args)); - ASSERT_EQ(segment.size(), 1); + ASSERT_EQ(segment.size(), size_t(1)); ASSERT_EQ(segment.getCode(), std::vector({0x05, 0x01, 0x00, 0x00, 0x00})); } @@ -66,7 +66,7 @@ TEST_F(AsmTest, Intel64_int_0) { Asm::Args args{{Asm::Args::Immediate8(0)}}; segment.push_back(makeOp("int", args)); - ASSERT_EQ(segment.size(), 1); + ASSERT_EQ(segment.size(), size_t(1)); ASSERT_EQ(segment.getCode(), std::vector{0xCE}); } @@ -75,7 +75,7 @@ TEST_F(AsmTest, Intel64_int_1) { Asm::Args args{{Asm::Args::Immediate8(1)}}; segment.push_back(makeOp("int", args)); - ASSERT_EQ(segment.size(), 1); + ASSERT_EQ(segment.size(), size_t(1)); ASSERT_EQ(segment.getCode(), std::vector{0xF1}); } @@ -84,7 +84,7 @@ TEST_F(AsmTest, Intel64_int_5) { Asm::Args args{{Asm::Args::Immediate8(5)}}; segment.push_back(makeOp("int", args)); - ASSERT_EQ(segment.size(), 1); + ASSERT_EQ(segment.size(), size_t(1)); ASSERT_EQ(segment.getCode(), std::vector({0xCD, 0x05})); } @@ -92,7 +92,7 @@ TEST_F(AsmTest, Intel64_nop) { Segment segment; segment.push_back(makeOp("nop")); - ASSERT_EQ(segment.size(), 1); + ASSERT_EQ(segment.size(), size_t(1)); ASSERT_EQ(segment.getCode(), std::vector{0x90}); } @@ -100,7 +100,7 @@ TEST_F(AsmTest, Intel64_ret) { Segment segment; segment.push_back(makeOp("ret")); - ASSERT_EQ(segment.size(), 1); + ASSERT_EQ(segment.size(), size_t(1)); ASSERT_EQ(segment.getCode(), std::vector{0xC3}); } @@ -119,7 +119,7 @@ TEST_F(AsmTest, Intel64_multiple) { segment.insertAddresses(); - ASSERT_EQ(segment.size(), 7); + ASSERT_EQ(segment.size(), size_t(7)); ASSERT_EQ(segment.getCode(), std::vector( { 0x90, // nop @@ -133,7 +133,7 @@ TEST_F(AsmTest, Intel64_multiple) { segment.optimize(); - ASSERT_EQ(segment.size(), 7); + ASSERT_EQ(segment.size(), size_t(7)); ASSERT_EQ(segment.getCode(), std::vector( { 0x90, // nop @@ -148,38 +148,38 @@ TEST_F(AsmTest, Intel64_multiple) { TEST_F(AsmParseTest, parse_empty) { std::vector> chunks0{parseAsm("")}; - ASSERT_EQ(chunks0.size(), 0); + ASSERT_EQ(chunks0.size(), 0u); std::vector> chunks1{parseAsm("\n\n")}; - ASSERT_EQ(chunks1.size(), 0); + ASSERT_EQ(chunks1.size(), 0u); std::vector> chunks2{parseAsm("\n\n")}; - ASSERT_EQ(chunks2.size(), 0); + ASSERT_EQ(chunks2.size(), 0u); } TEST_F(AsmParseTest, parse_op_0) { std::vector> chunks0{parseAsm("nop")}; - ASSERT_EQ(chunks0.size(), 1); + ASSERT_EQ(chunks0.size(), 1u); } TEST_F(AsmParseTest, parse_op_1) { std::vector> chunks1{parseAsm("neg edi")}; - ASSERT_EQ(chunks1.size(), 1); + ASSERT_EQ(chunks1.size(), 1u); } TEST_F(AsmParseTest, parse_op_2) { std::vector> chunks2{parseAsm("add eax, edx")}; - ASSERT_EQ(chunks2.size(), 1); + ASSERT_EQ(chunks2.size(), 1u); } TEST_F(AsmParseTest, parse_op_3) { std::vector> chunks3{parseAsm("add eax, 3")}; - ASSERT_EQ(chunks3.size(), 1); + ASSERT_EQ(chunks3.size(), 1u); } TEST_F(AsmParseTest, parse_op_4) { std::vector> chunks4{parseAsm("add [rdi], 3")}; - ASSERT_EQ(chunks4.size(), 1); + ASSERT_EQ(chunks4.size(), 1u); } TEST_F(AsmParseTest, parse_op_4_error) { @@ -188,7 +188,7 @@ TEST_F(AsmParseTest, parse_op_4_error) { TEST_F(AsmParseTest, parse_op_5) { std::vector> chunks5{parseAsm("add byte ptr [rdi], 3")}; - ASSERT_EQ(chunks5.size(), 1); + ASSERT_EQ(chunks5.size(), 1u); } TEST_F(AsmParseTest, parse_op_5_error) { @@ -197,7 +197,7 @@ TEST_F(AsmParseTest, parse_op_5_error) { TEST_F(AsmParseTest, parse_op_6) { std::vector> chunks6{parseAsm("add dword ptr[rdi], 3")}; - ASSERT_EQ(chunks6.size(), 1); + ASSERT_EQ(chunks6.size(), 1u); } TEST_F(AsmParseTest, parse_op_6_error) { @@ -206,46 +206,46 @@ TEST_F(AsmParseTest, parse_op_6_error) { TEST_F(AsmParseTest, parse_op_7) { std::vector> chunks7{parseAsm("add qword ptr[rdi], 3")}; - ASSERT_EQ(chunks7.size(), 1); + ASSERT_EQ(chunks7.size(), 1u); } TEST_F(AsmParseTest, parse_label) { std::vector> chunks0{parseAsm("label1:")}; - ASSERT_EQ(chunks0.size(), 1); + ASSERT_EQ(chunks0.size(), 1u); std::vector> chunks1{parseAsm("label2: add eax, 3")}; - ASSERT_EQ(chunks1.size(), 2); + ASSERT_EQ(chunks1.size(), 2u); } TEST_F(AsmParseTest, parse_multiline) { std::vector> chunks1{parseAsm("add eax, 3\n")}; - ASSERT_EQ(chunks1.size(), 1); + ASSERT_EQ(chunks1.size(), 1u); std::vector> chunks2{parseAsm("label2: add eax, 3\n mul rdx")}; - ASSERT_EQ(chunks2.size(), 3); + ASSERT_EQ(chunks2.size(), 3u); std::vector> chunks3{parseAsm("label2: add eax, 3\n mul rdx\n")}; - ASSERT_EQ(chunks3.size(), 3); + ASSERT_EQ(chunks3.size(), 3u); std::vector> chunks4{parseAsm("label2: add eax, 3\n\n\n mul rdx")}; - ASSERT_EQ(chunks4.size(), 3); + ASSERT_EQ(chunks4.size(), 3u); } TEST_F(AsmParseTest, parse_comment) { std::vector> chunks0{parseAsm(" ; Comment 1")}; - ASSERT_EQ(chunks0.size(), 0); + ASSERT_EQ(chunks0.size(), 0u); std::vector> chunks1{parseAsm("label2: add eax, 3 ; A comment")}; - ASSERT_EQ(chunks1.size(), 2); + ASSERT_EQ(chunks1.size(), 2u); std::vector> chunks3{parseAsm("label2: add eax, 3 // Another comment")}; - ASSERT_EQ(chunks3.size(), 2); + ASSERT_EQ(chunks3.size(), 2u); std::vector> chunks4{parseAsm("label2: add eax, 3 // Another comment\nadd rax, rdi")}; - ASSERT_EQ(chunks4.size(), 3); + ASSERT_EQ(chunks4.size(), 3u); std::vector> chunks5{parseAsm("label2: add eax, 3 // Another comment\n \t add rax, rdi")}; - ASSERT_EQ(chunks5.size(), 3); + ASSERT_EQ(chunks5.size(), 3u); } TEST_F(AsmParseTest, parse_error) { diff --git a/tests/test-cpp.cpp b/tests/test-cpp.cpp index 2e1b29e..d4e8c66 100644 --- a/tests/test-cpp.cpp +++ b/tests/test-cpp.cpp @@ -34,30 +34,30 @@ TEST_F(CppTest, preprocessing_tokenize) { CPP cpp; auto pp_tokens = cpp.preprocessing_tokenize("int main() { return 1; }"); - ASSERT_EQ(pp_tokens.size(), 9); + ASSERT_EQ(pp_tokens.size(), size_t(9)); auto tokens = cpp.tokens_from_pptokens(pp_tokens); - ASSERT_EQ(tokens.size(), 9); + ASSERT_EQ(tokens.size(), size_t(9)); auto nodes = cpp.analysis(tokens); - ASSERT_EQ(nodes.size(), 43); + ASSERT_EQ(nodes.size(), size_t(43)); } TEST_F(CppTest, preprocessing_tokenize_empty) { CPP cpp; auto pp_tokens = cpp.preprocessing_tokenize(""); - ASSERT_EQ(pp_tokens.size(), 0); + ASSERT_EQ(pp_tokens.size(), size_t(0)); auto tokens = cpp.tokens_from_pptokens(pp_tokens); - ASSERT_EQ(tokens.size(), 0); + ASSERT_EQ(tokens.size(), size_t(0)); auto nodes = cpp.analysis(tokens); - ASSERT_EQ(nodes.size(), 1); + ASSERT_EQ(nodes.size(), size_t(1)); ASSERT_EQ(nodes[0].type, "translation-unit"); } @@ -68,7 +68,7 @@ TEST_F(CppTest, preprocessing_tokenize_compile_error) { auto tokens = cpp.tokens_from_pptokens(ppTree); - ASSERT_EQ(tokens.size(), 2); + ASSERT_EQ(tokens.size(), size_t(2)); try { auto nodes = cpp.analysis(tokens); diff --git a/tests/test-elf.cpp b/tests/test-elf.cpp index 0bf1d42..737ba65 100644 --- a/tests/test-elf.cpp +++ b/tests/test-elf.cpp @@ -53,7 +53,7 @@ TEST_F(ElfTest, write_code) { }, {}); ASSERT_TRUE(fs::exists(TempFilename())); - ASSERT_GT(fs::file_size(TempFilename()), 0); + ASSERT_GT(fs::file_size(TempFilename()), size_t(0)); } TEST_F(ElfTest, write_code_data) { @@ -67,5 +67,5 @@ TEST_F(ElfTest, write_code_data) { {1, 0, 0, 0, 0, 0, 0, 0}); ASSERT_TRUE(fs::exists(TempFilename())); - ASSERT_GT(fs::file_size(TempFilename()), 0); + ASSERT_GT(fs::file_size(TempFilename()), size_t(0)); } diff --git a/tests/test-grammer.cpp b/tests/test-grammer.cpp index 6af6992..06b674c 100644 --- a/tests/test-grammer.cpp +++ b/tests/test-grammer.cpp @@ -45,21 +45,21 @@ TEST_F(GrammerTest, minimumSymbolsNeeded) { Gram::Compiler compiler(bnf, "translation-unit"); - EXPECT_EQ(minimumSymbolsNeeded(compiler, std::vector{}), 0); - EXPECT_EQ(minimumSymbolsNeeded(compiler, "translation-unit"), 0); - 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"), 2); - EXPECT_EQ(minimumSymbolsNeeded(compiler, "simple-declaration"), 2); - EXPECT_EQ(minimumSymbolsNeeded(compiler, "asm-declaration"), 5); - EXPECT_EQ(minimumSymbolsNeeded(compiler, "namespace-alias-definition"), 5); - EXPECT_EQ(minimumSymbolsNeeded(compiler, "using-declaration"), 4); - 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"), 5); - EXPECT_EQ(minimumSymbolsNeeded(compiler, "opaque-enum-declaration"), 3); - EXPECT_EQ(minimumSymbolsNeeded(compiler, "function-definition"), 3); + EXPECT_EQ(minimumSymbolsNeeded(compiler, std::vector{}), size_t(0)); + EXPECT_EQ(minimumSymbolsNeeded(compiler, "translation-unit"), 0u); + EXPECT_EQ(minimumSymbolsNeeded(compiler, "logical-or-expression"), 1u); + EXPECT_EQ(minimumSymbolsNeeded(compiler, "assignment-expression"), 1u); + EXPECT_EQ(minimumSymbolsNeeded(compiler, "declaration"), 1u); + EXPECT_EQ(minimumSymbolsNeeded(compiler, "block-declaration"), 2u); + EXPECT_EQ(minimumSymbolsNeeded(compiler, "simple-declaration"), 2u); + EXPECT_EQ(minimumSymbolsNeeded(compiler, "asm-declaration"), 5u); + EXPECT_EQ(minimumSymbolsNeeded(compiler, "namespace-alias-definition"), 5u); + EXPECT_EQ(minimumSymbolsNeeded(compiler, "using-declaration"), 4u); + EXPECT_EQ(minimumSymbolsNeeded(compiler, "using-enum-declaration"), 4u); + EXPECT_EQ(minimumSymbolsNeeded(compiler, "using-directive"), 4u); + EXPECT_EQ(minimumSymbolsNeeded(compiler, "static_assert-declaration"), 5u); + EXPECT_EQ(minimumSymbolsNeeded(compiler, "alias-declaration"), 5u); + EXPECT_EQ(minimumSymbolsNeeded(compiler, "opaque-enum-declaration"), 3u); + EXPECT_EQ(minimumSymbolsNeeded(compiler, "function-definition"), 3u); } diff --git a/tests/test-lexer.cpp b/tests/test-lexer.cpp index 23983f1..02bce69 100644 --- a/tests/test-lexer.cpp +++ b/tests/test-lexer.cpp @@ -35,5 +35,5 @@ TEST_F(LexerTest, Lex) { std::vector tokens{lexer.Lex("int main() { return 1; }")}; - ASSERT_EQ(tokens.size(), 9); + ASSERT_EQ(tokens.size(), size_t(9)); } -- cgit v1.2.3