7983
|
1 |
#include <check.h>
|
|
2 |
#include <stdlib.h>
|
|
3 |
#include <stdio.h>
|
|
4 |
#include "check_check.h"
|
|
5 |
#include "../src/fpcrtl.h"
|
|
6 |
|
|
7 |
typedef struct __TResourceList
|
|
8 |
{
|
10015
|
9 |
Integer count;
|
|
10 |
string255 files[500 + 1];
|
7983
|
11 |
} TResourceList;
|
|
12 |
|
|
13 |
string255 t = STRINIT("test");
|
|
14 |
string255 Pathz[1] =
|
|
15 |
{ STRINIT("../../") };
|
|
16 |
int ptCurrTheme = 0;
|
|
17 |
string255 cThemeCFGFilename = STRINIT("theme.cfg");
|
|
18 |
const string255 __str79 = STRINIT("object");
|
|
19 |
string255 c1 = STRINIT("=");
|
|
20 |
string255 c2 = STRINIT("\x2c");
|
|
21 |
string255 c3 = STRINIT("\x2f");
|
|
22 |
|
|
23 |
static string255 make_string(const char* str)
|
|
24 |
{
|
10015
|
25 |
string255 s;
|
|
26 |
s.len = strlen(str);
|
|
27 |
memcpy(s.str, str, s.len + 1);
|
|
28 |
return s;
|
7983
|
29 |
}
|
|
30 |
|
|
31 |
TResourceList readThemeCfg_0()
|
|
32 |
{
|
10015
|
33 |
TResourceList readthemecfg_result;
|
|
34 |
string255 s;
|
|
35 |
string255 key;
|
|
36 |
TextFile f;
|
|
37 |
Integer i;
|
|
38 |
TResourceList res;
|
7983
|
39 |
|
10015
|
40 |
s = _strconcat(_strappend(Pathz[ptCurrTheme], '\x2f'), cThemeCFGFilename);
|
|
41 |
//umisc_log(s);
|
7983
|
42 |
|
10015
|
43 |
fpcrtl_assign(f, s);
|
7983
|
44 |
|
10015
|
45 |
FileMode = 0;
|
|
46 |
fpcrtl_reset(f);
|
7983
|
47 |
|
10015
|
48 |
res.count = 0;
|
|
49 |
while (!(fpcrtl_eof(f)))
|
|
50 |
{
|
|
51 |
fpcrtl_readLnS(f, s);
|
|
52 |
if ((fpcrtl_Length(s)) == (0))
|
|
53 |
{
|
|
54 |
continue;
|
|
55 |
}
|
|
56 |
if ((s.s[1]) == ('\x3b'))
|
|
57 |
{
|
|
58 |
continue;
|
|
59 |
}
|
|
60 |
i = fpcrtl_pos('\x3d', s);
|
|
61 |
key = fpcrtl_trim(fpcrtl_copy(s, 1, i - 1));
|
|
62 |
fpcrtl_delete(s, 1, i);
|
|
63 |
if (_strcompare(key, __str79))
|
|
64 |
{
|
|
65 |
i = fpcrtl_pos('\x2c', s);
|
|
66 |
res.files[res.count] = _strconcat(
|
|
67 |
_strappend(Pathz[ptCurrTheme], '\x2f'),
|
|
68 |
fpcrtl_trim(fpcrtl_copy(s, 1, i - 1)));
|
|
69 |
++res.count;
|
|
70 |
//umisc_log(fpcrtl_trim(fpcrtl_copy(s, 1, i - 1)));
|
|
71 |
}
|
|
72 |
}
|
|
73 |
fpcrtl_close(f);
|
|
74 |
readthemecfg_result = res;
|
|
75 |
return readthemecfg_result;
|
7983
|
76 |
}
|
|
77 |
|
|
78 |
START_TEST(test_readthemecfg)
|
10015
|
79 |
{
|
|
80 |
int i;
|
|
81 |
TResourceList result;
|
7983
|
82 |
|
10015
|
83 |
printf("-----Entering test readthemecfg-----\n");
|
|
84 |
result = readThemeCfg_0();
|
|
85 |
for (i = 0; i < result.count; i++)
|
|
86 |
{
|
|
87 |
printf("%s\n", result.files[i].str);
|
|
88 |
}
|
|
89 |
printf("-----Leaving test readthemecfg-----\n");
|
|
90 |
}END_TEST
|
7983
|
91 |
|
|
92 |
Suite* fileio_suite(void)
|
|
93 |
{
|
10015
|
94 |
Suite *s = suite_create("fileio");
|
7983
|
95 |
|
10015
|
96 |
TCase *tc_core = tcase_create("Core");
|
7983
|
97 |
|
10015
|
98 |
tcase_add_test(tc_core, test_readthemecfg);
|
7983
|
99 |
|
10015
|
100 |
suite_add_tcase(s, tc_core);
|
7983
|
101 |
|
10015
|
102 |
return s;
|
7983
|
103 |
}
|