File tree Expand file tree Collapse file tree 5 files changed +65
-5
lines changed Expand file tree Collapse file tree 5 files changed +65
-5
lines changed Original file line number Diff line number Diff line change @@ -46,3 +46,4 @@ CMakeUserPresets.json
4646
4747# CMake build output
4848/out
49+ /TestResults
Original file line number Diff line number Diff line change 1- add_executable (cppjson-Test )
1+ add_executable (cppjson-Test )
22
33target_link_libraries (cppjson-Test PRIVATE
44 cppjson::cppjson
@@ -8,8 +8,23 @@ target_sources(cppjson-Test PRIVATE
88 Test .cpp
99)
1010
11- add_test (
12- NAME cppjson- Test
13- COMMAND cppjson- Test
14- WORKING_DIRECTORY " ${CMAKE_CURRENT_SOURCE_DIR} "
11+ set (TEST_SOURCES
12+ TestEmptyObject.cpp
13+ TestPrimitives.cpp
14+ TestNestedObjects.cpp
1515)
16+
17+ if (MSVC )
18+ add_compile_options ("/Zi" )
19+ add_link_options ("/PROFILE" )
20+ endif ()
21+
22+
23+ foreach (TEST_SRC IN LISTS TEST_SOURCES)
24+ message (Adding ${TEST_SRC} )
25+ get_filename_component (TEST_NAME ${TEST_SRC} NAME_WE )
26+ add_executable (${TEST_NAME} tests/${TEST_SRC} )
27+ target_link_libraries (${TEST_NAME} PRIVATE cppjson::cppjson)
28+
29+ add_test (NAME ${TEST_NAME} COMMAND ${TEST_NAME} )
30+ endforeach ()
Original file line number Diff line number Diff line change 1+ #include < cppjson/cppjson.hpp>
2+ #include < print>
3+
4+ int main ()
5+ {
6+ cppjson::Object object{};
7+ if (!object.IsEmpty ())
8+ {
9+ std::println (" TestEmptyObject failed" );
10+ return 1 ;
11+ }
12+ return 0 ;
13+ }
Original file line number Diff line number Diff line change 1+ #include < cppjson/cppjson.hpp>
2+ #include < print>
3+
4+ int main ()
5+ {
6+ cppjson::Object object{};
7+ object[" sub" ][" veryNested" ] = 6.0 ;
8+
9+ if ((double )object[" sub" ][" veryNested" ] != 6.0 )
10+ {
11+ std::println (" TestNestedObjects failed" );
12+ return 1 ;
13+ }
14+ return 0 ;
15+ }
Original file line number Diff line number Diff line change 1+ #include < cppjson/cppjson.hpp>
2+ #include < print>
3+
4+ int main ()
5+ {
6+ cppjson::Object object{};
7+ object[" test1" ] = " Hello World" ;
8+ object[" test2" ] = 123.0 ;
9+
10+ if ((std::string)object[" test1" ] != " Hello World" || (double )object[" test2" ] != 123.0 )
11+ {
12+ std::println (" TestPrimitives failed" );
13+ return 1 ;
14+ }
15+ return 0 ;
16+ }
You can’t perform that action at this time.
0 commit comments