- Never create build directories - They already exist in all sample projects
- Never build from
core/orplugins/directories - Always usesamples/ - Never use
mkdirfor build directories - Justcdinto the existing build directory
- Code style should follow the style given in
.clang-format. - Standard C++ library include headers are listed in the file
core/include/global.h. Check these includes to make sure you do not add unnecessary includes. - Prefer descriptive variable names that 'self-document' the code.
- Prefer clearer code over clever optimized code that provides only marginal performance improvements.
- When implementing new function/method definitions, be aware of the organization of the source file. Don't just automatically add them at the end of the file, but keep them grouped with similar definitions if possible.
- The code is organized into a core library and plugins. The core library contains the main functionality, while plugins provide additional features.
- The folder
samplescontains many examples that illustrate how to run the code. Each of these examples contains aCMakeLists.txtfile that can be used to build the example. This file referencescore/CMake_project.cmake, which is the highest level CMake file for the core library, and also links any plugin CMake files. - CMakeLists.txt files inside
coreandpluginsdo not build by themselves. You need to build a project that usescore/CMake_project.cmaketo build the core library and any plugins.
- Core tests are located in
core/tests/with 5 main test header files:Test_utilities.h: Vector types, colors, dates/times, coordinate systemsTest_functions.h: Global helper functions and math utilitiesTest_XML.h: XML parsing functionsTest_context.h: Context class methodsTest_data.h: Context data management (primitive, object, global data)
- Plugin tests are in
plugins/[plugin_name]/tests/selfTest.cpp - Tests use the doctest framework with specific patterns (DOCTEST_TEST_CASE, DOCTEST_CHECK, etc.)
- When adding new functions or classes, always add a test for it in the appropriate test file.
-
Building Tests: Always build from a sample directory, not from core or plugins directly
cd samples/[project_name]/ cd build # The build directory already exists - DO NOT create it with mkdir cmake .. && make
IMPORTANT: Never use
mkdirto create build directories - they already exist in all sample projects -
Running Tests:
- For core tests:
./context_tests(from context_selftest/build/) - For plugin tests:
./{plugin_name}_selftestor./{plugin_name}_tests - If you need to run custom test code from a new .cpp file, add it to the
CMakeLists.txtin the appropriate sample directory and rebuild.
- For core tests:
-
Common Build Issues:
- Always check compilation errors carefully for missing includes or function signature mismatches
- Plugin tests may have different data label expectations than actual implementation (verify against source code)
- Tests failing with "does not exist" errors usually indicate incorrect data labels in tests
- The script
utilities/generate_coverage_report.shcan be used to check test coverage. - The script must be run from the build directory. For example,
cd samples/context_selftest/build && ../../../utilities/generate_coverage_report.sh -t context_tests -r html -l logfile.log. - Prefer HTML output (
-r html) over text output - it provides a clear summary table with color-coded coverage percentages and clickable file navigation incoverage/index.html. - Coverage analysis requires tests to compile and run successfully first
- Coverage improvements should focus on:
- Adding tests for uncovered functions (check function names against test coverage)
- Verifying data manipulation functions use correct parameter types and labels
- Testing edge cases and error conditions
- Ensuring tests are organized with similar functionality and non-redundant
- When plugin tests fail, first check if the test expectations match the actual implementation
- Always verify test expectations against the source code in
plugins/[name]/src/ - Tests should not write any errors messages to std::cerr. Use the struct
capture_cerr(defined incore/include/global.h) to capture any error messages and check them in the test. - Make sure that any functions marked
[[nodiscard]]assign their return value to a variable in the test, otherwise the compiler will issue a warning.
- When adding new functions or classes, always add a docstring to the header file, and consider whether additional documentation is needed (in
doc/*.doxfor the core orplugins/[plugin_name]/doc/*.doxfor plugins). - If changes are made to docstrings or function signatures, build the documentation file
doc/Doxyfileusing doxygen to test it. Some notes on this are given below: - Run
doxygen doc/Doxyfileto generate the documentation from the root directory not thedocdirectory. - Check doxygen output for warnings. It is ok to ignore warnings of the form " warning: Member XXX is not documented."
- The main concern when changing docstrings or function signatures is the potential for breaking \ref references, which produces a warning like: warning: unable to resolve reference to XXX for \ref command". When fixing these, don't just remove the funciton signature or use markdown `` ticks to suppress the warning. It is important to keep the signature in the reference for overloaded functions/methods. Figure out why the function signature is not matching and thus causing Doxygen to treat it as plain text.