TianoCore EDK2 master
Loading...
Searching...
No Matches
UefiSortLibUnitTest.c File Reference
#include <stdio.h>
#include <string.h>
#include <stdarg.h>
#include <stddef.h>
#include <setjmp.h>
#include <cmocka.h>
#include <Uefi.h>
#include <Library/BaseLib.h>
#include <Library/DebugLib.h>
#include <Library/MemoryAllocationLib.h>
#include <Library/UnitTestLib.h>
#include <Library/SortLib.h>

Go to the source code of this file.

Macros

#define UNIT_TEST_APP_NAME   "UefiSortLib Unit Tests"
 
#define UNIT_TEST_APP_VERSION   "1.0"
 
#define TEST_ARRAY_SIZE_9   9
 
#define UefiSortLibUnitTestMain   main
 

Functions

INTN EFIAPI TestCompareFunction (IN CONST VOID *Left, IN CONST VOID *Right)
 
UNIT_TEST_STATUS EFIAPI SortUINT32ArrayShouldSucceed (IN UNIT_TEST_CONTEXT Context)
 
UNIT_TEST_STATUS EFIAPI CompareSameBufferShouldSucceed (IN UNIT_TEST_CONTEXT Context)
 
STATIC EFI_STATUS EFIAPI UnitTestingEntry (VOID)
 
INT32 UefiSortLibUnitTestMain (IN INT32 Argc, IN CHAR8 *Argv[])
 

Detailed Description

Unit tests of the UefiSortLib

Copyright (C) Huawei Technologies Co., Ltd. All rights reserved SPDX-License-Identifier: BSD-2-Clause-Patent

Definition in file UefiSortLibUnitTest.c.

Macro Definition Documentation

◆ TEST_ARRAY_SIZE_9

#define TEST_ARRAY_SIZE_9   9

Definition at line 27 of file UefiSortLibUnitTest.c.

◆ UefiSortLibUnitTestMain

#define UefiSortLibUnitTestMain   main

Avoid ECC error for function name that starts with lower case letter

Definition at line 188 of file UefiSortLibUnitTest.c.

◆ UNIT_TEST_APP_NAME

#define UNIT_TEST_APP_NAME   "UefiSortLib Unit Tests"

Definition at line 24 of file UefiSortLibUnitTest.c.

◆ UNIT_TEST_APP_VERSION

#define UNIT_TEST_APP_VERSION   "1.0"

Definition at line 25 of file UefiSortLibUnitTest.c.

Function Documentation

◆ CompareSameBufferShouldSucceed()

UNIT_TEST_STATUS EFIAPI CompareSameBufferShouldSucceed ( IN UNIT_TEST_CONTEXT  Context)

Unit test for StringCompare () API of the UefiSortLib.

Parameters
[in]Context[Optional] An optional parameter that enables: 1) test-case reuse with varied parameters and 2) test-case re-entry for Target tests that need a reboot. This parameter is a VOID* and it is the responsibility of the test author to ensure that the contents are well understood by all test cases that may consume it.
Return values
UNIT_TEST_PASSEDThe Unit test has completed and the test case was successful.
UNIT_TEST_ERROR_TEST_FAILEDA test case assertion has failed.

Definition at line 111 of file UefiSortLibUnitTest.c.

◆ SortUINT32ArrayShouldSucceed()

UNIT_TEST_STATUS EFIAPI SortUINT32ArrayShouldSucceed ( IN UNIT_TEST_CONTEXT  Context)

Unit test for PerformQuickSort () API of the UefiSortLib.

Parameters
[in]Context[Optional] An optional parameter that enables: 1) test-case reuse with varied parameters and 2) test-case re-entry for Target tests that need a reboot. This parameter is a VOID* and it is the responsibility of the test author to ensure that the contents are well understood by all test cases that may consume it.
Return values
UNIT_TEST_PASSEDThe Unit test has completed and the test case was successful.
UNIT_TEST_ERROR_TEST_FAILEDA test case assertion has failed.

Definition at line 73 of file UefiSortLibUnitTest.c.

◆ TestCompareFunction()

INTN EFIAPI TestCompareFunction ( IN CONST VOID *  Left,
IN CONST VOID *  Right 
)

The function is called by PerformQuickSort to compare int values.

Parameters
[in]LeftThe pointer to first buffer.
[in]RightThe pointer to second buffer.
Return values
0Buffer1 equal to Buffer2.
Returns
<0 Buffer1 is less than Buffer2.
>0 Buffer1 is greater than Buffer2.

Definition at line 42 of file UefiSortLibUnitTest.c.

◆ UefiSortLibUnitTestMain()

INT32 UefiSortLibUnitTestMain ( IN INT32  Argc,
IN CHAR8 *  Argv[] 
)

Standard POSIX C entry point for host based unit test execution.

Parameters
[in]ArgcNumber of arguments
[in]ArgvArray of pointers to arguments
Return values
0Success
otherError

Definition at line 200 of file UefiSortLibUnitTest.c.

◆ UnitTestingEntry()

STATIC EFI_STATUS EFIAPI UnitTestingEntry ( VOID  )

Initialze the unit test framework, suite, and unit tests for the UefiSortLib and run the UefiSortLib unit test.

Return values
EFI_SUCCESSAll test cases were dispatched.
EFI_OUT_OF_RESOURCESThere are not enough resources available to initialize the unit tests.

Definition at line 135 of file UefiSortLibUnitTest.c.