]> gitweb.factorcode.org Git - factor.git/blob - basis/ini-file/ini-file-tests.factor
Update actions, because Node.js 16 actions are deprecated, to Node.js 20
[factor.git] / basis / ini-file / ini-file-tests.factor
1 ! Copyright (C) 2010 John Benediktsson
2 ! See http://factorcode.org/license.txt for BSD license
3
4 USING: ini-file tools.test ;
5
6 { H{ } } [ "" string>ini ] unit-test
7
8 { H{ { "section" H{ } } } } [ "[section]" string>ini ] unit-test
9
10 { H{ { "section" H{ } } } } [ "[\"section\" ]" string>ini ] unit-test
11
12 { H{ { "   some name with spaces " H{ } } } }
13 [ "[ \"   some name with spaces \"]" string>ini ] unit-test
14
15 { H{ { "[]" H{ } } } } [ "[\\[\\]]" string>ini ] unit-test
16
17 { H{ { "foo" "bar" } } } [ "foo=bar" string>ini ] unit-test
18
19 { H{ { "foo" "bar" } { "baz" "quz" } } }
20 [ "foo=bar\nbaz= quz" string>ini ] unit-test
21
22 { H{ { "section" H{ { "foo" "abc def" } } } } }
23 [
24     "
25     [section]
26     foo = abc def
27     " string>ini
28 ] unit-test
29
30 { H{ { "section" H{ { "foo" "abc def" } } } } }
31 [
32     "
33     [section]
34     foo = abc    \\
35           \"def\"
36     " string>ini
37 ] unit-test
38
39 { H{ { "section" H{ { "foo" "abc def" } } } } }
40 [
41     "
42     [section]
43     foo = \"abc \" \\
44           def
45     " string>ini
46 ] unit-test
47
48 { H{ { "section" H{ { "foo" "abc def" } } } } }
49 [
50     "
51     [section]   foo = \"abc def\"
52     " string>ini
53 ] unit-test
54
55 { H{ { "section" H{ { "foo" "abc def" } } } } }
56 [
57     "
58     [section]   foo = abc \\
59     \"def\"
60     " string>ini
61 ] unit-test
62
63 { H{ { "section" H{ { "foo" "" } } } } }
64 [
65     "
66     [section]
67     foo=
68     " string>ini
69 ] unit-test
70
71 { H{ { "section" H{ { "foo" "" } } } } }
72 [
73     "
74     [section]
75     foo
76     " string>ini
77 ] unit-test
78
79 { H{ { "" H{ { "" "" } } } } }
80 [
81     "
82     []
83     =
84     " string>ini
85 ] unit-test
86
87 { H{ { "owner" H{ { "name" "John Doe" }
88                   { "organization" "Acme Widgets Inc." } } }
89      { "database" H{ { "server" "192.0.2.62" }
90                      { "port" "143" }
91                      { "file" "payroll.dat" } } } } }
92 [
93     "
94     ; last modified 1 April 2001 by John Doe
95     [owner]
96     name=John Doe
97     organization=Acme Widgets Inc.
98
99     [database]
100     server=192.0.2.62     ; use IP address in case network name resolution is not working
101     port=143
102     file = \"payroll.dat\"
103     " string>ini
104 ] unit-test
105
106 { H{ { "a long section name"
107        H{ { "a long key name" "a long value name" } } } } }
108 [
109     "
110     [a long section name ]
111     a long key name=  a long value name
112     " string>ini
113 ] unit-test
114
115 { H{ { "key with \n esc\ape \r codes \""
116        "value with \t esc\ape codes" } } }
117 [
118     "
119     key with \\n esc\\ape \\r codes \\\" = value with \\t esc\\ape codes
120     " string>ini
121 ] unit-test
122
123
124 { "key with \\n esc\\ape \\r codes \\\"=value with \\t esc\\ape codes\n" }
125 [
126     H{ { "key with \n esc\ape \r codes \""
127          "value with \t esc\ape codes" } } ini>string
128 ] unit-test