TODO
- Catch (C++ Automated Test Cases in Headers)
- Mettle
- 73 C++ UT frameworks listed on Wikipedia
#define CATCH_CONFIG_MAIN
#include "catch.hpp"
TEST_CASE("A year is not a leap year if it is not divisible by 4", "[leap]") {
REQUIRE( is_leap_year(2015) == false );
}
TEST_CASE("A year is a leap year if it is divisible by 4 but not by 100", "[leap]") {
REQUIRE( is_leap_year(2016) == true );
}
TEST_CASE("A year is not a leap year if it is divisible by 100 but not by 400", "[leap]") {
REQUIRE( is_leap_year(1900) == false );
}
TEST_CASE("A year is a leap year if it is divisible by 400", "[leap]") {
REQUIRE( is_leap_year(2000) == true );
}
TODO Fournir plus d'exemples sur la puissance de Catch
#include <mettle.hpp>
mettle::suite<> basic("Leap Year", [](auto &_) {
_.test("A year is not a leap year if it is not divisible by 4", []() {
mettle::expect(false, is_leap_year(2015));
});
_.test("A year is a leap year if it is divisible by 4 but not by 100", []() {
mettle::expect(true, is_leap_year(2016));
});
_.test("A year is not a leap year if it is divisible by 100 but not by 400", []() {
mettle::expect(false, is_leap_year(1900));
});
_.test("A year is a leap year if it is divisible by 400", []() {
mettle::expect(true, is_leap_year(2000));
})
}
lest errors escape testing
https://github.com/martinmoene/lest
Couverture de données
Les premières implémentations en C++ ont été C++ QuickCheck, puis AutoCheck.
Aujourd'hui, c'est le projet RapidCheck qui est le plus actif et propose le plus de fonctionnalités.
TODO Fournir quelques exemples
TODO Fournir exemples
- Header only C++14 mocking framework
- GitHub
Release | Debug | Coverage | |
---|---|---|---|
assert() |
-D NDEBUG |
-D NDEBUG |
|
Optimisation | -Ofast (or any other) |
-O0 -fno-inline |
-O0 -fno-inline |
- Toujours les symboles de debug =>
-g3 -fno-eliminate-unused-debug-types
(les binaires peuvent être strippés avant livraison au client) - C'est fini les
i386
=>-march=sandybridge
(à adapter selon le contexte)
- MSVC sous Windows (et un autre ?)
- GCC et Clang sous Linux
- GCC, Clang
- Release, Debug, Coverage
- Valgrind ou pas (tester différentes options)
- Source code respects Coding Rules
- No remaining FIXME
- No compiler warnings
- Unit-Tests passed
- Code coverage depending on context
- Valgrind
- CppCheck
- AddressSanitizer using
-fsanitize=*
(clang and gcc) - clang-check
(static code analyzer of control flow graph to detect bug-prone patterns) - clang-tidy
(linter: coding style, readability and fix your C++ code) - No dead code