Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions test_student.c
Original file line number Diff line number Diff line change
@@ -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();
}