Skip to content
Thomas Sarlandie edited this page Dec 1, 2017 · 1 revision

Code Style

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.

Testing

Unit tests

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 test

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.

Robustness and Postel's Law

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.