File tree Expand file tree Collapse file tree 10 files changed +50
-9
lines changed Expand file tree Collapse file tree 10 files changed +50
-9
lines changed Original file line number Diff line number Diff line change @@ -22,7 +22,7 @@ InlayHints:
2222
2323Diagnostics :
2424 UnusedIncludes : Strict
25- MissingIncludes : Strict
25+ MissingIncludes : None
2626
2727---
2828
Original file line number Diff line number Diff line change 88 LANGUAGES CXX
99)
1010
11+ if (FEATURE_TESTS)
12+ enable_testing ()
13+ endif ()
14+
1115add_subdirectory (library)
1216add_subdirectory (app)
Original file line number Diff line number Diff line change 108108 "name" : " debug" ,
109109 "hidden" : true ,
110110 "cacheVariables" : {
111- "CMAKE_BUILD_TYPE" : " Debug"
111+ "CMAKE_BUILD_TYPE" : " Debug" ,
112+ "VCPKG_MANIFEST_FEATURES" : " test" ,
113+ "FEATURE_TESTS" : true
112114 }
113115 },
114116 {
Original file line number Diff line number Diff line change 11#include < Core/Lib.hpp>
22
3+ #include < iostream>
4+
35int main ()
46{
57 Lib lib;
6- lib.displayName ();
8+ std::cout << lib.getName ();
79
810 return 0 ;
911}
Original file line number Diff line number Diff line change @@ -15,6 +15,10 @@ add_library(Core STATIC ${LIBRARY_HEADERS} ${LIBRARY_SOURCES})
1515target_include_directories (Core PUBLIC ${PROJECT_SOURCE_DIR} /library/include )
1616target_compile_features (Core PUBLIC cxx_std_17)
1717
18+ if (FEATURE_TESTS)
19+ add_subdirectory (${PROJECT_SOURCE_DIR} /library/test )
20+ endif ()
21+
1822# Group headers and sources for IDE
1923source_group (TREE ${INCROOT} PREFIX "Headers" FILES ${LIBRARY_HEADERS} )
2024source_group (TREE ${SRCROOT} PREFIX "Sources" FILES ${LIBRARY_SOURCES} )
Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ struct Lib
66{
77 Lib ();
88
9- void displayName () const ;
9+ std::string getName () const ;
1010
1111private:
1212 std::string m_name;
Original file line number Diff line number Diff line change 11#include < Core/Lib.hpp>
22
3- #include < iostream>
4-
53Lib::Lib () :
64 m_name { " Library" }
75{
86}
97
10- void Lib::displayName () const
8+ std::string Lib::getName () const
119{
12- std::cout << m_name;
10+ return m_name;
1311}
Original file line number Diff line number Diff line change 1+ include (CTest)
2+
3+ find_package (Catch2 REQUIRED)
4+ include (Catch)
5+
6+ add_executable (CoreTests ${PROJECT_SOURCE_DIR} /library/test /Tests.cpp)
7+
8+ target_link_libraries (CoreTests PRIVATE Core Catch2::Catch2WithMain)
9+ target_compile_features (CoreTests PRIVATE cxx_std_17)
10+ catch_discover_tests(CoreTests)
Original file line number Diff line number Diff line change 1+ #include < Core/Lib.hpp>
2+
3+ #include < catch2/catch_test_macros.hpp>
4+
5+ TEST_CASE (" some_fun" )
6+ {
7+ Lib lib;
8+ REQUIRE (lib.getName () == " Library" );
9+ }
Original file line number Diff line number Diff line change 44 "version-string" : " 0.1.0" ,
55 "dependencies" : [
66
7- ]
7+ ],
8+ "default-features" : [],
9+ "features" : {
10+ "test" : {
11+ "description" : " Dependencies for testing" ,
12+ "dependencies" : [
13+ {
14+ "name" : " catch2" ,
15+ "version>=" : " 3.5.2"
16+ }
17+ ]
18+ }
19+ }
820}
You can’t perform that action at this time.
0 commit comments