前言:
一般对于程序员来说,程序的测试非常头疼。似乎大家更愿意实现代码的前期架构,而对后期的测试调试过程颇为头疼。犹如,某些人对做饭情有独钟,却对刷锅刷碗愁眉苦脸。
测试工具:
catch2 、valgrind
catch2的前身是catch,地址在此https://github.com/catchorg/Catch2
/*
Catch2 stands for C++ Automated Test Cases in a Header and is a multi-paradigm test framework for C++.
which also supports Objective-C (and maybe C).
It is primarily distributed as a single header file,
although certain extensions may require additional headers.
*/
valgrind的安装方法简单,ubuntu环境下只需要执行
apt-get install valgrind
代码测试:
/// ....