Commit | Line | Data |
---|---|---|
81923e5c BA |
1 | #include "TimeSeries/serialize.h" |
2 | #include "lut.h" | |
3 | #include <unistd.h> | |
4 | #include <stdio.h> | |
5 | ||
6 | static void checkFilesEqual(const char* fileName1, const char* fileName2) | |
7 | { | |
8 | FILE* output = fopen(fileName1, "rb"); | |
9 | FILE* refOutput = fopen(fileName2, "rb"); | |
10 | while (!feof(output) && !feof(refOutput)) | |
11 | LUT_ASSERT(fgetc(output) == fgetc(refOutput)); | |
12 | LUT_ASSERT(feof(output) && feof(refOutput)); | |
13 | fclose(output); | |
14 | fclose(refOutput); | |
15 | } | |
16 | ||
17 | void t_serialize1() | |
18 | { | |
19 | const char* csvIfName = "../data/test/sample_byCols.csv"; | |
20 | const char* binaryIfName = "../data/test/sample_byCols.bin"; | |
21 | const char* tmpBinaryIfName = "../data/test/sample_byCols.tmp.bin"; | |
22 | ||
23 | // serialize text file into a temporary binary file | |
24 | serialize_byCols(csvIfName, tmpBinaryIfName, 0); | |
25 | ||
26 | // compare binary result with reference | |
27 | checkFilesEqual(tmpBinaryIfName, binaryIfName); | |
28 | ||
29 | // remove temp file | |
30 | unlink(tmpBinaryIfName); | |
31 | } | |
32 | ||
33 | void t_serialize2() | |
34 | { | |
35 | const char* csvIfName = "../data/test/sample_byRows.csv"; | |
36 | const char* binaryIfName = "../data/test/sample_byRows.bin"; | |
37 | const char* tmpBinaryIfName = "../data/test/sample_byRows.tmp.bin"; | |
38 | ||
39 | // serialize text file into a temporary binary file | |
40 | serialize_byRows(csvIfName, tmpBinaryIfName, 0); | |
41 | ||
42 | // compare binary result with reference | |
43 | checkFilesEqual(tmpBinaryIfName, binaryIfName); | |
44 | ||
45 | // remove temp file | |
46 | unlink(tmpBinaryIfName); | |
47 | } |