Test: Add Log10 tests to math suite.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132
diff --git a/test/testautomation_math.c b/test/testautomation_math.c
index bb50f3a..957c86c 100644
--- a/test/testautomation_math.c
+++ b/test/testautomation_math.c
@@ -1048,6 +1048,91 @@ log_regularCases(void *args)
return helper_dtod("Log", SDL_log, regular_cases, SDL_arraysize(regular_cases));
}
+/* SDL_log10 tests functions */
+
+/**
+ * \brief Checks limits (zeros and positive infinity).
+ */
+static int
+log10_limitCases(void *args)
+{
+ double result;
+
+ result = SDL_log10(INFINITY);
+ SDLTest_AssertCheck(INFINITY == result,
+ "Log10(%f), expected %f, got %f",
+ INFINITY, INFINITY, result);
+
+ result = SDL_log10(0.0);
+ SDLTest_AssertCheck(-INFINITY == result,
+ "Log10(%f), expected %f, got %f",
+ 0.0, -INFINITY, result);
+
+ result = SDL_log10(-0.0);
+ SDLTest_AssertCheck(-INFINITY == result,
+ "Log10(%f), expected %f, got %f",
+ -0.0, -INFINITY, result);
+
+ return TEST_COMPLETED;
+}
+
+/**
+ * \brief Checks some base cases.
+ */
+static int
+log10_baseCases(void *args)
+{
+ const d_to_d base_cases[] = {
+ { 1.0, 0.0 },
+ { 10.0, 1.0 },
+ { 100.0, 2.0 },
+ { 1000.0, 3.0 },
+ { 10000.0, 4.0 },
+ { 100000.0, 5.0 },
+ { 1000000.0, 6.0 },
+ { 10000000.0, 7.0 },
+ { 100000000.0, 8.0 },
+ { 1000000000.0, 9.0 },
+ };
+ return helper_dtod("Log10", SDL_log10, base_cases, SDL_arraysize(base_cases));
+}
+
+/**
+ * \brief Checks the nan cases.
+ */
+static int
+log10_nanCases(void *args)
+{
+ double result;
+
+ result = SDL_log10(NAN);
+ SDLTest_AssertCheck(isnan(result),
+ "Log10(%f), expected %f, got %f",
+ NAN, NAN, result);
+
+ result = SDL_log10(-1234.5678);
+ SDLTest_AssertCheck(isnan(result),
+ "Log10(%f), expected %f, got %f",
+ -1234.5678, NAN, result);
+
+ return TEST_COMPLETED;
+}
+
+/**
+ * \brief Checks a set of regular cases.
+ */
+static int
+log10_regularCases(void *args)
+{
+ const d_to_d regular_cases[] = {
+ { 5.0, 0.698970004336018857493684208748163655400276184082031250 },
+ { 12.5, 1.09691001300805646145875016372883692383766174316406250 },
+ { 56.32, 1.750662646134055755453573510749265551567077636718750 },
+ { 789.123, 2.8971447016351858927407647570362314581871032714843750 },
+ { 2734.876324, 3.436937691540090433761633903486654162406921386718750 }
+ };
+ return helper_dtod("Log10", SDL_log10, regular_cases, SDL_arraysize(regular_cases));
+}
/* ================= Test References ================== */
/* SDL_floor test cases */
@@ -1269,6 +1354,25 @@ static const SDLTest_TestCaseReference logTestRegular = {
"Check a set of regular values", TEST_ENABLED
};
+/* SDL_log10 test cases */
+
+static const SDLTest_TestCaseReference log10TestLimit = {
+ (SDLTest_TestCaseFp) log10_limitCases, "log10_limitCases",
+ "Check for limits", TEST_ENABLED
+};
+static const SDLTest_TestCaseReference log10TestNan = {
+ (SDLTest_TestCaseFp) log10_nanCases, "log10_nanCases",
+ "Check for the nan cases", TEST_ENABLED
+};
+static const SDLTest_TestCaseReference log10TestBase = {
+ (SDLTest_TestCaseFp) log10_baseCases, "log10_baseCases",
+ "Check for base cases", TEST_ENABLED
+};
+static const SDLTest_TestCaseReference log10TestRegular = {
+ (SDLTest_TestCaseFp) log10_regularCases, "log10_regularCases",
+ "Check a set of regular values", TEST_ENABLED
+};
+
static const SDLTest_TestCaseReference *mathTests[] = {
&floorTestInf, &floorTestZero, &floorTestNan,
&floorTestRound, &floorTestFraction, &floorTestRange,
@@ -1295,6 +1399,9 @@ static const SDLTest_TestCaseReference *mathTests[] = {
&logTestLimit, &logTestNan,
&logTestBase, &logTestRegular,
+ &log10TestLimit, &log10TestNan,
+ &log10TestBase, &log10TestRegular,
+
NULL
};