2 Unit Test Debug Assert Library
4 Copyright (c) 2020, Intel Corporation. All rights reserved.<BR>
5 SPDX-License-Identifier: BSD-2-Clause-Patent
10 #include <Library/BaseLib.h>
11 #include <Library/UnitTestLib.h>
14 /// Point to jump buffer used with SetJump()/LongJump() to test if a function
15 /// under test generates an expected ASSERT() condition.
17 BASE_LIBRARY_JUMP_BUFFER
*gUnitTestExpectAssertFailureJumpBuffer
= NULL
;
20 Unit test library replacement for DebugAssert() in DebugLib.
22 If FileName is NULL, then a <FileName> string of "(NULL) Filename" is printed.
23 If Description is NULL, then a <Description> string of "(NULL) Description" is printed.
25 @param FileName The pointer to the name of the source file that generated the assert condition.
26 @param LineNumber The line number in the source file that generated the assert condition
27 @param Description The pointer to the description of the assert condition.
33 IN CONST CHAR8
*FileName
,
35 IN CONST CHAR8
*Description
40 if (gUnitTestExpectAssertFailureJumpBuffer
!= NULL
) {
41 UT_LOG_INFO ("Detected expected ASSERT: %a(%d): %a\n", FileName
, LineNumber
, Description
);
42 LongJump (gUnitTestExpectAssertFailureJumpBuffer
, 1);
44 AsciiStrCpyS (Message
, sizeof (Message
), "Detected unexpected ASSERT(");
45 AsciiStrCatS (Message
, sizeof (Message
), Description
);
46 AsciiStrCatS (Message
, sizeof (Message
), ")");
47 UnitTestAssertTrue (FALSE
, "", LineNumber
, FileName
, Message
);