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