Files
dbc/tests
2026-10-06 17:14:50 -04:00
..
2026-10-05 21:41:19 -04:00
2026-10-06 17:04:13 -04:00
2026-10-06 17:14:50 -04:00
2026-10-05 21:41:19 -04:00
2026-10-05 21:41:19 -04:00
2026-10-06 17:14:50 -04:00
2026-10-05 21:41:19 -04:00
2026-10-06 17:14:50 -04:00
2026-10-05 21:41:19 -04:00
2026-10-06 17:14:50 -04:00

QtTest regression tests

Open the repository's root dbc.pro in Qt Creator. It contains core (a static C++17 library) and tests (the dbc_tests QtTest executable). Core is built first; tests link its archive rather than compiling its implementation again. Qt Core and Qt Test development packages are required for tests only.

Build from the repository root with Qt 6 (use qmake for Qt 5):

mkdir build
cd build
qmake6 ../dbc.pro
make -j
make check

Or run ./tests/dbc_tests directly. Both parser and decoder suites run, and the executable returns nonzero when either suite fails. Decoder cases appear as individual QtTest data rows; parser checks are grouped into named test slots. Checks also run in release builds.

To build tests separately against an existing core build:

mkdir /tmp/dbc-tests-build
cd /tmp/dbc-tests-build
qmake6 /absolute/path/to/dbc/tests/tests.pro \
  DBC_CORE_BUILD_DIR=/absolute/path/to/build/core
make
make check

parser_tests.pri and decoder_tests.pri include the test sources. ../core/core.pri supplies the library include path and linkage.

Decoder coverage

Coverage includes Motorola bit numbering within and across bytes, unaligned signals, signed values, scaling, 64-bit extraction, signed/unsigned boundary values (including INT64_MIN, INT64_MAX, and UINT64_MAX), numeric output, invalid lengths, insufficient payloads, and Intel regression cases. Frame validity means the definition was found; insufficient payloads are checked through signal validity.

Parser coverage

Parser tests cover standard and extended CAN IDs, whitespace, payload storage boundaries, missing fields, malformed and overflowing numbers, reserved ID bits, error paths and line numbers, and integration with signals and comments. Signal tests cover complete syntax and numeric validation, scientific notation, finite physical parameters and ordered ranges, spaces and tabs, receiver lists, unsupported multiplexing, and Intel/Motorola declared-payload boundaries. Value-description tests cover full VAL_ syntax, whitespace, escaped quotes, empty text, exact integer boundaries, duplicate keys within and across statements, deferred and normalized frame references, missing targets, error locations, raw lookup with scaling, unknown/invalid values, and both database builders. Temporary DBC fixtures are created in the system temporary directory and removed automatically.

Dispatch tests also verify exact keyword matching, handler construction and reuse, unknown statements, and independent parsing sessions, including recovery after errors.

Tree and optional model tests

tree_node_test.cpp is a standalone C++17 executable without Qt; see the root README for its compiler command. It checks parents, sibling positions, null children, bounds, and unique_ptr transfer.

Enable CONFIG+=dbc_qt in the root qmake invocation to build dbc_qt and dbc_model_tests alongside existing tests. Qt 5.11+ or Qt 6 is required. make check runs all suites. Model tests parse a temporary DBC fixture and use QAbstractItemModelTester, verify navigation across columns, invalid/foreign indexes, metadata and exact VAL_ integers, and persistent-index invalidation when reloading or clearing the tree. No GUI/display server is needed.