File tree Expand file tree Collapse file tree 3 files changed +37
-10
lines changed
Expand file tree Collapse file tree 3 files changed +37
-10
lines changed Original file line number Diff line number Diff line change 11cmake_minimum_required (VERSION 3.14)
2-
3- set (CMAKE_CXX_STANDARD 11)
4- set (CMAKE_CXX_STANDARD_REQUIRED ON )
5-
62if (NOT DEFINED CPP_SAFE_IO)
73 set (CPP_SAFE_IO "CppSafeIO" CACHE STRING "Name for the CppSafeIO library" )
84endif ()
95
6+ project (CPP_SAFE_IO)
7+
8+ set (CMAKE_CXX_STANDARD 11)
9+ set (CMAKE_CXX_STANDARD_REQUIRED ON )
10+
1011add_subdirectory (src)
12+ add_subdirectory (tests)
Original file line number Diff line number Diff line change 11cmake_minimum_required (VERSION 3.14)
2- project (Tests LANGUAGES CXX )
2+ include (CTest )
33
4- add_executable (Tests tests.cpp)
4+ add_executable (CppSafeIO-Tests tests.cpp)
5+ target_link_libraries (CppSafeIO-Tests ${CPP_SAFE_IO} )
56
6- get_filename_component (PARENT_DIR ../ ABSOLUTE )
7- add_subdirectory (${PARENT_DIR} ${CMAKE_CURRENT_SOURCE_DIR} /build /bin)
8-
9- target_link_libraries (Tests ${CPP_SAFE_IO} )
7+ add_executable (CppSafeIO-AutomatedTests automated-tests.cpp)
8+ target_link_libraries (CppSafeIO-AutomatedTests ${CPP_SAFE_IO} )
9+ add_test (NAME CppSafeIO-Testing COMMAND CppSafeIO-AutomatedTests)
Original file line number Diff line number Diff line change 1+ #include " cppsafeio.h"
2+ #include < iostream>
3+ #include < exception>
4+
5+ int main ()
6+ {
7+ try
8+ {
9+ if (false )
10+ CppSafeIO::clearConsole (); // not executing so that the building and testing log doesn't get erased in case of running ctest -V
11+
12+ std::cout << " Automated tests passed.\n "
13+ << " You can include the cppsafeio.h file, and use the CppSafeIO namespace.\n "
14+ << " You can try to run CppSafeIO-Tests executable to test the input functions.\n " ;
15+ }
16+ catch (const std::exception& exception)
17+ {
18+ std::cerr << " CppSafeIO library's tests failed\n "
19+ << " Error: " << exception.what () << ' \n ' ;
20+
21+ return 1 ;
22+ }
23+
24+ return 0 ;
25+ }
You can’t perform that action at this time.
0 commit comments