set up Catch2 for testing
Looks like there isn't really a way around C++ smh
This commit is contained in:
parent
06d538bc4a
commit
b8471c6d76
4 changed files with 59 additions and 5 deletions
|
@ -1,14 +1,13 @@
|
||||||
# See the end of this file for copyright and license terms.
|
# See the end of this file for copyright and license terms.
|
||||||
|
|
||||||
cmake_minimum_required(VERSION 3.0.0)
|
cmake_minimum_required(VERSION 3.14.0)
|
||||||
project(neo VERSION 0.1.0 LANGUAGES C ASM)
|
project(neo VERSION 0.1.0 LANGUAGES C)
|
||||||
set(CMAKE_C_STANDARD 11)
|
set(CMAKE_C_STANDARD 11)
|
||||||
|
set(CMAKE_C_EXTENSIONS ON)
|
||||||
|
|
||||||
if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
|
if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
|
||||||
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
|
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
|
||||||
option(DEBUG "Enable debug features" ON)
|
option(DEBUG "Enable debug features" ON)
|
||||||
include(CTest)
|
|
||||||
enable_testing()
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
find_package(Git QUIET)
|
find_package(Git QUIET)
|
||||||
|
@ -29,6 +28,12 @@ add_subdirectory(src)
|
||||||
|
|
||||||
add_subdirectory(demo)
|
add_subdirectory(demo)
|
||||||
|
|
||||||
|
option(BUILD_TESTING "Build tests" ON)
|
||||||
|
if((CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME OR NEO_BUILD_TESTING) AND BUILD_TESTING)
|
||||||
|
enable_testing()
|
||||||
|
add_subdirectory(test)
|
||||||
|
endif()
|
||||||
|
|
||||||
set(CPACK_PROJECT_NAME ${PROJECT_NAME})
|
set(CPACK_PROJECT_NAME ${PROJECT_NAME})
|
||||||
set(CPACK_PROJECT_VERSION ${PROJECT_VERSION})
|
set(CPACK_PROJECT_VERSION ${PROJECT_VERSION})
|
||||||
include(CPack)
|
include(CPack)
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include "neo/_toolchain.h"
|
||||||
#include "neo/_types.h"
|
#include "neo/_types.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -21,7 +22,7 @@ extern "C" {
|
||||||
* the values to insert which will become the error message.
|
* the values to insert which will become the error message.
|
||||||
*/
|
*/
|
||||||
__attribute__(( __format__(printf, 3, 4) ))
|
__attribute__(( __format__(printf, 3, 4) ))
|
||||||
void yeet(error *err, u32 number, const char *restrict fmt, ...);
|
void yeet(error *err, u32 number, const char *__restrict fmt, ...);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Indicate an operation has completed successfully.
|
* Indicate an operation has completed successfully.
|
||||||
|
|
31
test/CMakeLists.txt
Normal file
31
test/CMakeLists.txt
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
# See the end of this file for copyright and license terms.
|
||||||
|
|
||||||
|
enable_language(CXX)
|
||||||
|
set(CMAKE_CXX_STANDARD 17)
|
||||||
|
|
||||||
|
include(CTest)
|
||||||
|
include(FetchContent)
|
||||||
|
FetchContent_Declare(
|
||||||
|
Catch2
|
||||||
|
GIT_REPOSITORY https://github.com/catchorg/Catch2.git
|
||||||
|
GIT_TAG v2.13.6
|
||||||
|
)
|
||||||
|
FetchContent_MakeAvailable(Catch2)
|
||||||
|
|
||||||
|
add_executable(neo_test neo_test.cpp)
|
||||||
|
|
||||||
|
target_compile_features(neo_test PRIVATE cxx_std_17)
|
||||||
|
target_link_libraries(neo_test PRIVATE neo Catch2::Catch2)
|
||||||
|
|
||||||
|
add_test(NAME neo COMMAND neo_test)
|
||||||
|
|
||||||
|
# This file is part of libneo.
|
||||||
|
# Copyright (c) 2021 Fefie <owo@fef.moe>.
|
||||||
|
#
|
||||||
|
# libneo is non-violent software: you may only use, redistribute,
|
||||||
|
# and/or modify it under the terms of the CNPLv6+ as found in
|
||||||
|
# the LICENSE file in the source code root directory or at
|
||||||
|
# <https://git.pixie.town/thufie/CNPL>.
|
||||||
|
#
|
||||||
|
# libneo comes with ABSOLUTELY NO WARRANTY, to the extent
|
||||||
|
# permitted by applicable law. See the CNPLv6+ for details.
|
17
test/neo_test.cpp
Normal file
17
test/neo_test.cpp
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
/** See the end of this file for copyright and license terms. */
|
||||||
|
|
||||||
|
#define CATCH_CONFIG_MAIN
|
||||||
|
#include <catch2/catch.hpp>
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of libneo.
|
||||||
|
* Copyright (c) 2021 Fefie <owo@fef.moe>.
|
||||||
|
*
|
||||||
|
* libneo is non-violent software: you may only use, redistribute,
|
||||||
|
* and/or modify it under the terms of the CNPLv6+ as found in
|
||||||
|
* the LICENSE file in the source code root directory or at
|
||||||
|
* <https://git.pixie.town/thufie/CNPL>.
|
||||||
|
*
|
||||||
|
* libneo comes with ABSOLUTELY NO WARRANTY, to the extent
|
||||||
|
* permitted by applicable law. See the CNPLv6+ for details.
|
||||||
|
*/
|
Loading…
Reference in a new issue