From 00d252c60b31b2633401bb263b8b2c1e93e5b871 Mon Sep 17 00:00:00 2001 From: fdai7968 Date: Thu, 8 Feb 2024 16:44:31 +0000 Subject: [PATCH] Update test/trig_functions/test_trig_functions.c --- test/trig_functions/test_trig_functions.c | 30 +++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/test/trig_functions/test_trig_functions.c b/test/trig_functions/test_trig_functions.c index 8b13789..115d0c9 100644 --- a/test/trig_functions/test_trig_functions.c +++ b/test/trig_functions/test_trig_functions.c @@ -1 +1,31 @@ +#include "unity.h" +#include "trig_functions.h" +#define PI 3.14159265 +void setUp(void){} + +void tearDown(void){} + +void test_sin() { + TEST_ASSERT_EQUAL_DOUBLE(0.0, calculate_sin(0)); + TEST_ASSERT_EQUAL_DOUBLE(1.0, calculate_sin(PI/2)); + TEST_ASSERT_EQUAL_DOUBLE(0.0, calculate_sin(PI)); + TEST_ASSERT_EQUAL_DOUBLE(-1.0, calculate_sin(3*PI/2)); + TEST_ASSERT_EQUAL_DOUBLE(0.0, calculate_sin(2*PI)); +} + +void test_cos() { + TEST_ASSERT_EQUAL_DOUBLE(1.0, calculate_cos(0)); + TEST_ASSERT_EQUAL_DOUBLE(0.0, calculate_cos(PI/2)); + TEST_ASSERT_EQUAL_DOUBLE(-1.0, calculate_cos(PI)); + TEST_ASSERT_EQUAL_DOUBLE(0.0, calculate_cos(3*PI/2)); + TEST_ASSERT_EQUAL_DOUBLE(1.0, calculate_cos(2*PI)); +} + +void test_tan() { + TEST_ASSERT_EQUAL_DOUBLE(0.0, calculate_tan(0)); + TEST_ASSERT_EQUAL_DOUBLE(INFINITY, calculate_tan(PI/2)); // Tangens von 90 Grad ist unendlich + TEST_ASSERT_EQUAL_DOUBLE(0.0, calculate_tan(PI)); + TEST_ASSERT_EQUAL_DOUBLE(INFINITY, calculate_tan(3*PI/2)); // Tangens von 270 Grad ist unendlich + TEST_ASSERT_EQUAL_DOUBLE(0.0, calculate_tan(2*PI)); +}