Skip to content

Commit 3de8f5b

Browse files
add cases to sample
1 parent 0f4e7c2 commit 3de8f5b

File tree

2 files changed

+82
-0
lines changed

2 files changed

+82
-0
lines changed

code/tests/cases/test_sample.c

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,52 @@ FOSSIL_TEST_CASE(test_should_not_run) {
7474
FOSSIL_TEST_ASSUME(1 == 0, "This test should not run");
7575
}
7676

77+
// A simple test case to check if input % 2 equals expected_output
78+
FOSSIL_TEST_CASE(test_input_modulo) {
79+
CSampleTestData data = { .input = 5, .expected_output = 1 };
80+
81+
int actual_output = data.input % 2;
82+
83+
FOSSIL_TEST_ASSUME(actual_output == data.expected_output, "Modulo test failed");
84+
}
85+
86+
// A simple test case to check if input squared equals expected_output
87+
FOSSIL_TEST_CASE(test_input_square) {
88+
CSampleTestData data = { .input = 3, .expected_output = 9 };
89+
90+
int actual_output = data.input * data.input;
91+
92+
FOSSIL_TEST_ASSUME(actual_output == data.expected_output, "Square test failed");
93+
}
94+
95+
// A simple test case to check if input is equal to expected_output
96+
FOSSIL_TEST_CASE(test_input_equal) {
97+
CSampleTestData data = { .input = 7, .expected_output = 7 };
98+
99+
int actual_output = data.input;
100+
101+
FOSSIL_TEST_ASSUME(actual_output == data.expected_output, "Equality test failed");
102+
}
103+
104+
FOSSIL_TEST_CASE(test_has_no_assertions) {
105+
// This test has no assertions
106+
}
107+
108+
FOSSIL_TEST_CASE(test_has_copy_assertions) {
109+
ASSUME_ITS_TRUE(1 == 1);
110+
ASSUME_ITS_TRUE(1 == 1);
111+
}
112+
77113
FOSSIL_TEST_GROUP(c_sample_test_cases) {
78114
FOSSIL_TEST_ADD(sample_suite, test_input_increment);
79115
FOSSIL_TEST_ADD(sample_suite, test_input_decrement);
80116
FOSSIL_TEST_ADD(sample_suite, test_input_double);
81117
FOSSIL_TEST_ADD(sample_suite, test_input_half);
118+
FOSSIL_TEST_ADD(sample_suite, test_input_modulo);
119+
FOSSIL_TEST_ADD(sample_suite, test_input_square);
120+
FOSSIL_TEST_ADD(sample_suite, test_input_equal);
121+
FOSSIL_TEST_ADD(sample_suite, test_has_no_assertions); // Should be detected as empty
122+
FOSSIL_TEST_ADD(sample_suite, test_has_copy_assertions); // Should be detected as a copy cat
82123

83124
FOSSIL_TEST_SKIP(test_should_not_run, "This test should not run");
84125

code/tests/cases/test_sample.cpp

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,52 @@ FOSSIL_TEST_CASE(cpp_test_should_not_run) {
7474
FOSSIL_TEST_ASSUME(1 == 0, "This test should not run");
7575
}
7676

77+
// A simple test case to check if input % 2 equals expected_output
78+
FOSSIL_TEST_CASE(cpp_test_input_modulo) {
79+
CppSampleTestData data = { 5, 1 };
80+
81+
int actual_output = data.input % 2;
82+
83+
FOSSIL_TEST_ASSUME(actual_output == data.expected_output, "Modulo test failed");
84+
}
85+
86+
// A simple test case to check if input squared equals expected_output
87+
FOSSIL_TEST_CASE(cpp_test_input_square) {
88+
CppSampleTestData data = { 3, 9 };
89+
90+
int actual_output = data.input * data.input;
91+
92+
FOSSIL_TEST_ASSUME(actual_output == data.expected_output, "Square test failed");
93+
}
94+
95+
// A simple test case to check if input is equal to expected_output
96+
FOSSIL_TEST_CASE(cpp_test_input_equal) {
97+
CppSampleTestData data = { 7, 7 };
98+
99+
int actual_output = data.input;
100+
101+
FOSSIL_TEST_ASSUME(actual_output == data.expected_output, "Equality test failed");
102+
}
103+
104+
FOSSIL_TEST_CASE(cpp_test_has_no_assertions) {
105+
// This test has no assertions
106+
}
107+
108+
FOSSIL_TEST_CASE(cpp_test_has_copy_assertions) {
109+
ASSUME_ITS_TRUE(1 == 1);
110+
ASSUME_ITS_TRUE(1 == 1);
111+
}
112+
77113
FOSSIL_TEST_GROUP(cpp_sample_test_cases) {
78114
FOSSIL_TEST_ADD(cpp_sample_suite, cpp_test_input_increment);
79115
FOSSIL_TEST_ADD(cpp_sample_suite, cpp_test_input_decrement);
80116
FOSSIL_TEST_ADD(cpp_sample_suite, cpp_test_input_double);
81117
FOSSIL_TEST_ADD(cpp_sample_suite, cpp_test_input_half);
118+
FOSSIL_TEST_ADD(cpp_sample_suite, cpp_test_input_modulo);
119+
FOSSIL_TEST_ADD(cpp_sample_suite, cpp_test_input_square);
120+
FOSSIL_TEST_ADD(cpp_sample_suite, cpp_test_input_equal);
121+
FOSSIL_TEST_ADD(cpp_sample_suite, cpp_test_has_no_assertions); // Should be detected as empty
122+
FOSSIL_TEST_ADD(cpp_sample_suite, cpp_test_has_copy_assertions); // Should be detected as a copy cat
82123

83124
FOSSIL_TEST_SKIP(cpp_test_should_not_run, "This test should not run");
84125

0 commit comments

Comments
 (0)