inifile_test.anubis
1.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
*Project* The Anubis Project
*Title* Tests of implementation of inifile
*Copyright* Copyright (c) David René 2006.
*Created: 2006 02 22
*Author* David René
Unit test of reading of inifile
read system/parameter/inifile.anubis
read tools/basis.anubis
read tools/streams.anubis
define One printIniFile (String fileName) =
// dumpIniInfo(loadIniFile(fileName))
print("start reading " + fileName + "\n");
with start_time = (UTime) unow,
forget(loadIniFile(fileName));
with time = (UTime) unow - start_time,
if time is utime(s,m) then
print("Parsing duration of " + fileName + " = " + to_decimal(s) + " sec " + to_decimal(m) + " microsecondes")
.
define String bool_to_string (Bool bool) =
if bool is false
then "false"
else "true".
define One testFile (One u) =
with config = loadIniFile("c:\\my_inifile.ini"),
print("TEST STRING FullName : " + readString(config, "NETWORK", "FullName", "N/A") + "\n");
print("TEST INT32 TcpPort : " + to_decimal(readInt(config, "NETWORK", "TcpPort", 4000)) + "\n");
print("TEST BOOL ShouldUpdate : " + bool_to_string(readBool(config, "NETWORK", "ShouldUpdate", false)) + "\n");
writeIniInfo(config, "c:\\my_inifile2.ini")
.
define One syntax =
print(" Usage: inifile_test <filename> ... <filename>\n")
.
global define One inifile_test ( List(String) args ) =
if args is
{
[ ] then testFile(unique),
[_ . _] then
map_forget(printIniFile,args)
}.