Skip to content

Commit

Permalink
[tests] enable tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tomwillow committed Dec 23, 2024
1 parent 6a28ab8 commit 11d8fb7
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 19 deletions.
4 changes: 3 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ add_compile_options("$<$<CXX_COMPILER_ID:MSVC>:/utf-8>")
add_compile_options(-WX)

if(MSVC)
add_compile_options(/MP)
add_compile_options(/MP)

set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /MT")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MT")
Expand All @@ -27,4 +27,6 @@ endif()
# =============================================
add_subdirectory(third_party)
add_subdirectory(src)

enable_testing()
add_subdirectory(tests)
35 changes: 24 additions & 11 deletions CMakePresets.json
Original file line number Diff line number Diff line change
@@ -1,19 +1,32 @@
{
"version": 4,
"configurePresets": [{
"version": 8,
"configurePresets": [
{
"name": "default",
"binaryDir": "${sourceDir}/build",
"cacheVariables": {
"VCPKG_TARGET_TRIPLET": "x64-windows-static",
"CMAKE_TOOLCHAIN_FILE": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake"
}
}],
"buildPresets": [{
"name": "default",
"configurePreset": "default"
}],
"testPresets": [{
"name": "default",
"configurePreset": "default"
}]
}
],
"buildPresets": [
{
"name": "default",
"configurePreset": "default"
}
],
"testPresets": [
{
"name": "default",
"configurePreset": "default",
"output": {
"outputOnFailure": true
},
"execution": {
"noTestsAction": "error",
"stopOnFailure": true
}
}
]
}
2 changes: 0 additions & 2 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
find_package(GTest CONFIG REQUIRED)

enable_testing()

# === CoreUnitTest ===
file(GLOB TEST_CODE
*.h
Expand Down
4 changes: 1 addition & 3 deletions tests/Core_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,7 @@ TEST(Core, DetectEncodingMulti) {
auto charsetCode = DetectEncoding(core.GetUCharDet().get(), buf.get(), len);

if (charsetCode == expectedEncoding) {
SetConsoleColor(ConsoleColor::GREEN);
} else {
SetConsoleColor(ConsoleColor::RED);
continue;
}
std::cout << std::string(20, '=') << std::endl;
std::cout << "file: " << filename << std::endl;
Expand Down
2 changes: 0 additions & 2 deletions tests/uchardet_samples_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ TEST(Core, uchardet_sample_test) {
continue;
}

SetConsoleColor(ConsoleColor::RED);
std::cout << std::string(20, '=') << std::endl;
std::cout << "file: " << filename << std::endl;
std::cout << "detect: " << to_utf8(ToViewCharsetName(charsetCode)) << std::endl;
Expand All @@ -53,7 +52,6 @@ TEST(Core, uchardet_sample_test) {

// EXPECT_EQ(charsetCode, expectedEncoding); // not pass now
}
SetConsoleColor();

double rate = static_cast<double>(passed) / static_cast<double>(table.size());
std::cout << "PASSED: " << rate * 100.0 << "% \n";
Expand Down

0 comments on commit 11d8fb7

Please sign in to comment.