Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create test_student. #751

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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();
}