GCC Code Coverage Report


Directory: ./
File: Fw/Test/UnitTestAssert.cpp
Date: 2026-09-23 21:11:01
Exec Total Coverage
Lines: 44 47 93.6%
Functions: 6 7 85.7%
Branches: 5 8 62.5%

Line Branch Exec Source
1 /*
2 * UnitTestAssert.cpp
3 *
4 * Created on: Feb 8, 2016
5 * Author: tcanham
6 * Revised July 2020
7 * Author: bocchino
8 */
9
10 #include <Fw/Test/UnitTestAssert.hpp>
11 #include <cstdio>
12 #include <cstring>
13
14 namespace Test {
15
16 #if FW_ASSERT_LEVEL == FW_FILEID_ASSERT
17 const UnitTestAssert::File UnitTestAssert::fileInit = 0;
18 #else
19 const UnitTestAssert::File UnitTestAssert::fileInit = "";
20 #endif
21
22 1 UnitTestAssert::UnitTestAssert()
23
1/1
✓ Branch 3 taken 1 times.
1 : m_file(fileInit),
24 1 m_lineNo(0),
25 1 m_numArgs(0),
26 1 m_arg1(0),
27 1 m_arg2(0),
28 1 m_arg3(0),
29 1 m_arg4(0),
30 1 m_arg5(0),
31 1 m_arg6(0),
32 2 m_assertFailed(false) {
33 // register this hook
34
1/1
✓ Branch 5 taken 1 times.
1 Fw::AssertHook::registerHook();
35 1 }
36
37 4 UnitTestAssert::~UnitTestAssert() {
38 // deregister the hook
39 2 Fw::AssertHook::deregisterHook();
40 2 }
41
42 1 void UnitTestAssert::doAssert() {
43 1 this->m_assertFailed = true;
44 #if FW_ASSERT_LEVEL == FW_FILEID_ASSERT
45 (void)fprintf(stderr, "Assert: 0x%" PRIx32 ":%" PRI_FwSizeType "\n", this->m_file, this->m_lineNo);
46 #else
47
2/4
✗ Branch 10 not taken.
✓ Branch 11 taken 1 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 1 times.
1 (void)fprintf(stderr, "Assert: %s:%" PRI_FwSizeType "\n", this->m_file.toChar(), this->m_lineNo);
48 #endif
49 1 }
50
51 1 void UnitTestAssert::reportAssert(FILE_NAME_ARG file,
52 FwSizeType lineNo,
53 FwSizeType numArgs,
54 FwAssertArgType arg1,
55 FwAssertArgType arg2,
56 FwAssertArgType arg3,
57 FwAssertArgType arg4,
58 FwAssertArgType arg5,
59 FwAssertArgType arg6) {
60 #if FW_ASSERT_LEVEL == FW_FILEID_ASSERT
61 this->m_file = file;
62 #else
63 1 this->m_file = reinterpret_cast<const char*>(file);
64 #endif
65 1 this->m_lineNo = lineNo;
66 1 this->m_numArgs = numArgs;
67 1 this->m_arg1 = arg1;
68 1 this->m_arg2 = arg2;
69 1 this->m_arg3 = arg3;
70 1 this->m_arg4 = arg4;
71 1 this->m_arg5 = arg5;
72 1 this->m_arg6 = arg6;
73 1 }
74
75 1 void UnitTestAssert::retrieveAssert(File& file,
76 FwSizeType& lineNo,
77 FwSizeType& numArgs,
78 FwAssertArgType& arg1,
79 FwAssertArgType& arg2,
80 FwAssertArgType& arg3,
81 FwAssertArgType& arg4,
82 FwAssertArgType& arg5,
83 FwAssertArgType& arg6) const {
84 1 file = this->m_file;
85 1 lineNo = this->m_lineNo;
86 1 numArgs = this->m_numArgs;
87 1 arg1 = this->m_arg1;
88 1 arg2 = this->m_arg2;
89 1 arg3 = this->m_arg3;
90 1 arg4 = this->m_arg4;
91 1 arg5 = this->m_arg5;
92 1 arg6 = this->m_arg6;
93 1 }
94
95 1 bool UnitTestAssert::assertFailed() const {
96
1/2
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
1 return this->m_assertFailed;
97 }
98
99 ✗ void UnitTestAssert::clearAssertFailure() {
100 ✗ this->m_assertFailed = false;
101 ✗ }
102
103 } /* namespace Test */
104