Compare commits
2 Commits
dd312b9ec5
...
4d4115012c
| Author | SHA1 | Date | |
|---|---|---|---|
| 4d4115012c | |||
| 03e0ce53d5 |
@@ -20,7 +20,19 @@ jobs:
|
|||||||
git fetch --depth 1 origin ${{ github.sha }}
|
git fetch --depth 1 origin ${{ github.sha }}
|
||||||
git checkout FETCH_HEAD
|
git checkout FETCH_HEAD
|
||||||
- name: Configure
|
- name: Configure
|
||||||
run: cmake -S . -B build -DCMAKE_BUILD_TYPE=Release
|
run: cmake -S . -B build -DCMAKE_BUILD_TYPE=Debug -DENABLE_COVERAGE=ON
|
||||||
|
|
||||||
- name: Build
|
- name: Build
|
||||||
run: cmake --build build --config Release -j "$(nproc)"
|
run: cmake --build build --config Debug -j "$(nproc)"
|
||||||
|
|
||||||
|
- name: Test
|
||||||
|
run: |
|
||||||
|
cd build
|
||||||
|
ctest --output-on-failure
|
||||||
|
|
||||||
|
- name: Coverage
|
||||||
|
run: |
|
||||||
|
lcov --capture --directory build --output-file build/coverage.info
|
||||||
|
lcov --remove build/coverage.info "/usr/*" "*/build/*" "*/_deps/*" --output-file build/coverage.info
|
||||||
|
lcov --summary build/coverage.info
|
||||||
|
genhtml build/coverage.info --output-directory build/coverage-html
|
||||||
|
|||||||
@@ -1,6 +1,11 @@
|
|||||||
cmake_minimum_required(VERSION 4.2.0)
|
cmake_minimum_required(VERSION 4.2.0)
|
||||||
project(bar)
|
project(bar)
|
||||||
|
|
||||||
|
include(CTest)
|
||||||
|
enable_testing()
|
||||||
|
|
||||||
|
option(ENABLE_COVERAGE "Enable coverage flags" OFF)
|
||||||
|
|
||||||
set(CMAKE_CXX_STANDARD 23)
|
set(CMAKE_CXX_STANDARD 23)
|
||||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||||
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
||||||
@@ -8,8 +13,8 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
|||||||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O2 -DNDEBUG -Wall -Wextra -Wpedantic -Werror")
|
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O2 -DNDEBUG -Wall -Wextra -Wpedantic -Werror")
|
||||||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DDEBUG -Wall -Wextra -Wpedantic")
|
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DDEBUG -Wall -Wextra -Wpedantic")
|
||||||
|
|
||||||
set(CMAKE_C_COMPILER "clang")
|
set(CMAKE_C_COMPILER "/usr/bin/clang")
|
||||||
set(CMAKE_CXX_COMPILER "clang++")
|
set(CMAKE_CXX_COMPILER "/usr/bin/clang++")
|
||||||
|
|
||||||
find_package(PkgConfig REQUIRED)
|
find_package(PkgConfig REQUIRED)
|
||||||
|
|
||||||
@@ -59,6 +64,25 @@ add_executable(bar main.cpp)
|
|||||||
|
|
||||||
target_link_libraries(bar bar_lib ${GTKMM_LIBRARIES} ${LAYERSHELL_LIBRARIES} ${WEBKIT_LIBRARIES} ${CURL_LIBRARIES} nlohmann_json::nlohmann_json)
|
target_link_libraries(bar bar_lib ${GTKMM_LIBRARIES} ${LAYERSHELL_LIBRARIES} ${WEBKIT_LIBRARIES} ${CURL_LIBRARIES} nlohmann_json::nlohmann_json)
|
||||||
|
|
||||||
|
# ---- Tests (Catch2) ----
|
||||||
|
find_package(Catch2 3 REQUIRED)
|
||||||
|
|
||||||
|
add_executable(bar_tests
|
||||||
|
tests/string_helper_tests.cpp
|
||||||
|
)
|
||||||
|
target_include_directories(bar_tests PRIVATE
|
||||||
|
include
|
||||||
|
)
|
||||||
|
target_link_libraries(bar_tests PRIVATE Catch2::Catch2WithMain)
|
||||||
|
|
||||||
|
if(ENABLE_COVERAGE)
|
||||||
|
target_compile_options(bar_tests PRIVATE -O0 -g --coverage)
|
||||||
|
target_link_options(bar_tests PRIVATE --coverage)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
include(Catch)
|
||||||
|
catch_discover_tests(bar_tests)
|
||||||
|
|
||||||
# Copy all CSS files in resources/ into build and user config directories
|
# Copy all CSS files in resources/ into build and user config directories
|
||||||
file(GLOB RES_CSS_FILES CONFIGURE_DEPENDS
|
file(GLOB RES_CSS_FILES CONFIGURE_DEPENDS
|
||||||
"${CMAKE_CURRENT_SOURCE_DIR}/resources/*.css"
|
"${CMAKE_CURRENT_SOURCE_DIR}/resources/*.css"
|
||||||
|
|||||||
24
tests/string_helper_tests.cpp
Normal file
24
tests/string_helper_tests.cpp
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
#include <catch2/catch_test_macros.hpp>
|
||||||
|
|
||||||
|
#include "helpers/string.hpp"
|
||||||
|
|
||||||
|
TEST_CASE("StringHelper::split by char", "[string]") {
|
||||||
|
const auto tokens = StringHelper::split("a,b,,c", ',');
|
||||||
|
REQUIRE(tokens.size() == 3);
|
||||||
|
REQUIRE(tokens[0] == "a");
|
||||||
|
REQUIRE(tokens[1] == "b");
|
||||||
|
REQUIRE(tokens[2] == "c");
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_CASE("StringHelper::split by string", "[string]") {
|
||||||
|
const auto tokens = StringHelper::split("one::two::three", "::");
|
||||||
|
REQUIRE(tokens.size() == 3);
|
||||||
|
REQUIRE(tokens[0] == "one");
|
||||||
|
REQUIRE(tokens[1] == "two");
|
||||||
|
REQUIRE(tokens[2] == "three");
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_CASE("StringHelper::trimToSize", "[string]") {
|
||||||
|
REQUIRE(StringHelper::trimToSize("hello", 10) == "hello");
|
||||||
|
REQUIRE(StringHelper::trimToSize("hello world", 5) == "hello...");
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user