diff options
| author | kx <kx@radix.pro> | 2024-06-04 06:43:08 +0300 |
|---|---|---|
| committer | kx <kx@radix.pro> | 2024-06-04 06:43:08 +0300 |
| commit | 7e2ccccace24636f29ddc210b94606abd4c7e42b (patch) | |
| tree | 545d43ea12671048956cafeb12303e84d601e571 /UnitTestFrameworkPkg/Test/GoogleTest/Sample/SampleGoogleTestGenerateException | |
| parent | 27b044605cd5f6b33a3d231576003850b3fe305b (diff) | |
| download | edk2-trunk.tar.xz | |
Renormalized end-of-lines from master@27b044605cd5f6b33a3d231576003850b3fe305btrunk
Diffstat (limited to 'UnitTestFrameworkPkg/Test/GoogleTest/Sample/SampleGoogleTestGenerateException')
2 files changed, 93 insertions, 93 deletions
diff --git a/UnitTestFrameworkPkg/Test/GoogleTest/Sample/SampleGoogleTestGenerateException/SampleGoogleTestGenerateException.cpp b/UnitTestFrameworkPkg/Test/GoogleTest/Sample/SampleGoogleTestGenerateException/SampleGoogleTestGenerateException.cpp index 6e62bd79ff..203bfb2d34 100644 --- a/UnitTestFrameworkPkg/Test/GoogleTest/Sample/SampleGoogleTestGenerateException/SampleGoogleTestGenerateException.cpp +++ b/UnitTestFrameworkPkg/Test/GoogleTest/Sample/SampleGoogleTestGenerateException/SampleGoogleTestGenerateException.cpp @@ -1,54 +1,54 @@ -/** @file
- This is a sample to demonstrates the use of GoogleTest that supports host
- execution environments for test case that generates an exception. For some
- host-based environments, this is a fatal condition that terminates the unit
- tests and no additional test cases are executed. On other environments, this
- condition may be report a unit test failure and continue with additional unit
- tests.
-
- Copyright (c) 2024, Intel Corporation. All rights reserved.<BR>
- SPDX-License-Identifier: BSD-2-Clause-Patent
-**/
-
-#include <Library/GoogleTestLib.h>
-extern "C" {
- #include <Uefi.h>
- #include <Library/BaseLib.h>
- #include <Library/DebugLib.h>
-}
-
-UINTN
-DivideWithNoParameterChecking (
- UINTN Dividend,
- UINTN Divisor
- )
-{
- //
- // Perform integer division with no check for divide by zero
- //
- return (Dividend / Divisor);
-}
-
-/**
- Sample unit test that generates an unexpected exception
-**/
-TEST (ExceptionTest, GenerateExceptionExpectTestFail) {
- //
- // Assertion that passes without generating an exception
- //
- EXPECT_EQ (DivideWithNoParameterChecking (20, 1), (UINTN)20);
- //
- // Assertion that generates divide by zero exception before result evaluated
- //
- EXPECT_EQ (DivideWithNoParameterChecking (20, 0), MAX_UINTN);
-}
-
-int
-main (
- int argc,
- char *argv[]
- )
-{
- testing::InitGoogleTest (&argc, argv);
- return RUN_ALL_TESTS ();
-}
+/** @file + This is a sample to demonstrates the use of GoogleTest that supports host + execution environments for test case that generates an exception. For some + host-based environments, this is a fatal condition that terminates the unit + tests and no additional test cases are executed. On other environments, this + condition may be report a unit test failure and continue with additional unit + tests. + + Copyright (c) 2024, Intel Corporation. All rights reserved.<BR> + SPDX-License-Identifier: BSD-2-Clause-Patent +**/ + +#include <Library/GoogleTestLib.h> +extern "C" { + #include <Uefi.h> + #include <Library/BaseLib.h> + #include <Library/DebugLib.h> +} + +UINTN +DivideWithNoParameterChecking ( + UINTN Dividend, + UINTN Divisor + ) +{ + // + // Perform integer division with no check for divide by zero + // + return (Dividend / Divisor); +} + +/** + Sample unit test that generates an unexpected exception +**/ +TEST (ExceptionTest, GenerateExceptionExpectTestFail) { + // + // Assertion that passes without generating an exception + // + EXPECT_EQ (DivideWithNoParameterChecking (20, 1), (UINTN)20); + // + // Assertion that generates divide by zero exception before result evaluated + // + EXPECT_EQ (DivideWithNoParameterChecking (20, 0), MAX_UINTN); +} + +int +main ( + int argc, + char *argv[] + ) +{ + testing::InitGoogleTest (&argc, argv); + return RUN_ALL_TESTS (); +} diff --git a/UnitTestFrameworkPkg/Test/GoogleTest/Sample/SampleGoogleTestGenerateException/SampleGoogleTestHostGenerateException.inf b/UnitTestFrameworkPkg/Test/GoogleTest/Sample/SampleGoogleTestGenerateException/SampleGoogleTestHostGenerateException.inf index 3ce356c8ce..7c53869b09 100644 --- a/UnitTestFrameworkPkg/Test/GoogleTest/Sample/SampleGoogleTestGenerateException/SampleGoogleTestHostGenerateException.inf +++ b/UnitTestFrameworkPkg/Test/GoogleTest/Sample/SampleGoogleTestGenerateException/SampleGoogleTestHostGenerateException.inf @@ -1,39 +1,39 @@ -## @file
-# This is a sample to demonstrates the use of GoogleTest that supports host
-# execution environments for test case that generates an exception. For some
-# host-based environments, this is a fatal condition that terminates the unit
-# tests and no additional test cases are executed. On other environments, this
-# condition may be report a unit test failure and continue with additional unit
-# tests.
-#
-# Copyright (c) 2024, Intel Corporation. All rights reserved.<BR>
-# SPDX-License-Identifier: BSD-2-Clause-Patent
-##
-
-[Defines]
- INF_VERSION = 0x00010005
- BASE_NAME = SampleGoogleTestHostGenerateException
- FILE_GUID = 037A3C56-44C5-4899-AC4D-911943E6FBA1
- MODULE_TYPE = HOST_APPLICATION
- VERSION_STRING = 1.0
-
-#
-# The following information is for reference only and not required by the build tools.
-#
-# VALID_ARCHITECTURES = IA32 X64
-#
-
-[Sources]
- SampleGoogleTestGenerateException.cpp
-
-[Packages]
- MdePkg/MdePkg.dec
- UnitTestFrameworkPkg/UnitTestFrameworkPkg.dec
-
-[LibraryClasses]
- GoogleTestLib
- BaseLib
- DebugLib
-
-[Pcd]
- gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask
+## @file +# This is a sample to demonstrates the use of GoogleTest that supports host +# execution environments for test case that generates an exception. For some +# host-based environments, this is a fatal condition that terminates the unit +# tests and no additional test cases are executed. On other environments, this +# condition may be report a unit test failure and continue with additional unit +# tests. +# +# Copyright (c) 2024, Intel Corporation. All rights reserved.<BR> +# SPDX-License-Identifier: BSD-2-Clause-Patent +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = SampleGoogleTestHostGenerateException + FILE_GUID = 037A3C56-44C5-4899-AC4D-911943E6FBA1 + MODULE_TYPE = HOST_APPLICATION + VERSION_STRING = 1.0 + +# +# The following information is for reference only and not required by the build tools. +# +# VALID_ARCHITECTURES = IA32 X64 +# + +[Sources] + SampleGoogleTestGenerateException.cpp + +[Packages] + MdePkg/MdePkg.dec + UnitTestFrameworkPkg/UnitTestFrameworkPkg.dec + +[LibraryClasses] + GoogleTestLib + BaseLib + DebugLib + +[Pcd] + gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask |
