Remove googletest (#178)

This commit is contained in:
ykiko
2025-08-16 23:09:13 +08:00
committed by GitHub
parent e77f182fcd
commit 08b41f15c2
46 changed files with 4446 additions and 4285 deletions

View File

@@ -3,87 +3,89 @@
namespace clice::testing {
TEST(SourceCode, IgnoreComments) {
/// Test all tokens.
std::size_t count = 0;
suite<"SourceCode"> source_code = [] {
test("IgnoreComments") = [] {
/// Test all tokens.
std::size_t count = 0;
std::vector<clang::tok::TokenKind> kinds = {
clang::tok::raw_identifier,
clang::tok::raw_identifier,
clang::tok::equal,
clang::tok::numeric_constant,
clang::tok::semi,
};
std::vector<clang::tok::TokenKind> kinds = {
clang::tok::raw_identifier,
clang::tok::raw_identifier,
clang::tok::equal,
clang::tok::numeric_constant,
clang::tok::semi,
};
{
/// Test ignore comments.
Lexer lexer("int x = 1; // comment", true);
{
/// Test ignore comments.
Lexer lexer("int x = 1; // comment", true);
while(true) {
Token token = lexer.advance();
if(token.is_eof()) {
break;
while(true) {
Token token = lexer.advance();
if(token.is_eof()) {
break;
}
expect(that % token.kind == kinds[count]);
count += 1;
}
EXPECT_EQ(token.kind, kinds[count]);
count += 1;
expect(that % count == 5);
}
EXPECT_EQ(count, 5);
}
/// Test retain comments.
count = 0;
kinds = {
clang::tok::raw_identifier,
clang::tok::raw_identifier,
clang::tok::equal,
clang::tok::numeric_constant,
clang::tok::semi,
clang::tok::comment,
};
{
/// Test retain comments.
Lexer lexer("int x = 1; // comment", false);
count = 0;
while(true) {
Token token = lexer.advance();
if(token.is_eof()) {
break;
kinds = {
clang::tok::raw_identifier,
clang::tok::raw_identifier,
clang::tok::equal,
clang::tok::numeric_constant,
clang::tok::semi,
clang::tok::comment,
};
{
/// Test retain comments.
Lexer lexer("int x = 1; // comment", false);
while(true) {
Token token = lexer.advance();
if(token.is_eof()) {
break;
}
expect(that % token.kind == kinds[count]);
count += 1;
}
EXPECT_EQ(token.kind, kinds[count]);
count += 1;
expect(that % count == 6);
}
};
EXPECT_EQ(count, 6);
}
}
test("LexInclude") = [] {
/// TODO: test eod
/// test multiple lines macros.
TEST(SourceCode, LexInclude) {
/// TODO: test eod
/// test multiple lines macros.
Lexer lexer(R"(
Lexer lexer(R"(
#include <iostream>
#include "gtest/test.h"
module;
int x = 1;
)",
true,
nullptr,
false);
true,
nullptr,
false);
// while(true) {
// Token token = lexer.advance();
// if(token.is_eof()) {
// break;
// }
//
// println("kind: {}", token.name());
//}
}
// while(true) {
// Token token = lexer.advance();
// if(token.is_eof()) {
// break;
// }
//
// println("kind: {}", token.name());
//}
};
};
} // namespace clice::testing