-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Expand file tree
/
Copy pathtest_student.c
More file actions
31 lines (25 loc) · 784 Bytes
/
test_student.c
File metadata and controls
31 lines (25 loc) · 784 Bytes
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
// 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();
}