From b4e5860fd5f722cc849265f1fa4ea20b4071fa1d Mon Sep 17 00:00:00 2001 From: Michael D Kinney Date: Wed, 18 Jun 2025 17:58:33 -0700 Subject: [PATCH] UnitTestFrameworkPkg/GoogleTestLib: Enhance unit test NULL checks gtest.h uses standard includes that define NULL to __null. This is different that the C++ standard that uses nullptr. Redefine NULL in GoogleTestLib.h to use C++ form of nullptr. This allows NULL to be used in checks and mocks without explicit typecasts. Signed-off-by: Michael D Kinney --- UnitTestFrameworkPkg/Include/Library/GoogleTestLib.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/UnitTestFrameworkPkg/Include/Library/GoogleTestLib.h b/UnitTestFrameworkPkg/Include/Library/GoogleTestLib.h index b8405cee8e..951bbb8102 100644 --- a/UnitTestFrameworkPkg/Include/Library/GoogleTestLib.h +++ b/UnitTestFrameworkPkg/Include/Library/GoogleTestLib.h @@ -13,6 +13,15 @@ #include #include +// +// For all use of GoogleTestLib, make sure NULL is defined to nullptr to +// support matching any unit test pointer value to NULL. +// +#ifdef NULL + #undef NULL +#define NULL nullptr +#endif + using ::testing::Throws; using ::testing::ThrowsMessage; using ::testing::HasSubstr;