| 1 |
package config |
| 2 |
|
| 3 |
type Fixture struct { |
| 4 |
Text string |
| 5 |
Raw string |
| 6 |
Config *Config |
| 7 |
} |
| 8 |
|
| 9 |
var fixtures = []*Fixture{ |
| 10 |
{ |
| 11 |
Raw: "", |
| 12 |
Text: "", |
| 13 |
Config: New(), |
| 14 |
}, |
| 15 |
{ |
| 16 |
Raw: ";Comments only", |
| 17 |
Text: "", |
| 18 |
Config: New(), |
| 19 |
}, |
| 20 |
{ |
| 21 |
Raw: "#Comments only", |
| 22 |
Text: "", |
| 23 |
Config: New(), |
| 24 |
}, |
| 25 |
{ |
| 26 |
Raw: "[core]\nrepositoryformatversion=0", |
| 27 |
Text: "[core]\n\trepositoryformatversion = 0\n", |
| 28 |
Config: New().AddOption("core", "", "repositoryformatversion", "0"), |
| 29 |
}, |
| 30 |
{ |
| 31 |
Raw: "[core]\n\trepositoryformatversion = 0\n", |
| 32 |
Text: "[core]\n\trepositoryformatversion = 0\n", |
| 33 |
Config: New().AddOption("core", "", "repositoryformatversion", "0"), |
| 34 |
}, |
| 35 |
{ |
| 36 |
Raw: ";Commment\n[core]\n;Comment\nrepositoryformatversion = 0\n", |
| 37 |
Text: "[core]\n\trepositoryformatversion = 0\n", |
| 38 |
Config: New().AddOption("core", "", "repositoryformatversion", "0"), |
| 39 |
}, |
| 40 |
{ |
| 41 |
Raw: "#Commment\n#Comment\n[core]\n#Comment\nrepositoryformatversion = 0\n", |
| 42 |
Text: "[core]\n\trepositoryformatversion = 0\n", |
| 43 |
Config: New().AddOption("core", "", "repositoryformatversion", "0"), |
| 44 |
}, |
| 45 |
{ |
| 46 |
Raw: `[section] |
| 47 |
option1 = "has # hash" |
| 48 |
option2 = "has \" quote" |
| 49 |
option3 = "has \\ backslash" |
| 50 |
option4 = "has ; semicolon" |
| 51 |
option5 = "has \n line-feed" |
| 52 |
option6 = "has \t tab" |
| 53 |
option7 = " has leading spaces" |
| 54 |
option8 = "has trailing spaces " |
| 55 |
option9 = has no special characters |
| 56 |
option10 = has unusual ` + "\x01\x7f\xc8\x80 characters\n", |
| 57 |
Text: `[section] |
| 58 |
option1 = "has # hash" |
| 59 |
option2 = "has \" quote" |
| 60 |
option3 = "has \\ backslash" |
| 61 |
option4 = "has ; semicolon" |
| 62 |
option5 = "has \n line-feed" |
| 63 |
option6 = "has \t tab" |
| 64 |
option7 = " has leading spaces" |
| 65 |
option8 = "has trailing spaces " |
| 66 |
option9 = has no special characters |
| 67 |
option10 = has unusual ` + "\x01\x7f\xc8\x80 characters\n", |
| 68 |
Config: New(). |
| 69 |
AddOption("section", "", "option1", `has # hash`). |
| 70 |
AddOption("section", "", "option2", `has " quote`). |
| 71 |
AddOption("section", "", "option3", `has \ backslash`). |
| 72 |
AddOption("section", "", "option4", `has ; semicolon`). |
| 73 |
AddOption("section", "", "option5", "has \n line-feed"). |
| 74 |
AddOption("section", "", "option6", "has \t tab"). |
| 75 |
AddOption("section", "", "option7", ` has leading spaces`). |
| 76 |
AddOption("section", "", "option8", `has trailing spaces `). |
| 77 |
AddOption("section", "", "option9", `has no special characters`). |
| 78 |
AddOption("section", "", "option10", "has unusual \x01\x7f\u0200 characters"), |
| 79 |
}, |
| 80 |
{ |
| 81 |
Raw: ` |
| 82 |
[sect1] |
| 83 |
opt1 = value1 |
| 84 |
[sect1 "subsect1"] |
| 85 |
opt2 = value2 |
| 86 |
`, |
| 87 |
Text: `[sect1] |
| 88 |
opt1 = value1 |
| 89 |
[sect1 "subsect1"] |
| 90 |
opt2 = value2 |
| 91 |
`, |
| 92 |
Config: New(). |
| 93 |
AddOption("sect1", "", "opt1", "value1"). |
| 94 |
AddOption("sect1", "subsect1", "opt2", "value2"), |
| 95 |
}, |
| 96 |
{ |
| 97 |
Raw: ` |
| 98 |
[sect1] |
| 99 |
opt1 = value1 |
| 100 |
[sect1 "subsect1"] |
| 101 |
opt2 = value2 |
| 102 |
[sect1] |
| 103 |
opt1 = value1b |
| 104 |
[sect1 "subsect1"] |
| 105 |
opt2 = value2b |
| 106 |
[sect1 "subsect2"] |
| 107 |
opt2 = value2 |
| 108 |
`, |
| 109 |
Text: `[sect1] |
| 110 |
opt1 = value1 |
| 111 |
opt1 = value1b |
| 112 |
[sect1 "subsect1"] |
| 113 |
opt2 = value2 |
| 114 |
opt2 = value2b |
| 115 |
[sect1 "subsect2"] |
| 116 |
opt2 = value2 |
| 117 |
`, |
| 118 |
Config: New(). |
| 119 |
AddOption("sect1", "", "opt1", "value1"). |
| 120 |
AddOption("sect1", "", "opt1", "value1b"). |
| 121 |
AddOption("sect1", "subsect1", "opt2", "value2"). |
| 122 |
AddOption("sect1", "subsect1", "opt2", "value2b"). |
| 123 |
AddOption("sect1", "subsect2", "opt2", "value2"), |
| 124 |
}, |
| 125 |
{ |
| 126 |
Raw: ` |
| 127 |
[sect1] |
| 128 |
opt1 = value1 |
| 129 |
opt1 = value2 |
| 130 |
`, |
| 131 |
Text: `[sect1] |
| 132 |
opt1 = value1 |
| 133 |
opt1 = value2 |
| 134 |
`, |
| 135 |
Config: New(). |
| 136 |
AddOption("sect1", "", "opt1", "value1"). |
| 137 |
AddOption("sect1", "", "opt1", "value2"), |
| 138 |
}, |
| 139 |
} |