0 | 0 |
package ini
|
1 | 1 |
|
2 | 2 |
import (
|
|
3 |
"bufio"
|
3 | 4 |
"io/ioutil"
|
|
5 |
"os"
|
|
6 |
"strings"
|
4 | 7 |
"testing"
|
5 | |
"strings"
|
6 | |
"bufio"
|
7 | 8 |
)
|
8 | 9 |
|
9 | 10 |
var (
|
|
18 | 19 |
func TestLoad(t *testing.T) {
|
19 | 20 |
if err != nil {
|
20 | 21 |
t.Error("Example: load error:", err)
|
|
22 |
}
|
|
23 |
}
|
|
24 |
|
|
25 |
func TestLoadFileWithSpaces(t *testing.T) {
|
|
26 |
if err := ioutil.WriteFile("testLoadFileWithSpaces.ini", []byte(" "), 0777); err != nil {
|
|
27 |
t.Error("Unable to write test file")
|
|
28 |
}
|
|
29 |
defer os.Remove("testLoadFileWithSpaces.ini")
|
|
30 |
|
|
31 |
if _, err := Load("testLoadFileWithSpaces.ini"); err != nil {
|
|
32 |
t.Error("Load: Couldn't load ini file with line consisting only of spaces.")
|
21 | 33 |
}
|
22 | 34 |
}
|
23 | 35 |
|
|
161 | 173 |
}
|
162 | 174 |
s, found := d2.GetString("section1", "key1")
|
163 | 175 |
if !found || s != "value2" {
|
164 | |
t.Error("Stringify failed for section1, key1")
|
|
176 |
t.Error("Stringify failed for section1, key1")
|
165 | 177 |
}
|
166 | 178 |
i, found := d2.GetInt("section1", "key2")
|
167 | 179 |
if !found || i != 5 {
|
168 | |
t.Error("Stringify failed for section1, key2")
|
|
180 |
t.Error("Stringify failed for section1, key2")
|
169 | 181 |
}
|
170 | 182 |
db, found := d2.GetDouble("section1", "key3")
|
171 | 183 |
if !found || db != 1.3 {
|
172 | |
t.Error("Stringify failed for section1, key3")
|
|
184 |
t.Error("Stringify failed for section1, key3")
|
173 | 185 |
}
|
174 | 186 |
db, found = d2.GetDouble("section2", "key1")
|
175 | 187 |
if !found || db != 5.0 {
|
176 | |
t.Error("Stringify failed for section2, key1")
|
|
188 |
t.Error("Stringify failed for section2, key1")
|
177 | 189 |
}
|
178 | 190 |
}
|