From d7ec0b903c033d06548c93243a61eb0fbc057209 Mon Sep 17 00:00:00 2001 From: Zoro200454 Date: Mon, 9 Sep 2024 06:44:41 +0530 Subject: [PATCH] Create test_student.c --- test_student.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 test_student.c diff --git a/test_student.c b/test_student.c new file mode 100644 index 00000000..467d4264 --- /dev/null +++ b/test_student.c @@ -0,0 +1,31 @@ +// test_student.c + +#include "unity.h" +#include "student.h" // Your original code's header file + +void setUp(void) { + // Code to run before each test +} + +void tearDown(void) { + // Code to run after each test +} + +void test_calculate_percentage_all_same_marks(void) { + struct student s = {"John", {80, 80, 80, 80, 80}, 0.0}; + calculate_percentage(&s); + TEST_ASSERT_EQUAL_FLOAT(80.0, s.percentage); +} + +void test_calculate_percentage_different_marks(void) { + struct student s = {"Alice", {90, 80, 85, 70, 75}, 0.0}; + calculate_percentage(&s); + TEST_ASSERT_EQUAL_FLOAT(80.0, s.percentage); +} + +int main(void) { + UNITY_BEGIN(); + RUN_TEST(test_calculate_percentage_all_same_marks); + RUN_TEST(test_calculate_percentage_different_marks); + return UNITY_END(); +}