-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfileA_suite.c
More file actions
56 lines (47 loc) · 1.33 KB
/
fileA_suite.c
File metadata and controls
56 lines (47 loc) · 1.33 KB
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#include "CUnit/Basic.h"
#include "fileA.h"
/* The suite initialization function.
* Returns zero on success, non-zero otherwise.
*/
int init_suite_fileA(void) {
/*
* if (problem during initialisation)
* return -1; // this number can be used to explicit the problem
*/
return 0;
}
/* The suite cleanup function.
* Returns zero on success, non-zero otherwise.
*/
int clean_suite_fileA(void) {
/*
* if (problem during cleaning)
* return -1; // this number can be used to explicit the problem
*/
return 0;
}
/* A test
*/
void testNormalValues(void) {
/* classic cases */
CU_ASSERT_EQUAL(simpleDivision(1, 1), 1);
CU_ASSERT_EQUAL(simpleDivision(100, 10), 10);
CU_ASSERT_EQUAL(simpleDivision(42, 6), 7);
/* non integer result should be floored */
CU_ASSERT_EQUAL(simpleDivision(5, 3), 1);
CU_ASSERT_EQUAL(simpleDivision(14, 4), 3);
}
/* Another test
*/
void testErrorValues(void) {
/* division by 0 should return -1 */
CU_ASSERT_EQUAL(simpleDivision(1, 0), -1);
CU_ASSERT_EQUAL(simpleDivision(427, 0), -1);
/* strange cases */
CU_ASSERT_EQUAL(simpleDivision(0, 0), -1);
CU_ASSERT_EQUAL(simpleDivision(0, 1), 0);
/* use of negative number should return -2 */
CU_ASSERT_EQUAL(simpleDivision(-63, 39), -2);
CU_ASSERT_EQUAL(simpleDivision(78, -36), -2);
CU_ASSERT_EQUAL(simpleDivision(-43, -23), -2);
}