blob: 15e9aafa3bcdb67f5bc4e3987e222a00d3fc0915 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
// Copyright (c) 2026 Progmasoft.
// SPDX-License-Identifier: LGPL-3.0-or-later
// A test binary built with coverage instrumentation, for the integration
// tests of `--coverage`: each test reaches lines the other does not. The
// markers at the ends of lines let the tests find those lines.
#include <Progmasoft/Catch3/TestMacros.hpp>
namespace
{
int
AddOne(int value)
{
return value + 1; // coverage: add-one
}
int
SubtractOne(int value)
{
return value - 1; // coverage: subtract-one
}
int
NonNegative(int value)
{
if (value < 0) // coverage: branch
{
return 0;
}
return value;
}
} // namespace
TEST_CASE("Adds one", "[coverage]")
{
CHECK(AddOne(1) == 2);
CHECK(NonNegative(AddOne(1)) == 2);
}
TEST_CASE("Subtracts one", "[coverage]")
{
CHECK(SubtractOne(1) == 0);
}
|