| Unit Test Source Language | C | C++ |\r
| Register Test Suite | YES | Auto |\r
| Register Test Case | YES | Auto |\r
-| Death/Expected Assert Tests | YES | YES |\r
+| Expected Assert Tests | YES | YES |\r
| Setup/Teardown Hooks | YES | YES |\r
| Value-Parameterized Tests | NO | YES |\r
| Typed Tests | NO | YES |\r
\r
**/\r
\r
-#include <gtest/gtest.h>\r
+#include <Library/GoogleTestLib.h>\r
extern "C" {\r
#include <Uefi.h>\r
#include <Library/BaseLib.h>\r
}\r
\r
/**\r
- Sample unit test using the ASSERT_DEATH() macro to test expected ASSERT()s.\r
+ Sample unit test using the EXPECT_ANY_THROW() macro to test expected ASSERT()s.\r
**/\r
TEST_P (MacroTestsAssertsEnabledDisabled, MacroExpectAssertFailure) {\r
//\r
//\r
// This test passes because it directly triggers an ASSERT().\r
//\r
- ASSERT_DEATH (ASSERT (FALSE), "");\r
+ EXPECT_ANY_THROW (ASSERT (FALSE));\r
\r
//\r
// This test passes because DecimalToBcd() generates an ASSERT() if the\r
// value passed in is >= 100. The expected ASSERT() is caught by the unit\r
- // test framework and ASSERT_DEATH() returns without an error.\r
+ // test framework and EXPECT_ANY_THROW() returns without an error.\r
//\r
- ASSERT_DEATH (DecimalToBcd8 (101), "");\r
+ EXPECT_ANY_THROW (DecimalToBcd8 (101));\r
+\r
+ //\r
+ // This test passes because DecimalToBcd() generates an ASSERT() if the\r
+ // value passed in is >= 100. The expected ASSERT() is caught by the unit\r
+ // test framework and throws the C++ exception of type std::runtime_error.\r
+ // EXPECT_THROW() returns without an error.\r
+ //\r
+ EXPECT_THROW (DecimalToBcd8 (101), std::runtime_error);\r
+\r
+ //\r
+ // This test passes because DecimalToBcd() generates an ASSERT() if the\r
+ // value passed in is >= 100. The expected ASSERT() is caught by the unit\r
+ // test framework and throws the C++ exception of type std::runtime_error with\r
+ // a message that includes the filename, linenumber, and the expression that\r
+ // triggered the ASSERT().\r
+ //\r
+ // EXPECT_THROW_MESSAGE() calls DecimalToBcd() expecting DecimalToBds() to\r
+ // throw a C++ exception of type std::runtime_error with a message that\r
+ // includes the expression of "Value < 100" that triggered the ASSERT().\r
+ //\r
+ EXPECT_THROW_MESSAGE (DecimalToBcd8 (101), "Value < 100");\r
}\r
\r
INSTANTIATE_TEST_SUITE_P (\r
// Example of logging.\r
//\r
SCOPED_TRACE ("SCOPED_TRACE message\n");\r
+\r
+ //\r
+ // Always pass\r
+ //\r
+ ASSERT_TRUE (TRUE);\r
}\r
\r
int\r