| 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 |
{ |
| 9 |
Integer count; |
| 10 |
string255 files[500 + 1]; |
| 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 |
{ |
| 25 |
string255 s; |
| 26 |
s.len = strlen(str); |
| 27 |
memcpy(s.str, str, s.len + 1); |
| 28 |
return s; |
| 29 |
} |
| 30 |
|
| 31 |
TResourceList readThemeCfg_0() |
| 32 |
{ |
| 33 |
TResourceList readthemecfg_result; |
| 34 |
string255 s; |
| 35 |
string255 key; |
| 36 |
TextFile f; |
| 37 |
Integer i; |
| 38 |
TResourceList res; |
| 39 |
|
| 40 |
s = _strconcat(_strappend(Pathz[ptCurrTheme], '\x2f'), cThemeCFGFilename); |
| 41 |
//umisc_log(s); |
| 42 |
|
| 43 |
fpcrtl_assign(f, s); |
| 44 |
|
| 45 |
FileMode = 0; |
| 46 |
fpcrtl_reset(f); |
| 47 |
|
| 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; |
| 76 |
} |
| 77 |
|
| 78 |
START_TEST(test_readthemecfg) |
| 79 |
{ |
| 80 |
int i; |
| 81 |
TResourceList result; |
| 82 |
|
| 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 |
| 91 |
|
| 92 |
Suite* fileio_suite(void) |
| 93 |
{ |
| 94 |
Suite *s = suite_create("fileio"); |
| 95 |
|
| 96 |
TCase *tc_core = tcase_create("Core"); |
| 97 |
|
| 98 |
tcase_add_test(tc_core, test_readthemecfg); |
| 99 |
|
| 100 |
suite_add_tcase(s, tc_core); |
| 101 |
|
| 102 |
return s; |
| 103 |
} |