Validate Swedish personal identity numbers with C++
Use cmake
cmake \
--no-warn-unused-cli \
-DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE \
-DCMAKE_BUILD_TYPE:STRING=Debug \
-DCMAKE_C_COMPILER:FILEPATH=/usr/bin/clang \
-DCMAKE_CXX_COMPILER:FILEPATH=/usr/bin/clang++ \
-DWITH_TEST=1 \
-DWITH_EXAMPLES=1 \
-H$(pwd) \
-B$(pwd)/build
cmake \
--build $(pwd)/build \
--config Debug \
--target all \
-- \
-j 10
- Build the library
- Import
personnummer.hpp
- Link library with your code
g++ -Wall -I/include/path -L/library/path your_program.cpp -lPersonnummer
See examples for code examples.
Tests are written with Catch2. To make the
unittest compile the Catch2
header is bundled in the test
directory.
After building (with WITH_TEST=1
), run the executable unittest
.
./build/test/unittest
Or use the make target in build/Makefile
and run make test
.
Code is (and should continue to be) formatted with clang-format
, the default
settings for VS Code.
$ clang-format -i src/*.{cpp,hpp} test/unittest.cpp