Test: Add Log 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 133
diff --git a/test/testautomation_math.c b/test/testautomation_math.c
index 95243b4..bb50f3a 100644
--- a/test/testautomation_math.c
+++ b/test/testautomation_math.c
@@ -962,6 +962,92 @@ exp_regularCases(void *args)
return helper_dtod("Exp", SDL_exp, regular_cases, SDL_arraysize(regular_cases));
}
+/* SDL_log tests functions */
+
+/**
+ * \brief Checks limits (zeros and positive infinity).
+ */
+static int
+log_limitCases(void *args)
+{
+ double result;
+
+ result = SDL_log(INFINITY);
+ SDLTest_AssertCheck(INFINITY == result,
+ "Log(%f), expected %f, got %f",
+ INFINITY, INFINITY, result);
+
+ result = SDL_log(0.0);
+ SDLTest_AssertCheck(-INFINITY == result,
+ "Log(%f), expected %f, got %f",
+ 0.0, -INFINITY, result);
+
+ result = SDL_log(-0.0);
+ SDLTest_AssertCheck(-INFINITY == result,
+ "Log(%f), expected %f, got %f",
+ -0.0, -INFINITY, result);
+
+ return TEST_COMPLETED;
+}
+
+/**
+ * \brief Checks some base cases.
+ */
+static int
+log_baseCases(void *args)
+{
+ double result;
+
+ result = SDL_log(1.0);
+ SDLTest_AssertCheck(0.0 == result,
+ "Log(%f), expected %f, got %f",
+ 1.0, 0.0, result);
+
+ result = SDL_log(EULER);
+ SDLTest_AssertCheck(1.0 == result,
+ "Log(%f), expected %f, got %f",
+ EULER, 1.0, result);
+
+ return TEST_COMPLETED;
+}
+
+/**
+ * \brief Checks the nan cases.
+ */
+static int
+log_nanCases(void *args)
+{
+ double result;
+
+ result = SDL_log(NAN);
+ SDLTest_AssertCheck(isnan(result),
+ "Log(%f), expected %f, got %f",
+ NAN, NAN, result);
+
+ result = SDL_log(-1234.5678);
+ SDLTest_AssertCheck(isnan(result),
+ "Log(%f), expected %f, got %f",
+ -1234.5678, NAN, result);
+
+ return TEST_COMPLETED;
+}
+
+/**
+ * \brief Checks a set of regular cases.
+ */
+static int
+log_regularCases(void *args)
+{
+ const d_to_d regular_cases[] = {
+ { 5.0, 1.60943791243410028179994242236716672778129577636718750 },
+ { 10.0, 2.302585092994045901093613792909309267997741699218750 },
+ { 56.32, 4.031049711849786554296315443934872746467590332031250 },
+ { 789.123, 6.670922202231861497523368598194792866706848144531250 },
+ { 2734.876324, 7.91384149408957959792587644187733530998229980468750 }
+ };
+ return helper_dtod("Log", SDL_log, regular_cases, SDL_arraysize(regular_cases));
+}
+
/* ================= Test References ================== */
/* SDL_floor test cases */
@@ -1164,6 +1250,25 @@ static const SDLTest_TestCaseReference expTestRegular = {
"Check a set of regular values", TEST_ENABLED
};
+/* SDL_log test cases */
+
+static const SDLTest_TestCaseReference logTestLimit = {
+ (SDLTest_TestCaseFp) log_limitCases, "log_limitCases",
+ "Check for limits", TEST_ENABLED
+};
+static const SDLTest_TestCaseReference logTestNan = {
+ (SDLTest_TestCaseFp) log_nanCases, "log_nanCases",
+ "Check for the nan cases", TEST_ENABLED
+};
+static const SDLTest_TestCaseReference logTestBase = {
+ (SDLTest_TestCaseFp) log_baseCases, "log_baseCases",
+ "Check for base cases", TEST_ENABLED
+};
+static const SDLTest_TestCaseReference logTestRegular = {
+ (SDLTest_TestCaseFp) log_regularCases, "log_regularCases",
+ "Check a set of regular values", TEST_ENABLED
+};
+
static const SDLTest_TestCaseReference *mathTests[] = {
&floorTestInf, &floorTestZero, &floorTestNan,
&floorTestRound, &floorTestFraction, &floorTestRange,
@@ -1187,6 +1292,9 @@ static const SDLTest_TestCaseReference *mathTests[] = {
&expTestInf, &expTestZero, &expTestOverflow,
&expTestBase, &expTestRegular,
+ &logTestLimit, &logTestNan,
+ &logTestBase, &logTestRegular,
+
NULL
};