From f2888c1f67cc0817299a8e2b370f3f61693bed3c Mon Sep 17 00:00:00 2001 From: Tibor Nagy Date: Tue, 6 Nov 2018 16:08:02 +0100 Subject: [PATCH] Add tests to check the existence of math constants --- tests/expected/math.stdout | 13 +++++++++++++ tests/math.c | 15 +++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/tests/expected/math.stdout b/tests/expected/math.stdout index 86541779..e0e3e365 100644 --- a/tests/expected/math.stdout +++ b/tests/expected/math.stdout @@ -1 +1,14 @@ +M_E = 2.7183 +M_LOG2E = 1.4427 +M_LOG10E = 0.4343 +M_LN2 = 0.6931 +M_LN10 = 2.3026 +M_PI = 3.1416 +M_PI_2 = 1.5708 +M_PI_4 = 0.7854 +M_1_PI = 0.3183 +M_2_PI = 0.6366 +M_2_SQRTPI = 1.1284 +M_SQRT2 = 1.4142 +M_SQRT1_2 = 0.7071 cos(3.140000) = -0.999999 diff --git a/tests/math.c b/tests/math.c index fb53fa24..c30c553d 100644 --- a/tests/math.c +++ b/tests/math.c @@ -2,6 +2,21 @@ #include int main(int argc, char ** argv) { + // Check the existence of math constants + printf("M_E = %.4f\n", M_E); + printf("M_LOG2E = %.4f\n", M_LOG2E); + printf("M_LOG10E = %.4f\n", M_LOG10E); + printf("M_LN2 = %.4f\n", M_LN2); + printf("M_LN10 = %.4f\n", M_LN10); + printf("M_PI = %.4f\n", M_PI); + printf("M_PI_2 = %.4f\n", M_PI_2); + printf("M_PI_4 = %.4f\n", M_PI_4); + printf("M_1_PI = %.4f\n", M_1_PI); + printf("M_2_PI = %.4f\n", M_2_PI); + printf("M_2_SQRTPI = %.4f\n", M_2_SQRTPI); + printf("M_SQRT2 = %.4f\n", M_SQRT2); + printf("M_SQRT1_2 = %.4f\n", M_SQRT1_2); + double pi = 3.14; float c = cos(pi); printf("cos(%f) = %f\n", pi, c); -- GitLab