root / approxBasisSollya / test / test-read-lines / test-read-lines-suite-1.c
Historique | Voir | Annoter | Télécharger (3,54 ko)
1 | 301 | storres | /** @file test-read-lines-suite-1.c
|
---|---|---|---|
2 | 301 | storres | * Test the basic features of the read-lines library.
|
3 | 301 | storres | *
|
4 | 301 | storres | * @author ST
|
5 | 301 | storres | * @date 2018-03-14
|
6 | 301 | storres | *
|
7 | 301 | storres | */
|
8 | 301 | storres | /******************************************************************************/
|
9 | 301 | storres | |
10 | 301 | storres | /* includes of system headers */
|
11 | 301 | storres | #include <stdlib.h> |
12 | 301 | storres | #include <stdio.h> |
13 | 301 | storres | |
14 | 301 | storres | /* includes of project (CUnit) headers */
|
15 | 301 | storres | #include <CUnit.h> |
16 | 301 | storres | #include <Basic.h> |
17 | 301 | storres | |
18 | 301 | storres | /* includes of local (functions to test) headers */
|
19 | 301 | storres | #include<read-lines-from-file.h> |
20 | 301 | storres | |
21 | 301 | storres | /* Exportable prototypes (cleanup, init, setup, teardown and test functions),*/
|
22 | 301 | storres | |
23 | 301 | storres | /* The suite cleanup, init, setup, teardown functions (name used in
|
24 | 301 | storres | the driver program to build the suite). */
|
25 | 301 | storres | int
|
26 | 301 | storres | test_read_lines_suite_1_cleanup(void);
|
27 | 301 | storres | |
28 | 301 | storres | int
|
29 | 301 | storres | test_read_lines_suite_1_init(void);
|
30 | 301 | storres | |
31 | 301 | storres | void
|
32 | 301 | storres | test_read_lines_suite_1_setup(void);
|
33 | 301 | storres | |
34 | 301 | storres | void
|
35 | 301 | storres | test_read_lines_suite_1_teardown(void);
|
36 | 301 | storres | |
37 | 301 | storres | /* Test functions of the suite (one function per test in the suite,
|
38 | 301 | storres | names are used in the driver program to build the suite).*/
|
39 | 301 | storres | void
|
40 | 301 | storres | test_read_lines_suite_1_test_1(); |
41 | 301 | storres | |
42 | 301 | storres | void
|
43 | 301 | storres | test_read_lines_suite_1_test_2(); |
44 | 301 | storres | |
45 | 301 | storres | void
|
46 | 301 | storres | test_read_lines_suite_1_test_3(); |
47 | 301 | storres | |
48 | 301 | storres | void
|
49 | 301 | storres | test_read_lines_suite_1_test_4(); |
50 | 301 | storres | |
51 | 301 | storres | void
|
52 | 301 | storres | test_read_lines_suite_1_test_5(); |
53 | 301 | storres | |
54 | 301 | storres | /* The topmost part of the file is included by main program to initialize
|
55 | 301 | storres | data structures. The lower part is kept her to avoid double definitions.*/
|
56 | 301 | storres | #ifndef TEST_DRIVER
|
57 | 301 | storres | /* Internal prototypes */
|
58 | 301 | storres | |
59 | 301 | storres | /* Types, constants and macros definitions */
|
60 | 301 | storres | |
61 | 301 | storres | /* Global variables */
|
62 | 301 | storres | |
63 | 301 | storres | /* Function definitions */
|
64 | 301 | storres | |
65 | 301 | storres | /** Suite management functions. **/
|
66 | 301 | storres | int
|
67 | 301 | storres | test_read_lines_suite_1_cleanup() |
68 | 301 | storres | { |
69 | 301 | storres | return(0); |
70 | 301 | storres | } /* End test_read_lines_suite_1_cleanp() */
|
71 | 301 | storres | |
72 | 301 | storres | int
|
73 | 301 | storres | test_read_lines_suite_1_init(void)
|
74 | 301 | storres | { |
75 | 301 | storres | return(0); |
76 | 301 | storres | } /* End test_read_lines_suite_1_init. */
|
77 | 301 | storres | |
78 | 301 | storres | void
|
79 | 301 | storres | test_read_lines_suite_1_setup(void)
|
80 | 301 | storres | { |
81 | 301 | storres | } /* End test_read_lines_suite_1_setup. */
|
82 | 301 | storres | |
83 | 301 | storres | void
|
84 | 301 | storres | test_read_lines_suite_1_teardown(void)
|
85 | 301 | storres | { |
86 | 301 | storres | } /* End test_read_lines_suite_1_teardown. */
|
87 | 301 | storres | |
88 | 301 | storres | void
|
89 | 301 | storres | test_read_lines_suite_1_test_1() |
90 | 301 | storres | { |
91 | 301 | storres | rlff_readLines_t* linesRead = NULL;
|
92 | 301 | storres | |
93 | 301 | storres | linesRead = rlff_read_lines_from_file_name("non-existant-file.txt");
|
94 | 301 | storres | CU_ASSERT_PTR_NULL_FATAL(linesRead); |
95 | 301 | storres | } /* End test_read_lines_suite_1_test_1. */
|
96 | 301 | storres | |
97 | 301 | storres | void
|
98 | 301 | storres | test_read_lines_suite_1_test_2() |
99 | 301 | storres | { |
100 | 301 | storres | rlff_readLines_t* linesRead = NULL;
|
101 | 301 | storres | |
102 | 301 | storres | linesRead = rlff_read_lines_from_file_name("basis-01.txt");
|
103 | 301 | storres | CU_ASSERT_PTR_NOT_NULL_FATAL(linesRead); |
104 | 301 | storres | CU_ASSERT_EQUAL(linesRead->linesNum, 8);
|
105 | 301 | storres | CU_ASSERT_EQUAL(linesRead->linesLength, 9);
|
106 | 301 | storres | rlff_free_lines(linesRead); |
107 | 301 | storres | } /* End test_read_lines_suite_1_test_2. */
|
108 | 301 | storres | |
109 | 301 | storres | void
|
110 | 301 | storres | test_read_lines_suite_1_test_3() |
111 | 301 | storres | { |
112 | 301 | storres | rlff_readLines_t* linesRead = NULL;
|
113 | 301 | storres | |
114 | 301 | storres | linesRead = rlff_read_lines_from_file_name("basis-02.txt");
|
115 | 301 | storres | CU_ASSERT_PTR_NOT_NULL_FATAL(linesRead); |
116 | 301 | storres | CU_ASSERT_EQUAL(linesRead->linesNum, 8);
|
117 | 301 | storres | CU_ASSERT_EQUAL(linesRead->linesLength, 11);
|
118 | 301 | storres | rlff_free_lines(linesRead); |
119 | 301 | storres | } /* End test_read_lines_suite_1_test_3. */
|
120 | 301 | storres | |
121 | 301 | storres | void
|
122 | 301 | storres | test_read_lines_suite_1_test_4() |
123 | 301 | storres | { |
124 | 301 | storres | rlff_readLines_t* linesRead = NULL;
|
125 | 301 | storres | |
126 | 301 | storres | /* basis-03.txt is a zero-length file. */
|
127 | 301 | storres | linesRead = rlff_read_lines_from_file_name("basis-03.txt");
|
128 | 301 | storres | CU_ASSERT_PTR_NOT_NULL_FATAL(linesRead); |
129 | 301 | storres | CU_ASSERT_EQUAL(linesRead->linesNum, 0);
|
130 | 301 | storres | CU_ASSERT_EQUAL(linesRead->linesLength, 0);
|
131 | 301 | storres | rlff_free_lines(linesRead); |
132 | 301 | storres | } /* End test_read_lines_suite_1_test_4. */
|
133 | 301 | storres | |
134 | 301 | storres | void
|
135 | 301 | storres | test_read_lines_suite_1_test_5() |
136 | 301 | storres | { |
137 | 301 | storres | rlff_readLines_t* linesRead = NULL;
|
138 | 301 | storres | |
139 | 301 | storres | /* basis-04.txt is only made of a comment line starting with spaces. */
|
140 | 301 | storres | linesRead = rlff_read_lines_from_file_name("basis-04.txt");
|
141 | 301 | storres | CU_ASSERT_PTR_NOT_NULL_FATAL(linesRead); |
142 | 301 | storres | CU_ASSERT_EQUAL(linesRead->linesNum, 0);
|
143 | 301 | storres | CU_ASSERT_EQUAL(linesRead->linesLength, 0);
|
144 | 301 | storres | rlff_free_lines(linesRead); |
145 | 301 | storres | } /* End test_read_lines_suite_1_test_5. */
|
146 | 301 | storres | |
147 | 301 | storres | #endif |