testing passed successfully
This commit is contained in:
parent
7351a94b9f
commit
275832514e
33
README.md
33
README.md
|
@ -16,27 +16,32 @@ import std.stdio;
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
Config.file.read("./settings.conf");
|
rc.read("./settings.conf");
|
||||||
|
|
||||||
foreach (key, param; Config.file.keys())
|
foreach (key, param; rc.sn.keys())
|
||||||
writefln("%s => %s", key, param);
|
writefln("%s => %s", key, param);
|
||||||
|
|
||||||
writeln(Config.file.key("value1"));
|
writeln(rc.sn.key("value1"));
|
||||||
|
|
||||||
|
foreach (key, param; rc.sn("part2").keys())
|
||||||
|
writefln("%s => %s", key, param);
|
||||||
|
|
||||||
|
writeln(rc.sn("part2").key("value1"));
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
Result:
|
Result:
|
||||||
|
|
||||||
```
|
```
|
||||||
value1 => This is the full value
|
value1 => text without quotes
|
||||||
value2 => Take the value in quotation marks
|
value2 => Yes!
|
||||||
value3 => Or take in apostrophes
|
value3 => value in apostrophes
|
||||||
value4 => You can also comment
|
value4 => 1000
|
||||||
value5 => So you can also comment
|
value5 => 0.000
|
||||||
value6 => "And you can even do that!"
|
value7 => //path
|
||||||
value7 => 1234567890
|
value8 => "Hey!"
|
||||||
value8 => 12345.67890
|
text without quotes
|
||||||
value9 => You can use large margins
|
value1 => this value will be in the new section
|
||||||
value12 => //path
|
value3 => good value!
|
||||||
This is the full value
|
this value will be in the new section
|
||||||
```
|
```
|
||||||
|
|
BIN
img/matches.png
BIN
img/matches.png
Binary file not shown.
Before Width: | Height: | Size: 68 KiB After Width: | Height: | Size: 125 KiB |
|
@ -1,13 +1,23 @@
|
||||||
Such a line will not be read
|
Such a line will not be read
|
||||||
value1 = This is the full value
|
The main section is set by default
|
||||||
value2 = "Take the value in quotation marks"
|
value1=text without quotes
|
||||||
value3 = 'Or take in apostrophes'
|
value2=>"value in quotation marks"
|
||||||
value4 => You can also comment // Another separator and comment
|
value3=>'value in apostrophes' ; and here is the first comment
|
||||||
value5 => 'So you can also comment' # Yeah!
|
value4 => 1000 // free space in spaces and tabs
|
||||||
value6 => '"And you can even do that!"' ; He-he;)
|
value5 => 0.000 /* different form of commenting
|
||||||
value7 = 1234567890 # decimal value
|
value6 = // the string will not be read because the parameter value is missing
|
||||||
value8 => 12345.67890 ; float value
|
value7 = '' ; limiting empty characters will also not be taken into account
|
||||||
value9 => You can use large margins
|
[part2] ; a new section!
|
||||||
value10 = // But a line without a value will not be read
|
value1 = this value will be in the new section
|
||||||
value11 = //path # not working
|
value 2 = 200 ; The parameter name is incorrect
|
||||||
value12 = "//path" // nice way (or '//path')
|
value3 => good value! # and another way of commenting
|
||||||
|
|
||||||
|
[] ; Make the main section again!
|
||||||
|
value7 => '//path' # and now the value7 will be read!
|
||||||
|
value2 = Yes! /* We will also redefine the value2
|
||||||
|
value8 => '"Hey!"' # you can separate the values in quotation marks or apostrophes
|
||||||
|
|
||||||
|
[part3] // and another section
|
||||||
|
value1=>-2 ; so you can
|
||||||
|
value2=3// but it will not work to leave a comment
|
||||||
|
value3=>100 //you need space from the value by at least 1 character
|
||||||
|
|
35
tests/test.d
35
tests/test.d
|
@ -4,28 +4,31 @@ unittest
|
||||||
{
|
{
|
||||||
rc.read("./tests/settings.conf");
|
rc.read("./tests/settings.conf");
|
||||||
|
|
||||||
assert(rc.sn.key("value1") == "This is the full value");
|
assert(rc.sn.key("value1") == "text without quotes");
|
||||||
assert(rc.sn.key("value2") == "Take the value in quotation marks");
|
assert(rc.sn.key("value2") == "Yes!");
|
||||||
assert(rc.sn.key("value3") == "Or take in apostrophes");
|
assert(rc.sn.key("value3") == "value in apostrophes");
|
||||||
assert(rc.sn.key("value4") == "You can also comment");
|
assert(rc.sn.key("value4") == "1000");
|
||||||
assert(rc.sn.key("value5") == "So you can also comment");
|
assert(rc.sn.key("value5") == "0.000");
|
||||||
assert(rc.sn.key("value6") == "\"And you can even do that!\"");
|
assert(rc.sn.key("value7") == "//path");
|
||||||
assert(rc.sn.key("value7") == "1234567890");
|
assert(rc.sn.key("value8") == "\"Hey!\"");
|
||||||
assert(rc.sn.key("value8") == "12345.67890");
|
assert(rc.sn("part2").key("value1") == "this value will be in the new section");
|
||||||
assert(rc.sn.key("value9") == "You can use large margins");
|
assert(rc.sn("part2").key("value3") == "good value!");
|
||||||
assert(rc.sn.key("value10").empty);
|
assert(rc.sn("part3").key("value1") == "-2");
|
||||||
assert(rc.sn.key("value11").empty);
|
assert(rc.sn("part3").key("value3") == "100");
|
||||||
assert(rc.sn.key("value12") == "//path");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// void main()
|
// void main()
|
||||||
// {
|
// {
|
||||||
// import std.stdio;
|
// import std.stdio;
|
||||||
// Config.file.read("./tests/settings.conf");
|
// rc.read("./tests/settings.conf");
|
||||||
|
|
||||||
// foreach (key, param; Config.file.keys())
|
// foreach (key, param; rc.sn.keys())
|
||||||
// writefln("%s => %s", key, param);
|
// writefln("%s => %s", key, param);
|
||||||
|
|
||||||
// writeln(Config.file.key("value1"));
|
// writeln(rc.sn.key("value1"));
|
||||||
|
|
||||||
|
// foreach (key, param; rc.sn("part2").keys())
|
||||||
|
// writefln("%s => %s", key, param);
|
||||||
|
|
||||||
|
// writeln(rc.sn("part2").key("value1"));
|
||||||
// }
|
// }
|
||||||
|
|
Loading…
Reference in New Issue