--- tags: - daily date: 2023-10-26 --- ## Tasks - [ ] #todo/b finish file format implementation (v0.2, unit tests) - [ ] #todo/b Add automated unit tests in the gitlab - [ ] #todo/b use the fileformat in the 3d map implementation - [ ] #todo/p start exam_generator project. Is this a software that can actually make profit? - [ ] #todo/p mario games auf tutti - [x] Add v0.2 samples to testing #todo/b ⏫ 📅 2023-10-27 ✅ 2023-10-27 - [x] Implement the gitlab CI for the unit tests of the fileformat project #todo/b 🔽 📅 2023-10-27 ✅ 2023-10-27 ## Quick Notes ## Learnings #learning/investing - Compound interest is key to building wealth. The average yearly return of the S&P 500 over the last 30 years was 9.9% (or 7.2% inflation-adjusted). #learning/cpp * how long is `"hi"` as a char array? ;; Length 3. In addition all char arrays in C and C++ contain the null terminator indicating the end of this string: `"h", "i", "\0"` [[GTest Framework|GoogleTest]] is actually a great method to test your code during development. I should always start with google test instead of a dummy main function that executes stuff and immediately shows if its working or not. It is also surprisingly easy to get started with the google test library in C++. You just need to define the following [[CMake|CMakeLists.txt]] in your `test` subfolder: ```cmake # 1. integrate GTest include(FetchContent) FetchContent_Declare( googletest GIT_REPOSITORY https://github.com/google/googletest.git GIT_TAG release-1.11.0 ) FetchContent_MakeAvailable(googletest) add_library(GTest::GTest INTERFACE IMPORTED) target_link_libraries(GTest::GTest INTERFACE gtest_main) # 2. add test executable set(test_exe_name ${library_name}_test) add_executable(${test_exe_name} test_onesec3d_cpp.cpp) target_link_libraries(${test_exe_name} PRIVATE ${library_name} GTest::gtest GTest::gtest_main ) add_test(onesec3d_tests ${test_exe_name}) set_tests_properties(onesec3d_tests PROPERTIES ENVIRONMENT DATADIR=${CMAKE_CURRENT_SOURCE_DIR}/sample_3d_files/ ) ``` Once this is done you can implement your test in the specified executable test file. For example: ```cpp #include TEST(test_onesec3d, test_read_rewrite_equal_hash) { // ... do your testing stuff // execute tests ASSERT_EQ(1, 1); } ``` The `DATADIR` environment variable in `set_test_properties` is a smart way to pass the test folder of the build to the test file in order to use assets such as files etc in your tests. #learning/cpp this seems a good learning resource for cpp: https://matgomes.com/integrate-google-test-into-cmake/