12#define UNIT_TEST_NAME "Int Safe Lib Unit Test Application"
13#define UNIT_TEST_VERSION "0.1"
44 return UNIT_TEST_PASSED;
73 return UNIT_TEST_PASSED;
102 return UNIT_TEST_PASSED;
131 return UNIT_TEST_PASSED;
136TestSafeInt8ToUint64 (
160 return UNIT_TEST_PASSED;
189 return UNIT_TEST_PASSED;
194TestSafeUint8ToChar8 (
223 return UNIT_TEST_PASSED;
261 return UNIT_TEST_PASSED;
266TestSafeInt16ToChar8 (
315 return UNIT_TEST_PASSED;
320TestSafeInt16ToUint8 (
348 return UNIT_TEST_PASSED;
353TestSafeInt16ToUint16 (
358 INT16 Operand = 0x5b5b;
375 return UNIT_TEST_PASSED;
380TestSafeInt16ToUint32 (
404 return UNIT_TEST_PASSED;
409TestSafeInt16ToUintn (
433 return UNIT_TEST_PASSED;
438TestSafeInt16ToUint64 (
462 return UNIT_TEST_PASSED;
467TestSafeUint16ToInt8 (
491 return UNIT_TEST_PASSED;
496TestSafeUint16ToChar8 (
523 return UNIT_TEST_PASSED;
528TestSafeUint16ToUint8 (
552 return UNIT_TEST_PASSED;
557TestSafeUint16ToInt16 (
581 return UNIT_TEST_PASSED;
611 Operand = (0x5bababab);
615 Operand = (-1537977259);
619 return UNIT_TEST_PASSED;
624TestSafeInt32ToChar8 (
665 Operand = (0x5bababab);
669 Operand = (-1537977259);
673 return UNIT_TEST_PASSED;
678TestSafeInt32ToUint8 (
702 Operand = (0x5bababab);
706 Operand = (-1537977259);
710 return UNIT_TEST_PASSED;
715TestSafeInt32ToInt16 (
740 Operand = (0x5bababab);
744 Operand = (-1537977259);
748 return UNIT_TEST_PASSED;
753TestSafeInt32ToUint16 (
777 Operand = (0x5bababab);
781 Operand = (-1537977259);
785 return UNIT_TEST_PASSED;
790TestSafeInt32ToUint32 (
801 Operand = 0x5bababab;
810 Operand = (-1537977259);
814 return UNIT_TEST_PASSED;
819TestSafeInt32ToUint64 (
830 Operand = 0x5bababab;
839 Operand = (-1537977259);
843 return UNIT_TEST_PASSED;
848TestSafeUint32ToInt8 (
868 Operand = (0x5bababab);
872 return UNIT_TEST_PASSED;
877TestSafeUint32ToChar8 (
900 Operand = (0x5bababab);
904 return UNIT_TEST_PASSED;
909TestSafeUint32ToUint8 (
929 Operand = (0xabababab);
933 return UNIT_TEST_PASSED;
938TestSafeUint32ToInt16 (
958 Operand = (0xabababab);
962 return UNIT_TEST_PASSED;
967TestSafeUint32ToUint16 (
987 Operand = (0xabababab);
991 return UNIT_TEST_PASSED;
996TestSafeUint32ToInt32 (
1007 Operand = 0x5bababab;
1016 Operand = (0xabababab);
1020 return UNIT_TEST_PASSED;
1050 Operand = (0x5bababab);
1054 Operand = (-1537977259);
1058 return UNIT_TEST_PASSED;
1063TestSafeIntnToChar8 (
1104 Operand = (0x5bababab);
1108 Operand = (-1537977259);
1112 return UNIT_TEST_PASSED;
1117TestSafeIntnToUint8 (
1137 Operand = (0x5bababab);
1141 Operand = (-1537977259);
1145 return UNIT_TEST_PASSED;
1150TestSafeIntnToInt16 (
1175 Operand = (0x5bababab);
1179 Operand = (-1537977259);
1183 return UNIT_TEST_PASSED;
1188TestSafeIntnToUint16 (
1208 Operand = (0x5bababab);
1212 Operand = (-1537977259);
1216 return UNIT_TEST_PASSED;
1221TestSafeIntnToUintn (
1232 Operand = 0x5bababab;
1241 Operand = (-1537977259);
1245 return UNIT_TEST_PASSED;
1250TestSafeIntnToUint64 (
1261 Operand = 0x5bababab;
1270 Operand = (-1537977259);
1274 return UNIT_TEST_PASSED;
1279TestSafeUintnToInt8 (
1303 return UNIT_TEST_PASSED;
1308TestSafeUintnToChar8 (
1335 return UNIT_TEST_PASSED;
1340TestSafeUintnToUint8 (
1364 return UNIT_TEST_PASSED;
1369TestSafeUintnToInt16 (
1393 return UNIT_TEST_PASSED;
1398TestSafeUintnToUint16 (
1418 Operand = (0xabababab);
1422 return UNIT_TEST_PASSED;
1427TestSafeUintnToInt32 (
1438 Operand = 0x5bababab;
1447 Operand = (0xabababab);
1451 return UNIT_TEST_PASSED;
1456TestSafeInt64ToInt8 (
1481 Operand = (0x5babababefefefef);
1485 Operand = (-6605562033422200815);
1489 return UNIT_TEST_PASSED;
1494TestSafeInt64ToChar8 (
1535 Operand = (0x5babababefefefef);
1539 Operand = (-6605562033422200815);
1543 return UNIT_TEST_PASSED;
1548TestSafeInt64ToUint8 (
1568 Operand = (0x5babababefefefef);
1572 Operand = (-6605562033422200815);
1576 return UNIT_TEST_PASSED;
1581TestSafeInt64ToInt16 (
1606 Operand = (0x5babababefefefef);
1610 Operand = (-6605562033422200815);
1614 return UNIT_TEST_PASSED;
1619TestSafeInt64ToUint16 (
1639 Operand = (0x5babababefefefef);
1643 Operand = (-6605562033422200815);
1647 return UNIT_TEST_PASSED;
1652TestSafeInt64ToInt32 (
1663 Operand = 0x5bababab;
1669 Operand = (-1537977259);
1677 Operand = (0x5babababefefefef);
1681 Operand = (-6605562033422200815);
1685 return UNIT_TEST_PASSED;
1690TestSafeInt64ToUint32 (
1701 Operand = 0xabababab;
1710 Operand = (0x5babababefefefef);
1714 Operand = (-6605562033422200815);
1718 return UNIT_TEST_PASSED;
1723TestSafeInt64ToUint64 (
1734 Operand = 0x5babababefefefef;
1743 Operand = (-6605562033422200815);
1747 return UNIT_TEST_PASSED;
1752TestSafeUint64ToInt8 (
1772 Operand = (0xababababefefefef);
1776 return UNIT_TEST_PASSED;
1781TestSafeUint64ToChar8 (
1804 Operand = (0xababababefefefef);
1808 return UNIT_TEST_PASSED;
1813TestSafeUint64ToUint8 (
1833 Operand = (0xababababefefefef);
1837 return UNIT_TEST_PASSED;
1842TestSafeUint64ToInt16 (
1862 Operand = (0xababababefefefef);
1866 return UNIT_TEST_PASSED;
1871TestSafeUint64ToUint16 (
1891 Operand = (0xababababefefefef);
1895 return UNIT_TEST_PASSED;
1900TestSafeUint64ToInt32 (
1911 Operand = 0x5bababab;
1920 Operand = (0xababababefefefef);
1924 return UNIT_TEST_PASSED;
1929TestSafeUint64ToUint32 (
1940 Operand = 0xabababab;
1949 Operand = (0xababababefefefef);
1953 return UNIT_TEST_PASSED;
1958TestSafeUint64ToInt64 (
1969 Operand = 0x5babababefefefef;
1978 Operand = (0xababababefefefef);
1982 return UNIT_TEST_PASSED;
2017 return UNIT_TEST_PASSED;
2027 UINT16 Augend = 0x3a3a;
2028 UINT16 Addend = 0x3a3a;
2046 return UNIT_TEST_PASSED;
2063 Augend = 0x3a3a3a3a;
2064 Addend = 0x3a3a3a3a;
2073 Augend = 0xabababab;
2074 Addend = 0xbcbcbcbc;
2078 return UNIT_TEST_PASSED;
2095 Augend = 0x3a3a3a3a12121212;
2096 Addend = 0x3a3a3a3a12121212;
2105 Augend = 0xababababefefefef;
2106 Addend = 0xbcbcbcbcdededede;
2110 return UNIT_TEST_PASSED;
2154 return UNIT_TEST_PASSED;
2198 return UNIT_TEST_PASSED;
2216 Augend = 0x3a3a3a3a;
2217 Addend = 0x3a3a3a3a;
2223 Augend = (-976894522);
2224 Addend = (-976894522);
2232 Augend = 0x5a5a5a5a;
2233 Addend = 0x5a5a5a5a;
2237 Augend = (-1515870810);
2238 Addend = (-1515870810);
2242 return UNIT_TEST_PASSED;
2260 Augend = 0x3a3a3a3a3a3a3a3a;
2261 Addend = 0x3a3a3a3a3a3a3a3a;
2267 Augend = (-4195730024608447034);
2268 Addend = (-4195730024608447034);
2276 Augend = 0x5a5a5a5a5a5a5a5a;
2277 Addend = 0x5a5a5a5a5a5a5a5a;
2281 Augend = (-6510615555426900570);
2282 Addend = (-6510615555426900570);
2286 return UNIT_TEST_PASSED;
2321 return UNIT_TEST_PASSED;
2339 Subtrahend = 0x3b3b;
2349 Subtrahend = 0x6d6d;
2353 return UNIT_TEST_PASSED;
2370 Minuend = 0x5a5a5a5a;
2371 Subtrahend = 0x3b3b3b3b;
2380 Minuend = 0x5a5a5a5a;
2381 Subtrahend = 0x6d6d6d6d;
2385 return UNIT_TEST_PASSED;
2402 Minuend = 0x5a5a5a5a5a5a5a5a;
2403 Subtrahend = 0x3b3b3b3b3b3b3b3b;
2412 Minuend = 0x5a5a5a5a5a5a5a5a;
2413 Subtrahend = 0x6d6d6d6d6d6d6d6d;
2417 return UNIT_TEST_PASSED;
2438 Status =
SafeInt8Sub (Minuend, Subtrahend, &Result);
2444 Status =
SafeInt8Sub (Minuend, Subtrahend, &Result);
2453 Status =
SafeInt8Sub (Minuend, Subtrahend, &Result);
2458 Status =
SafeInt8Sub (Minuend, Subtrahend, &Result);
2461 return UNIT_TEST_PASSED;
2480 Subtrahend = 0x3a3a;
2487 Subtrahend = 0x5a5a;
2501 Subtrahend = (-31354);
2505 return UNIT_TEST_PASSED;
2523 Minuend = 0x5a5a5a5a;
2524 Subtrahend = 0x3a3a3a3a;
2530 Minuend = 0x3a3a3a3a;
2531 Subtrahend = 0x5a5a5a5a;
2539 Minuend = (-2054847098);
2540 Subtrahend = 2054847098;
2544 Minuend = (2054847098);
2545 Subtrahend = (-2054847098);
2549 return UNIT_TEST_PASSED;
2567 Minuend = 0x5a5a5a5a5a5a5a5a;
2568 Subtrahend = 0x3a3a3a3a3a3a3a3a;
2574 Minuend = 0x3a3a3a3a3a3a3a3a;
2575 Subtrahend = 0x5a5a5a5a5a5a5a5a;
2583 Minuend = (-8825501086245354106);
2584 Subtrahend = 8825501086245354106;
2588 Minuend = (8825501086245354106);
2589 Subtrahend = (-8825501086245354106);
2593 return UNIT_TEST_PASSED;
2613 Multiplicand = 0x12;
2623 Multiplicand = 0x12;
2628 return UNIT_TEST_PASSED;
2638 UINT16 Multiplicand;
2645 Multiplicand = 0x212;
2655 Multiplicand = 0x1234;
2660 return UNIT_TEST_PASSED;
2670 UINT32 Multiplicand;
2677 Multiplicand = 0xa122a;
2687 Multiplicand = 0xa122a;
2688 Multiplier = 0xed23;
2692 return UNIT_TEST_PASSED;
2702 UINT64 Multiplicand;
2709 Multiplicand = 0x123456789a;
2710 Multiplier = 0x1234567;
2719 Multiplicand = 0x123456789a;
2720 Multiplier = 0x12345678;
2724 return UNIT_TEST_PASSED;
2742 Multiplicand = 0x12;
2745 Status =
SafeInt8Mult (Multiplicand, Multiplier, &Result);
2752 Multiplicand = 0x12;
2754 Status =
SafeInt8Mult (Multiplicand, Multiplier, &Result);
2757 return UNIT_TEST_PASSED;
2775 Multiplicand = 0x123;
2785 Multiplicand = 0x123;
2790 return UNIT_TEST_PASSED;
2808 Multiplicand = 0x123456;
2818 Multiplicand = 0x123456;
2823 return UNIT_TEST_PASSED;
2841 Multiplicand = 0x123456789;
2842 Multiplier = 0x6789abcd;
2851 Multiplicand = 0x123456789;
2852 Multiplier = 0xa789abcd;
2856 return UNIT_TEST_PASSED;
2871 UNIT_TEST_FRAMEWORK_HANDLE Framework;
2872 UNIT_TEST_SUITE_HANDLE ConversionTestSuite;
2873 UNIT_TEST_SUITE_HANDLE AdditionSubtractionTestSuite;
2874 UNIT_TEST_SUITE_HANDLE MultiplicationTestSuite;
2877 ConversionTestSuite =
NULL;
2878 AdditionSubtractionTestSuite =
NULL;
2879 MultiplicationTestSuite =
NULL;
2881 DEBUG ((DEBUG_INFO,
"%a v%a\n", UNIT_TEST_NAME, UNIT_TEST_VERSION));
2887 if (EFI_ERROR (Status)) {
2888 DEBUG ((DEBUG_ERROR,
"Failed in InitUnitTestFramework. Status = %r\n", Status));
2895 Status =
CreateUnitTestSuite (&ConversionTestSuite, Framework,
"Int Safe Conversions Test Suite",
"Common.SafeInt.Convert",
NULL,
NULL);
2896 if (EFI_ERROR (Status)) {
2897 DEBUG ((DEBUG_ERROR,
"Failed in CreateUnitTestSuite for Conversions Test Suite\n"));
2898 Status = EFI_OUT_OF_RESOURCES;
2902 AddTestCase (ConversionTestSuite,
"Test SafeInt8ToUint8",
"TestSafeInt8ToUint8", TestSafeInt8ToUint8,
NULL,
NULL,
NULL);
2903 AddTestCase (ConversionTestSuite,
"Test SafeInt8ToUint16",
"TestSafeInt8ToUint16", TestSafeInt8ToUint16,
NULL,
NULL,
NULL);
2904 AddTestCase (ConversionTestSuite,
"Test SafeInt8ToUint32",
"TestSafeInt8ToUint32", TestSafeInt8ToUint32,
NULL,
NULL,
NULL);
2905 AddTestCase (ConversionTestSuite,
"Test SafeInt8ToUintn",
"TestSafeInt8ToUintn", TestSafeInt8ToUintn,
NULL,
NULL,
NULL);
2906 AddTestCase (ConversionTestSuite,
"Test SafeInt8ToUint64",
"TestSafeInt8ToUint64", TestSafeInt8ToUint64,
NULL,
NULL,
NULL);
2907 AddTestCase (ConversionTestSuite,
"Test SafeUint8ToInt8",
"TestSafeUint8ToInt8", TestSafeUint8ToInt8,
NULL,
NULL,
NULL);
2908 AddTestCase (ConversionTestSuite,
"Test SafeUint8ToChar8",
"TestSafeUint8ToChar8", TestSafeUint8ToChar8,
NULL,
NULL,
NULL);
2909 AddTestCase (ConversionTestSuite,
"Test SafeInt16ToInt8",
"TestSafeInt16ToInt8", TestSafeInt16ToInt8,
NULL,
NULL,
NULL);
2910 AddTestCase (ConversionTestSuite,
"Test SafeInt16ToChar8",
"TestSafeInt16ToChar8", TestSafeInt16ToChar8,
NULL,
NULL,
NULL);
2911 AddTestCase (ConversionTestSuite,
"Test SafeInt16ToUint8",
"TestSafeInt16ToUint8", TestSafeInt16ToUint8,
NULL,
NULL,
NULL);
2912 AddTestCase (ConversionTestSuite,
"Test SafeInt16ToUint16",
"TestSafeInt16ToUint16", TestSafeInt16ToUint16,
NULL,
NULL,
NULL);
2913 AddTestCase (ConversionTestSuite,
"Test SafeInt16ToUint32",
"TestSafeInt16ToUint32", TestSafeInt16ToUint32,
NULL,
NULL,
NULL);
2914 AddTestCase (ConversionTestSuite,
"Test SafeInt16ToUintn",
"TestSafeInt16ToUintn", TestSafeInt16ToUintn,
NULL,
NULL,
NULL);
2915 AddTestCase (ConversionTestSuite,
"Test SafeInt16ToUint64",
"TestSafeInt16ToUint64", TestSafeInt16ToUint64,
NULL,
NULL,
NULL);
2916 AddTestCase (ConversionTestSuite,
"Test SafeUint16ToInt8",
"TestSafeUint16ToInt8", TestSafeUint16ToInt8,
NULL,
NULL,
NULL);
2917 AddTestCase (ConversionTestSuite,
"Test SafeUint16ToChar8",
"TestSafeUint16ToChar8", TestSafeUint16ToChar8,
NULL,
NULL,
NULL);
2918 AddTestCase (ConversionTestSuite,
"Test SafeUint16ToUint8",
"TestSafeUint16ToUint8", TestSafeUint16ToUint8,
NULL,
NULL,
NULL);
2919 AddTestCase (ConversionTestSuite,
"Test SafeUint16ToInt16",
"TestSafeUint16ToInt16", TestSafeUint16ToInt16,
NULL,
NULL,
NULL);
2920 AddTestCase (ConversionTestSuite,
"Test SafeInt32ToInt8",
"TestSafeInt32ToInt8", TestSafeInt32ToInt8,
NULL,
NULL,
NULL);
2921 AddTestCase (ConversionTestSuite,
"Test SafeInt32ToChar8",
"TestSafeInt32ToChar8", TestSafeInt32ToChar8,
NULL,
NULL,
NULL);
2922 AddTestCase (ConversionTestSuite,
"Test SafeInt32ToUint8",
"TestSafeInt32ToUint8", TestSafeInt32ToUint8,
NULL,
NULL,
NULL);
2923 AddTestCase (ConversionTestSuite,
"Test SafeInt32ToInt16",
"TestSafeInt32ToInt16", TestSafeInt32ToInt16,
NULL,
NULL,
NULL);
2924 AddTestCase (ConversionTestSuite,
"Test SafeInt32ToUint16",
"TestSafeInt32ToUint16", TestSafeInt32ToUint16,
NULL,
NULL,
NULL);
2925 AddTestCase (ConversionTestSuite,
"Test SafeInt32ToUint32",
"TestSafeInt32ToUint32", TestSafeInt32ToUint32,
NULL,
NULL,
NULL);
2926 AddTestCase (ConversionTestSuite,
"Test SafeInt32ToUintn",
"TestSafeInt32ToUintn", TestSafeInt32ToUintn,
NULL,
NULL,
NULL);
2927 AddTestCase (ConversionTestSuite,
"Test SafeInt32ToUint64",
"TestSafeInt32ToUint64", TestSafeInt32ToUint64,
NULL,
NULL,
NULL);
2928 AddTestCase (ConversionTestSuite,
"Test SafeUint32ToInt8",
"TestSafeUint32ToInt8", TestSafeUint32ToInt8,
NULL,
NULL,
NULL);
2929 AddTestCase (ConversionTestSuite,
"Test SafeUint32ToChar8",
"TestSafeUint32ToChar8", TestSafeUint32ToChar8,
NULL,
NULL,
NULL);
2930 AddTestCase (ConversionTestSuite,
"Test SafeUint32ToUint8",
"TestSafeUint32ToUint8", TestSafeUint32ToUint8,
NULL,
NULL,
NULL);
2931 AddTestCase (ConversionTestSuite,
"Test SafeUint32ToInt16",
"TestSafeUint32ToInt16", TestSafeUint32ToInt16,
NULL,
NULL,
NULL);
2932 AddTestCase (ConversionTestSuite,
"Test SafeUint32ToUint16",
"TestSafeUint32ToUint16", TestSafeUint32ToUint16,
NULL,
NULL,
NULL);
2933 AddTestCase (ConversionTestSuite,
"Test SafeUint32ToInt32",
"TestSafeUint32ToInt32", TestSafeUint32ToInt32,
NULL,
NULL,
NULL);
2934 AddTestCase (ConversionTestSuite,
"Test SafeUint32ToIntn",
"TestSafeUint32ToIntn", TestSafeUint32ToIntn,
NULL,
NULL,
NULL);
2935 AddTestCase (ConversionTestSuite,
"Test SafeIntnToInt8",
"TestSafeIntnToInt8", TestSafeIntnToInt8,
NULL,
NULL,
NULL);
2936 AddTestCase (ConversionTestSuite,
"Test SafeIntnToChar8",
"TestSafeIntnToChar8", TestSafeIntnToChar8,
NULL,
NULL,
NULL);
2937 AddTestCase (ConversionTestSuite,
"Test SafeIntnToUint8",
"TestSafeIntnToUint8", TestSafeIntnToUint8,
NULL,
NULL,
NULL);
2938 AddTestCase (ConversionTestSuite,
"Test SafeIntnToInt16",
"TestSafeIntnToInt16", TestSafeIntnToInt16,
NULL,
NULL,
NULL);
2939 AddTestCase (ConversionTestSuite,
"Test SafeIntnToUint16",
"TestSafeIntnToUint16", TestSafeIntnToUint16,
NULL,
NULL,
NULL);
2940 AddTestCase (ConversionTestSuite,
"Test SafeIntnToInt32",
"TestSafeIntnToInt32", TestSafeIntnToInt32,
NULL,
NULL,
NULL);
2941 AddTestCase (ConversionTestSuite,
"Test SafeIntnToUint32",
"TestSafeIntnToUint32", TestSafeIntnToUint32,
NULL,
NULL,
NULL);
2942 AddTestCase (ConversionTestSuite,
"Test SafeIntnToUintn",
"TestSafeIntnToUintn", TestSafeIntnToUintn,
NULL,
NULL,
NULL);
2943 AddTestCase (ConversionTestSuite,
"Test SafeIntnToUint64",
"TestSafeIntnToUint64", TestSafeIntnToUint64,
NULL,
NULL,
NULL);
2944 AddTestCase (ConversionTestSuite,
"Test SafeUintnToInt8",
"TestSafeUintnToInt8", TestSafeUintnToInt8,
NULL,
NULL,
NULL);
2945 AddTestCase (ConversionTestSuite,
"Test SafeUintnToChar8",
"TestSafeUintnToChar8", TestSafeUintnToChar8,
NULL,
NULL,
NULL);
2946 AddTestCase (ConversionTestSuite,
"Test SafeUintnToUint8",
"TestSafeUintnToUint8", TestSafeUintnToUint8,
NULL,
NULL,
NULL);
2947 AddTestCase (ConversionTestSuite,
"Test SafeUintnToInt16",
"TestSafeUintnToInt16", TestSafeUintnToInt16,
NULL,
NULL,
NULL);
2948 AddTestCase (ConversionTestSuite,
"Test SafeUintnToUint16",
"TestSafeUintnToUint16", TestSafeUintnToUint16,
NULL,
NULL,
NULL);
2949 AddTestCase (ConversionTestSuite,
"Test SafeUintnToInt32",
"TestSafeUintnToInt32", TestSafeUintnToInt32,
NULL,
NULL,
NULL);
2950 AddTestCase (ConversionTestSuite,
"Test SafeUintnToUint32",
"TestSafeUintnToUint32", TestSafeUintnToUint32,
NULL,
NULL,
NULL);
2951 AddTestCase (ConversionTestSuite,
"Test SafeUintnToIntn",
"TestSafeUintnToIntn", TestSafeUintnToIntn,
NULL,
NULL,
NULL);
2952 AddTestCase (ConversionTestSuite,
"Test SafeUintnToInt64",
"TestSafeUintnToInt64", TestSafeUintnToInt64,
NULL,
NULL,
NULL);
2953 AddTestCase (ConversionTestSuite,
"Test SafeInt64ToInt8",
"TestSafeInt64ToInt8", TestSafeInt64ToInt8,
NULL,
NULL,
NULL);
2954 AddTestCase (ConversionTestSuite,
"Test SafeInt64ToChar8",
"TestSafeInt64ToChar8", TestSafeInt64ToChar8,
NULL,
NULL,
NULL);
2955 AddTestCase (ConversionTestSuite,
"Test SafeInt64ToUint8",
"TestSafeInt64ToUint8", TestSafeInt64ToUint8,
NULL,
NULL,
NULL);
2956 AddTestCase (ConversionTestSuite,
"Test SafeInt64ToInt16",
"TestSafeInt64ToInt16", TestSafeInt64ToInt16,
NULL,
NULL,
NULL);
2957 AddTestCase (ConversionTestSuite,
"Test SafeInt64ToUint16",
"TestSafeInt64ToUint16", TestSafeInt64ToUint16,
NULL,
NULL,
NULL);
2958 AddTestCase (ConversionTestSuite,
"Test SafeInt64ToInt32",
"TestSafeInt64ToInt32", TestSafeInt64ToInt32,
NULL,
NULL,
NULL);
2959 AddTestCase (ConversionTestSuite,
"Test SafeInt64ToUint32",
"TestSafeInt64ToUint32", TestSafeInt64ToUint32,
NULL,
NULL,
NULL);
2960 AddTestCase (ConversionTestSuite,
"Test SafeInt64ToIntn",
"TestSafeInt64ToIntn", TestSafeInt64ToIntn,
NULL,
NULL,
NULL);
2961 AddTestCase (ConversionTestSuite,
"Test SafeInt64ToUintn",
"TestSafeInt64ToUintn", TestSafeInt64ToUintn,
NULL,
NULL,
NULL);
2962 AddTestCase (ConversionTestSuite,
"Test SafeInt64ToUint64",
"TestSafeInt64ToUint64", TestSafeInt64ToUint64,
NULL,
NULL,
NULL);
2963 AddTestCase (ConversionTestSuite,
"Test SafeUint64ToInt8",
"TestSafeUint64ToInt8", TestSafeUint64ToInt8,
NULL,
NULL,
NULL);
2964 AddTestCase (ConversionTestSuite,
"Test SafeUint64ToChar8",
"TestSafeUint64ToChar8", TestSafeUint64ToChar8,
NULL,
NULL,
NULL);
2965 AddTestCase (ConversionTestSuite,
"Test SafeUint64ToUint8",
"TestSafeUint64ToUint8", TestSafeUint64ToUint8,
NULL,
NULL,
NULL);
2966 AddTestCase (ConversionTestSuite,
"Test SafeUint64ToInt16",
"TestSafeUint64ToInt16", TestSafeUint64ToInt16,
NULL,
NULL,
NULL);
2967 AddTestCase (ConversionTestSuite,
"Test SafeUint64ToUint16",
"TestSafeUint64ToUint16", TestSafeUint64ToUint16,
NULL,
NULL,
NULL);
2968 AddTestCase (ConversionTestSuite,
"Test SafeUint64ToInt32",
"TestSafeUint64ToInt32", TestSafeUint64ToInt32,
NULL,
NULL,
NULL);
2969 AddTestCase (ConversionTestSuite,
"Test SafeUint64ToUint32",
"TestSafeUint64ToUint32", TestSafeUint64ToUint32,
NULL,
NULL,
NULL);
2970 AddTestCase (ConversionTestSuite,
"Test SafeUint64ToIntn",
"TestSafeUint64ToIntn", TestSafeUint64ToIntn,
NULL,
NULL,
NULL);
2971 AddTestCase (ConversionTestSuite,
"Test SafeUint64ToUintn",
"TestSafeUint64ToUintn", TestSafeUint64ToUintn,
NULL,
NULL,
NULL);
2972 AddTestCase (ConversionTestSuite,
"Test SafeUint64ToInt64",
"TestSafeUint64ToInt64", TestSafeUint64ToInt64,
NULL,
NULL,
NULL);
2977 Status =
CreateUnitTestSuite (&AdditionSubtractionTestSuite, Framework,
"Int Safe Add/Subtract Test Suite",
"Common.SafeInt.AddSubtract",
NULL,
NULL);
2978 if (EFI_ERROR (Status)) {
2979 DEBUG ((DEBUG_ERROR,
"Failed in CreateUnitTestSuite for Int Safe Add/Subtract Test Suite\n"));
2980 Status = EFI_OUT_OF_RESOURCES;
2984 AddTestCase (AdditionSubtractionTestSuite,
"Test SafeUint8Add",
"TestSafeUint8Add", TestSafeUint8Add,
NULL,
NULL,
NULL);
2985 AddTestCase (AdditionSubtractionTestSuite,
"Test SafeUint16Add",
"TestSafeUint16Add", TestSafeUint16Add,
NULL,
NULL,
NULL);
2986 AddTestCase (AdditionSubtractionTestSuite,
"Test SafeUint32Add",
"TestSafeUint32Add", TestSafeUint32Add,
NULL,
NULL,
NULL);
2987 AddTestCase (AdditionSubtractionTestSuite,
"Test SafeUintnAdd",
"TestSafeUintnAdd", TestSafeUintnAdd,
NULL,
NULL,
NULL);
2988 AddTestCase (AdditionSubtractionTestSuite,
"Test SafeUint64Add",
"TestSafeUint64Add", TestSafeUint64Add,
NULL,
NULL,
NULL);
2989 AddTestCase (AdditionSubtractionTestSuite,
"Test SafeInt8Add",
"TestSafeInt8Add", TestSafeInt8Add,
NULL,
NULL,
NULL);
2990 AddTestCase (AdditionSubtractionTestSuite,
"Test SafeInt16Add",
"TestSafeInt16Add", TestSafeInt16Add,
NULL,
NULL,
NULL);
2991 AddTestCase (AdditionSubtractionTestSuite,
"Test SafeInt32Add",
"TestSafeInt32Add", TestSafeInt32Add,
NULL,
NULL,
NULL);
2992 AddTestCase (AdditionSubtractionTestSuite,
"Test SafeIntnAdd",
"TestSafeIntnAdd", TestSafeIntnAdd,
NULL,
NULL,
NULL);
2993 AddTestCase (AdditionSubtractionTestSuite,
"Test SafeInt64Add",
"TestSafeInt64Add", TestSafeInt64Add,
NULL,
NULL,
NULL);
2994 AddTestCase (AdditionSubtractionTestSuite,
"Test SafeUint8Sub",
"TestSafeUint8Sub", TestSafeUint8Sub,
NULL,
NULL,
NULL);
2995 AddTestCase (AdditionSubtractionTestSuite,
"Test SafeUint16Sub",
"TestSafeUint16Sub", TestSafeUint16Sub,
NULL,
NULL,
NULL);
2996 AddTestCase (AdditionSubtractionTestSuite,
"Test SafeUint32Sub",
"TestSafeUint32Sub", TestSafeUint32Sub,
NULL,
NULL,
NULL);
2997 AddTestCase (AdditionSubtractionTestSuite,
"Test SafeUintnSub",
"TestSafeUintnSub", TestSafeUintnSub,
NULL,
NULL,
NULL);
2998 AddTestCase (AdditionSubtractionTestSuite,
"Test SafeUint64Sub",
"TestSafeUint64Sub", TestSafeUint64Sub,
NULL,
NULL,
NULL);
2999 AddTestCase (AdditionSubtractionTestSuite,
"Test SafeInt8Sub",
"TestSafeInt8Sub", TestSafeInt8Sub,
NULL,
NULL,
NULL);
3000 AddTestCase (AdditionSubtractionTestSuite,
"Test SafeInt16Sub",
"TestSafeInt16Sub", TestSafeInt16Sub,
NULL,
NULL,
NULL);
3001 AddTestCase (AdditionSubtractionTestSuite,
"Test SafeInt32Sub",
"TestSafeInt32Sub", TestSafeInt32Sub,
NULL,
NULL,
NULL);
3002 AddTestCase (AdditionSubtractionTestSuite,
"Test SafeIntnSub",
"TestSafeIntnSub", TestSafeIntnSub,
NULL,
NULL,
NULL);
3003 AddTestCase (AdditionSubtractionTestSuite,
"Test SafeInt64Sub",
"TestSafeInt64Sub", TestSafeInt64Sub,
NULL,
NULL,
NULL);
3008 Status =
CreateUnitTestSuite (&MultiplicationTestSuite, Framework,
"Int Safe Multiply Test Suite",
"Common.SafeInt.Multiply",
NULL,
NULL);
3009 if (EFI_ERROR (Status)) {
3010 DEBUG ((DEBUG_ERROR,
"Failed in CreateUnitTestSuite for Int Safe Multiply Test Suite\n"));
3011 Status = EFI_OUT_OF_RESOURCES;
3015 AddTestCase (MultiplicationTestSuite,
"Test SafeUint8Mult",
"TestSafeUint8Mult", TestSafeUint8Mult,
NULL,
NULL,
NULL);
3016 AddTestCase (MultiplicationTestSuite,
"Test SafeUint16Mult",
"TestSafeUint16Mult", TestSafeUint16Mult,
NULL,
NULL,
NULL);
3017 AddTestCase (MultiplicationTestSuite,
"Test SafeUint32Mult",
"TestSafeUint32Mult", TestSafeUint32Mult,
NULL,
NULL,
NULL);
3018 AddTestCase (MultiplicationTestSuite,
"Test SafeUintnMult",
"TestSafeUintnMult", TestSafeUintnMult,
NULL,
NULL,
NULL);
3019 AddTestCase (MultiplicationTestSuite,
"Test SafeUint64Mult",
"TestSafeUint64Mult", TestSafeUint64Mult,
NULL,
NULL,
NULL);
3020 AddTestCase (MultiplicationTestSuite,
"Test SafeInt8Mult",
"TestSafeInt8Mult", TestSafeInt8Mult,
NULL,
NULL,
NULL);
3021 AddTestCase (MultiplicationTestSuite,
"Test SafeInt16Mult",
"TestSafeInt16Mult", TestSafeInt16Mult,
NULL,
NULL,
NULL);
3022 AddTestCase (MultiplicationTestSuite,
"Test SafeInt32Mult",
"TestSafeInt32Mult", TestSafeInt32Mult,
NULL,
NULL,
NULL);
3023 AddTestCase (MultiplicationTestSuite,
"Test SafeIntnMult",
"TestSafeIntnMult", TestSafeIntnMult,
NULL,
NULL,
NULL);
3024 AddTestCase (MultiplicationTestSuite,
"Test SafeInt64Mult",
"TestSafeInt64Mult", TestSafeInt64Mult,
NULL,
NULL,
NULL);
3032 if (Framework !=
NULL) {
int main()
=== TEST ENGINE ================================================================================
#define RETURN_BUFFER_TOO_SMALL
#define DEBUG(Expression)
VOID * EFI_PEI_FILE_HANDLE
RETURN_STATUS EFIAPI SafeInt16ToUint32(IN INT16 Operand, OUT UINT32 *Result)
RETURN_STATUS EFIAPI SafeUint64ToInt8(IN UINT64 Operand, OUT INT8 *Result)
RETURN_STATUS EFIAPI SafeInt64ToInt32(IN INT64 Operand, OUT INT32 *Result)
RETURN_STATUS EFIAPI SafeIntnToInt16(IN INTN Operand, OUT INT16 *Result)
RETURN_STATUS EFIAPI SafeInt32Sub(IN INT32 Minuend, IN INT32 Subtrahend, OUT INT32 *Result)
RETURN_STATUS EFIAPI SafeUint64ToInt32(IN UINT64 Operand, OUT INT32 *Result)
RETURN_STATUS EFIAPI SafeIntnToInt8(IN INTN Operand, OUT INT8 *Result)
RETURN_STATUS EFIAPI SafeUint16Sub(IN UINT16 Minuend, IN UINT16 Subtrahend, OUT UINT16 *Result)
RETURN_STATUS EFIAPI SafeInt8ToUintn(IN INT8 Operand, OUT UINTN *Result)
RETURN_STATUS EFIAPI SafeUint8Sub(IN UINT8 Minuend, IN UINT8 Subtrahend, OUT UINT8 *Result)
RETURN_STATUS EFIAPI SafeInt8Mult(IN INT8 Multiplicand, IN INT8 Multiplier, OUT INT8 *Result)
RETURN_STATUS EFIAPI SafeUint32ToInt32(IN UINT32 Operand, OUT INT32 *Result)
RETURN_STATUS EFIAPI SafeUint32Add(IN UINT32 Augend, IN UINT32 Addend, OUT UINT32 *Result)
RETURN_STATUS EFIAPI SafeUintnToInt32(IN UINTN Operand, OUT INT32 *Result)
RETURN_STATUS EFIAPI SafeInt32ToUint32(IN INT32 Operand, OUT UINT32 *Result)
RETURN_STATUS EFIAPI SafeUint64ToUint16(IN UINT64 Operand, OUT UINT16 *Result)
RETURN_STATUS EFIAPI SafeIntnToChar8(IN INTN Operand, OUT CHAR8 *Result)
RETURN_STATUS EFIAPI SafeInt32ToInt16(IN INT32 Operand, OUT INT16 *Result)
RETURN_STATUS EFIAPI SafeUint32Mult(IN UINT32 Multiplicand, IN UINT32 Multiplier, OUT UINT32 *Result)
RETURN_STATUS EFIAPI SafeInt16ToChar8(IN INT16 Operand, OUT CHAR8 *Result)
RETURN_STATUS EFIAPI SafeInt8ToUint64(IN INT8 Operand, OUT UINT64 *Result)
RETURN_STATUS EFIAPI SafeInt16ToUint64(IN INT16 Operand, OUT UINT64 *Result)
RETURN_STATUS EFIAPI SafeInt16ToUintn(IN INT16 Operand, OUT UINTN *Result)
RETURN_STATUS EFIAPI SafeUintnToInt8(IN UINTN Operand, OUT INT8 *Result)
RETURN_STATUS EFIAPI SafeUint16Mult(IN UINT16 Multiplicand, IN UINT16 Multiplier, OUT UINT16 *Result)
RETURN_STATUS EFIAPI SafeInt32ToUint64(IN INT32 Operand, OUT UINT64 *Result)
RETURN_STATUS EFIAPI SafeUint64ToUint8(IN UINT64 Operand, OUT UINT8 *Result)
RETURN_STATUS EFIAPI SafeUint16ToInt16(IN UINT16 Operand, OUT INT16 *Result)
RETURN_STATUS EFIAPI SafeInt64ToUint32(IN INT64 Operand, OUT UINT32 *Result)
RETURN_STATUS EFIAPI SafeUint64ToChar8(IN UINT64 Operand, OUT CHAR8 *Result)
RETURN_STATUS EFIAPI SafeInt64ToInt16(IN INT64 Operand, OUT INT16 *Result)
RETURN_STATUS EFIAPI SafeUint8ToInt8(IN UINT8 Operand, OUT INT8 *Result)
RETURN_STATUS EFIAPI SafeUint16Add(IN UINT16 Augend, IN UINT16 Addend, OUT UINT16 *Result)
RETURN_STATUS EFIAPI SafeUintnToUint16(IN UINTN Operand, OUT UINT16 *Result)
RETURN_STATUS EFIAPI SafeInt32Mult(IN INT32 Multiplicand, IN INT32 Multiplier, OUT INT32 *Result)
RETURN_STATUS EFIAPI SafeInt64Mult(IN INT64 Multiplicand, IN INT64 Multiplier, OUT INT64 *Result)
RETURN_STATUS EFIAPI SafeUint32ToChar8(IN UINT32 Operand, OUT CHAR8 *Result)
RETURN_STATUS EFIAPI SafeInt16Mult(IN INT16 Multiplicand, IN INT16 Multiplier, OUT INT16 *Result)
RETURN_STATUS EFIAPI SafeInt32ToUint8(IN INT32 Operand, OUT UINT8 *Result)
RETURN_STATUS EFIAPI SafeIntnToUint8(IN INTN Operand, OUT UINT8 *Result)
RETURN_STATUS EFIAPI SafeUint64Sub(IN UINT64 Minuend, IN UINT64 Subtrahend, OUT UINT64 *Result)
RETURN_STATUS EFIAPI SafeInt8Add(IN INT8 Augend, IN INT8 Addend, OUT INT8 *Result)
RETURN_STATUS EFIAPI SafeInt64ToInt8(IN INT64 Operand, OUT INT8 *Result)
RETURN_STATUS EFIAPI SafeUint64Add(IN UINT64 Augend, IN UINT64 Addend, OUT UINT64 *Result)
RETURN_STATUS EFIAPI SafeInt16ToUint8(IN INT16 Operand, OUT UINT8 *Result)
RETURN_STATUS EFIAPI SafeUint32ToUint16(IN UINT32 Operand, OUT UINT16 *Result)
RETURN_STATUS EFIAPI SafeInt16ToInt8(IN INT16 Operand, OUT INT8 *Result)
RETURN_STATUS EFIAPI SafeInt32ToInt8(IN INT32 Operand, OUT INT8 *Result)
RETURN_STATUS EFIAPI SafeUintnToChar8(IN UINTN Operand, OUT CHAR8 *Result)
RETURN_STATUS EFIAPI SafeInt64ToChar8(IN INT64 Operand, OUT CHAR8 *Result)
RETURN_STATUS EFIAPI SafeUint64Mult(IN UINT64 Multiplicand, IN UINT64 Multiplier, OUT UINT64 *Result)
RETURN_STATUS EFIAPI SafeIntnToUint64(IN INTN Operand, OUT UINT64 *Result)
RETURN_STATUS EFIAPI SafeUint32ToInt8(IN UINT32 Operand, OUT INT8 *Result)
RETURN_STATUS EFIAPI SafeInt8ToUint8(IN INT8 Operand, OUT UINT8 *Result)
RETURN_STATUS EFIAPI SafeUint8Mult(IN UINT8 Multiplicand, IN UINT8 Multiplier, OUT UINT8 *Result)
RETURN_STATUS EFIAPI SafeInt64Add(IN INT64 Augend, IN INT64 Addend, OUT INT64 *Result)
RETURN_STATUS EFIAPI SafeUint16ToChar8(IN UINT16 Operand, OUT CHAR8 *Result)
RETURN_STATUS EFIAPI SafeInt8ToUint32(IN INT8 Operand, OUT UINT32 *Result)
RETURN_STATUS EFIAPI SafeInt64ToUint64(IN INT64 Operand, OUT UINT64 *Result)
RETURN_STATUS EFIAPI SafeInt8Sub(IN INT8 Minuend, IN INT8 Subtrahend, OUT INT8 *Result)
RETURN_STATUS EFIAPI SafeUint16ToInt8(IN UINT16 Operand, OUT INT8 *Result)
RETURN_STATUS EFIAPI SafeUint64ToInt64(IN UINT64 Operand, OUT INT64 *Result)
RETURN_STATUS EFIAPI SafeInt32ToChar8(IN INT32 Operand, OUT CHAR8 *Result)
RETURN_STATUS EFIAPI SafeInt32ToUint16(IN INT32 Operand, OUT UINT16 *Result)
RETURN_STATUS EFIAPI SafeUint32Sub(IN UINT32 Minuend, IN UINT32 Subtrahend, OUT UINT32 *Result)
RETURN_STATUS EFIAPI SafeInt64ToUint8(IN INT64 Operand, OUT UINT8 *Result)
RETURN_STATUS EFIAPI SafeUintnToInt16(IN UINTN Operand, OUT INT16 *Result)
RETURN_STATUS EFIAPI SafeInt16Sub(IN INT16 Minuend, IN INT16 Subtrahend, OUT INT16 *Result)
RETURN_STATUS EFIAPI SafeInt64ToUint16(IN INT64 Operand, OUT UINT16 *Result)
RETURN_STATUS EFIAPI SafeUint16ToUint8(IN UINT16 Operand, OUT UINT8 *Result)
RETURN_STATUS EFIAPI SafeIntnToUint16(IN INTN Operand, OUT UINT16 *Result)
RETURN_STATUS EFIAPI SafeUint32ToInt16(IN UINT32 Operand, OUT INT16 *Result)
RETURN_STATUS EFIAPI SafeUint64ToInt16(IN UINT64 Operand, OUT INT16 *Result)
RETURN_STATUS EFIAPI SafeIntnToUintn(IN INTN Operand, OUT UINTN *Result)
RETURN_STATUS EFIAPI SafeInt8ToUint16(IN INT8 Operand, OUT UINT16 *Result)
RETURN_STATUS EFIAPI SafeInt16ToUint16(IN INT16 Operand, OUT UINT16 *Result)
RETURN_STATUS EFIAPI SafeUint32ToUint8(IN UINT32 Operand, OUT UINT8 *Result)
RETURN_STATUS EFIAPI SafeUintnToUint8(IN UINTN Operand, OUT UINT8 *Result)
RETURN_STATUS EFIAPI SafeUint64ToUint32(IN UINT64 Operand, OUT UINT32 *Result)
RETURN_STATUS EFIAPI SafeUint8Add(IN UINT8 Augend, IN UINT8 Addend, OUT UINT8 *Result)
RETURN_STATUS EFIAPI SafeInt16Add(IN INT16 Augend, IN INT16 Addend, OUT INT16 *Result)
RETURN_STATUS EFIAPI SafeUint8ToChar8(IN UINT8 Operand, OUT CHAR8 *Result)
RETURN_STATUS EFIAPI SafeInt32Add(IN INT32 Augend, IN INT32 Addend, OUT INT32 *Result)
RETURN_STATUS EFIAPI SafeInt64Sub(IN INT64 Minuend, IN INT64 Subtrahend, OUT INT64 *Result)
EFI_STATUS EFIAPI UefiTestMain(VOID)
EFI_STATUS EFIAPI RunAllTestSuites(IN UNIT_TEST_FRAMEWORK_HANDLE FrameworkHandle)
#define UT_ASSERT_EQUAL(ValueA, ValueB)
EFI_STATUS EFIAPI CreateUnitTestSuite(OUT UNIT_TEST_SUITE_HANDLE *SuiteHandle, IN UNIT_TEST_FRAMEWORK_HANDLE FrameworkHandle, IN CHAR8 *Title, IN CHAR8 *Name, IN UNIT_TEST_SUITE_SETUP Setup OPTIONAL, IN UNIT_TEST_SUITE_TEARDOWN Teardown OPTIONAL)
EFI_STATUS EFIAPI FreeUnitTestFramework(IN UNIT_TEST_FRAMEWORK_HANDLE FrameworkHandle)
EFI_STATUS EFIAPI AddTestCase(IN UNIT_TEST_SUITE_HANDLE SuiteHandle, IN CHAR8 *Description, IN CHAR8 *Name, IN UNIT_TEST_FUNCTION Function, IN UNIT_TEST_PREREQUISITE Prerequisite OPTIONAL, IN UNIT_TEST_CLEANUP CleanUp OPTIONAL, IN UNIT_TEST_CONTEXT Context OPTIONAL)
EFI_STATUS EFIAPI InitUnitTestFramework(OUT UNIT_TEST_FRAMEWORK_HANDLE *FrameworkHandle, IN CHAR8 *Title, IN CHAR8 *ShortTitle, IN CHAR8 *VersionString)
#define UT_ASSERT_NOT_EFI_ERROR(Status)
EFI_STATUS EFIAPI DxeEntryPoint(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
EFI_STATUS EFIAPI PeiEntryPoint(IN EFI_PEI_FILE_HANDLE FileHandle, IN CONST EFI_PEI_SERVICES **PeiServices)