[Glacier] Add a basic unit testing framework.
This commit is contained in:
parent
83b0d9ab61
commit
09d902dfb5
|
@ -1,4 +1,5 @@
|
||||||
builddbg/
|
builddbg/
|
||||||
|
test-bin/
|
||||||
__pycache__/
|
__pycache__/
|
||||||
compile_commands.json
|
compile_commands.json
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,8 @@ set(CMAKE_TRY_COMPILE_TARGET_TYPE "STATIC_LIBRARY")
|
||||||
|
|
||||||
project(AcadiaOS VERSION 0.0.1 LANGUAGES CXX ASM-ATT)
|
project(AcadiaOS VERSION 0.0.1 LANGUAGES CXX ASM-ATT)
|
||||||
|
|
||||||
|
include(CTest)
|
||||||
|
|
||||||
set(CMAKE_CXX_STANDARD 20)
|
set(CMAKE_CXX_STANDARD 20)
|
||||||
set(CMAKE_CXX_STANDARD_REQUIRED True)
|
set(CMAKE_CXX_STANDARD_REQUIRED True)
|
||||||
set(CMAKE_EXPORT_COMPILE_COMMANDS True)
|
set(CMAKE_EXPORT_COMPILE_COMMANDS True)
|
||||||
|
|
|
@ -29,3 +29,7 @@ target_include_directories(glacier_kernel
|
||||||
|
|
||||||
set_target_properties(glacier_kernel PROPERTIES
|
set_target_properties(glacier_kernel PROPERTIES
|
||||||
COMPILE_FLAGS "${CMAKE_CXX_FLAGS} ${BASE_COMPILE_FLAGS} -mcmodel=kernel -mgeneral-regs-only")
|
COMPILE_FLAGS "${CMAKE_CXX_FLAGS} ${BASE_COMPILE_FLAGS} -mcmodel=kernel -mgeneral-regs-only")
|
||||||
|
|
||||||
|
if (enable_testing)
|
||||||
|
add_subdirectory(test)
|
||||||
|
endif()
|
||||||
|
|
|
@ -0,0 +1,8 @@
|
||||||
|
find_package(Catch2 3 REQUIRED)
|
||||||
|
|
||||||
|
add_subdirectory(container)
|
||||||
|
|
||||||
|
add_custom_target(build_test)
|
||||||
|
add_dependencies(build_test
|
||||||
|
glc_vec_test)
|
||||||
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
add_executable(glc_vec_test vector.cpp)
|
||||||
|
target_link_libraries(glc_vec_test glacier Catch2::Catch2WithMain)
|
||||||
|
target_include_directories(glc_vec_test PRIVATE "../..")
|
||||||
|
add_test(NAME glc_vec_test COMMAND $<TARGET_FILE:glc_vec_test>)
|
|
@ -0,0 +1,10 @@
|
||||||
|
#include "container/vector.h"
|
||||||
|
|
||||||
|
#include <catch2/catch_test_macros.hpp>
|
||||||
|
|
||||||
|
using namespace glcr;
|
||||||
|
|
||||||
|
TEST_CASE("Build Vector", "[vector]") {
|
||||||
|
Vector<uint64_t> v;
|
||||||
|
REQUIRE(v.size() == 0);
|
||||||
|
}
|
|
@ -0,0 +1,14 @@
|
||||||
|
#! /bin/bash
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||||
|
|
||||||
|
pushd "$DIR/.."
|
||||||
|
cmake -B test-bin/ -G Ninja -D enable_testing=on
|
||||||
|
pushd test-bin/
|
||||||
|
ninja build_test
|
||||||
|
ctest --output-on-failure
|
||||||
|
popd
|
||||||
|
popd
|
||||||
|
|
Loading…
Reference in New Issue