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