-
Notifications
You must be signed in to change notification settings - Fork 20
Coding Guidelines
We try to follow Google C++ Coding style.
Not all the code is compliant at this time. Feel free to fix anything that is not compliant to make it compliant!
New code should always be compliant.
Located in src/test, they are written with Catch.hpp and are intended to be run on the developer desktop. Do make test
to run them.
Tests run automatically on every pull request and new commit so that we can detect if we break something.
sktool is a little C++ program, to run on your computer. It uses KBox signalk code to read NMEA or NMEA2000 and convert it to signalk. With this tool it's very easy to check that conversions to signalk are working well.
There is a script src/sktool/sktool-test.py
that can automatically run conversion and compare the output to what we expect to receive (see src/sktool/tests
for the tests).
This script runs automatically on every pull request and new commit so that we can detect if we break something.
For example, Should we accept angles outside of -PI to 2PI range?
Designing for robustness is a great principle but it may lead to bugs that are hard to detect and reproduce. In KBox we should strictly validate inputs and reject data that does not look valid.
If we find a buggy device on the market and decide we want to be compatible with it, we should add some logic to deal with the values sent by this device only after adding tests. The tests and the logic should clearly explain why we have to accept values that do not seem valid.
See pull request #84 for the origin of this discussion.