Compare commits
4 commits
unit-threa
...
master
Author | SHA1 | Date | |
---|---|---|---|
892378f55f | |||
6ad2048907 | |||
e85289fe53 | |||
18de7f6998 |
5 changed files with 132 additions and 181 deletions
5
.gitignore
vendored
5
.gitignore
vendored
|
@ -1 +1,4 @@
|
||||||
/bayernfahrplan
|
bayernfahrplan*
|
||||||
|
.dub/*
|
||||||
|
replacement.txt
|
||||||
|
dub.selections.json
|
||||||
|
|
19
.gitlab-ci.yml
Normal file
19
.gitlab-ci.yml
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
image: base/devel
|
||||||
|
|
||||||
|
before_script:
|
||||||
|
- pacman -Sy
|
||||||
|
- pacman --noconfirm -S ldc dub libevent
|
||||||
|
|
||||||
|
stages:
|
||||||
|
- build
|
||||||
|
- test
|
||||||
|
|
||||||
|
build:
|
||||||
|
stage: build
|
||||||
|
script:
|
||||||
|
- dub build --compiler=ldc2
|
||||||
|
|
||||||
|
test:
|
||||||
|
stage: test
|
||||||
|
script:
|
||||||
|
- dub test --compiler=ldc2
|
18
dub.json
18
dub.json
|
@ -5,24 +5,10 @@
|
||||||
"Oliver Rümpelein"
|
"Oliver Rümpelein"
|
||||||
],
|
],
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"requests": "~>0.5.0",
|
"requests": "0.5.3",
|
||||||
"kxml": "~>1.0.1"
|
"kxml": "~>1.0.1"
|
||||||
},
|
},
|
||||||
"description": "A minimal D application.",
|
"description": "A minimal D application.",
|
||||||
"copyright": "Copyright © 2017, Johannes Loher",
|
"copyright": "Copyright © 2017, Johannes Loher",
|
||||||
"license": "MIT",
|
"license": "MIT"
|
||||||
"targetType": "executable",
|
|
||||||
"configurations": [
|
|
||||||
{ "name": "executable" },
|
|
||||||
{
|
|
||||||
"name": "unittest",
|
|
||||||
"targetType": "executable",
|
|
||||||
"preBuildCommands": ["dub run unit-threaded -c gen_ut_main -- -f gen/ut.d"],
|
|
||||||
"mainSourceFile": "gen/ut.d",
|
|
||||||
"excludedSourceFiles": ["source/app.d"],
|
|
||||||
"dependencies": {
|
|
||||||
"unit-threaded": "~>0.7.28"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,17 +1,12 @@
|
||||||
module fahrplanparser;
|
module fahrplanparser;
|
||||||
|
|
||||||
import kxml.xml : readDocument, XmlNode;
|
|
||||||
|
|
||||||
import std.algorithm : map;
|
import std.algorithm : map;
|
||||||
import std.array : empty, front;
|
import std.array : empty, front;
|
||||||
import std.conv : to;
|
import std.conv : to;
|
||||||
import std.datetime : dur, TimeOfDay, DateTimeException;
|
import std.datetime : dur, TimeOfDay, DateTimeException;
|
||||||
import std.string : format;
|
import std.string : format;
|
||||||
|
|
||||||
version (unittest)
|
import kxml.xml : readDocument, XmlNode;
|
||||||
{
|
|
||||||
import unit_threaded;
|
|
||||||
}
|
|
||||||
|
|
||||||
import substitution;
|
import substitution;
|
||||||
|
|
||||||
|
@ -55,74 +50,22 @@ auto parsedFahrplan(in string data)
|
||||||
{
|
{
|
||||||
import std.array : array;
|
import std.array : array;
|
||||||
|
|
||||||
"".parsedFahrplan.array.shouldEqual([]);
|
auto xml = "";
|
||||||
|
assert(xml.parsedFahrplan.array == []);
|
||||||
|
|
||||||
"<efa><dps></dps></efa>".parsedFahrplan.array.shouldEqual([]);
|
xml = "<efa><dps></dps></efa>";
|
||||||
|
assert(xml.parsedFahrplan.array == []);
|
||||||
|
|
||||||
q"[
|
xml = "<efa><dps><dp><realtime>1</realtime><st><t>1224</t><rt>1242</rt></st><m><nu>6</nu><des>Wernerwerkstraße</des></m></dp></dps></efa>";
|
||||||
<efa>
|
assert(xml.parsedFahrplan.array == [["direction" : "Wernerwerkstraße",
|
||||||
<dps>
|
|
||||||
<dp>
|
|
||||||
<realtime>1</realtime>
|
|
||||||
<st>
|
|
||||||
<t>1224</t>
|
|
||||||
<rt>1242</rt>
|
|
||||||
</st>
|
|
||||||
<m>
|
|
||||||
<nu>6</nu>
|
|
||||||
<des>Wernerwerkstraße</des>
|
|
||||||
</m>
|
|
||||||
</dp>
|
|
||||||
</dps>
|
|
||||||
</efa>
|
|
||||||
]".parsedFahrplan.array.shouldEqual([["direction" : "Wernerwerkstraße",
|
|
||||||
"line" : "6", "departure" : "12:24", "delay" : "18"]]);
|
"line" : "6", "departure" : "12:24", "delay" : "18"]]);
|
||||||
|
|
||||||
q"[
|
xml = "<efa><dps><dp><realtime>0</realtime><st><t>1224</t></st><m><nu>6</nu><des>Wernerwerkstraße</des></m></dp></dps></efa>";
|
||||||
<efa>
|
assert(xml.parsedFahrplan.array == [["direction" : "Wernerwerkstraße",
|
||||||
<dps>
|
|
||||||
<dp>
|
|
||||||
<realtime>0</realtime>
|
|
||||||
<st>
|
|
||||||
<t>1224</t>
|
|
||||||
</st>
|
|
||||||
<m>
|
|
||||||
<nu>6</nu>
|
|
||||||
<des>Wernerwerkstraße</des>
|
|
||||||
</m>
|
|
||||||
</dp>
|
|
||||||
</dps>
|
|
||||||
</efa>
|
|
||||||
]".parsedFahrplan.array.shouldEqual([["direction" : "Wernerwerkstraße",
|
|
||||||
"line" : "6", "departure" : "12:24", "delay" : "0"]]);
|
"line" : "6", "departure" : "12:24", "delay" : "0"]]);
|
||||||
|
|
||||||
q"[
|
xml = "<efa><dps><dp><realtime>0</realtime><st><t>1224</t></st><m><nu>6</nu><des>Wernerwerkstraße</des></m></dp><dp><realtime>1</realtime><st><t>1353</t><rt>1356</rt></st><m><nu>11</nu><des>Burgweinting</des></m></dp></dps></efa>";
|
||||||
<efa>
|
assert(xml.parsedFahrplan.array == [["direction" : "Wernerwerkstraße", "line" : "6",
|
||||||
<dps>
|
|
||||||
<dp>
|
|
||||||
<realtime>0</realtime>
|
|
||||||
<st>
|
|
||||||
<t>1224</t>
|
|
||||||
</st>
|
|
||||||
<m>
|
|
||||||
<nu>6</nu>
|
|
||||||
<des>Wernerwerkstraße</des>
|
|
||||||
</m>
|
|
||||||
</dp>
|
|
||||||
<dp>
|
|
||||||
<realtime>1</realtime>
|
|
||||||
<st>
|
|
||||||
<t>1353</t>
|
|
||||||
<rt>1356</rt>
|
|
||||||
</st>
|
|
||||||
<m>
|
|
||||||
<nu>11</nu>
|
|
||||||
<des>Burgweinting</des>
|
|
||||||
</m>
|
|
||||||
</dp>
|
|
||||||
</dps>
|
|
||||||
</efa>
|
|
||||||
]".parsedFahrplan.array.shouldEqual([["direction" : "Wernerwerkstraße", "line" : "6",
|
|
||||||
"departure" : "12:24", "delay" : "0"], ["direction" : "Burgweinting",
|
"departure" : "12:24", "delay" : "0"], ["direction" : "Burgweinting",
|
||||||
"line" : "11", "departure" : "13:53", "delay" : "3"]]);
|
"line" : "11", "departure" : "13:53", "delay" : "3"]]);
|
||||||
}
|
}
|
||||||
|
@ -161,47 +104,41 @@ body
|
||||||
|
|
||||||
@system unittest
|
@system unittest
|
||||||
{
|
{
|
||||||
"<dp><st><t>0000</t></st></dp>".readDocument.parseXPath("/dp")
|
import std.exception : assertThrown;
|
||||||
.front.departureTime.shouldEqual(TimeOfDay(0, 0));
|
|
||||||
|
|
||||||
"<dp><st><t>0013</t></st></dp>".readDocument.parseXPath("/dp")
|
auto xml = "<dp><st><t>0000</t></st></dp>".readDocument.parseXPath("/dp").front;
|
||||||
.front.departureTime.shouldEqual(TimeOfDay(0, 13));
|
assert(xml.departureTime == TimeOfDay(0, 0));
|
||||||
|
|
||||||
"<dp><st><t>1100</t></st></dp>".readDocument.parseXPath("/dp")
|
xml = "<dp><st><t>0013</t></st></dp>".readDocument.parseXPath("/dp").front;
|
||||||
.front.departureTime.shouldEqual(TimeOfDay(11, 00));
|
assert(xml.departureTime == TimeOfDay(0, 13));
|
||||||
|
|
||||||
"<dp><st><t>1242</t></st></dp>".readDocument.parseXPath("/dp")
|
xml = "<dp><st><t>1100</t></st></dp>".readDocument.parseXPath("/dp").front;
|
||||||
.front.departureTime.shouldEqual(TimeOfDay(12, 42));
|
assert(xml.departureTime == TimeOfDay(11, 00));
|
||||||
|
|
||||||
"<dp><st><t>2359</t></st></dp>".readDocument.parseXPath("/dp")
|
xml = "<dp><st><t>1242</t></st></dp>".readDocument.parseXPath("/dp").front;
|
||||||
.front.departureTime.shouldEqual(TimeOfDay(23, 59));
|
assert(xml.departureTime == TimeOfDay(12, 42));
|
||||||
|
|
||||||
"<dp><st><t>2400</t></st></dp>".readDocument.parseXPath("/dp")
|
xml = "<dp><st><t>2359</t></st></dp>".readDocument.parseXPath("/dp").front;
|
||||||
.front.departureTime.shouldThrow!DateTimeException;
|
assert(xml.departureTime == TimeOfDay(23, 59));
|
||||||
|
|
||||||
"<dp><st><t>0061</t></st></dp>".readDocument.parseXPath("/dp")
|
assertThrown!DateTimeException("<dp><st><t>2400</t></st></dp>".readDocument.parseXPath("/dp")
|
||||||
.front.departureTime.shouldThrow!DateTimeException;
|
.front.departureTime);
|
||||||
|
assertThrown!DateTimeException("<dp><st><t>0061</t></st></dp>".readDocument.parseXPath("/dp")
|
||||||
"<dp><st><t>2567</t></st></dp>".readDocument.parseXPath("/dp")
|
.front.departureTime);
|
||||||
.front.departureTime.shouldThrow!DateTimeException;
|
assertThrown!DateTimeException("<dp><st><t>2567</t></st></dp>".readDocument.parseXPath("/dp")
|
||||||
|
.front.departureTime);
|
||||||
"<dp><st><t></t></st></dp>".readDocument.parseXPath("/dp")
|
assertThrown!DateTimeException("<dp><st><t></t></st></dp>".readDocument.parseXPath("/dp")
|
||||||
.front.departureTime.shouldThrow!DateTimeException;
|
.front.departureTime);
|
||||||
|
assertThrown!DateTimeException("<dp><st><t>0</t></st></dp>".readDocument.parseXPath("/dp")
|
||||||
"<dp><st><t>0</t></st></dp>".readDocument.parseXPath("/dp")
|
.front.departureTime);
|
||||||
.front.departureTime.shouldThrow!DateTimeException;
|
assertThrown!DateTimeException("<dp><st><t>00</t></st></dp>".readDocument.parseXPath("/dp")
|
||||||
|
.front.departureTime);
|
||||||
"<dp><st><t>00</t></st></dp>".readDocument.parseXPath("/dp")
|
assertThrown!DateTimeException("<dp><st><t>000000</t></st></dp>".readDocument.parseXPath("/dp")
|
||||||
.front.departureTime.shouldThrow!DateTimeException;
|
.front.departureTime);
|
||||||
|
assertThrown!DateTimeException("<dp><st><t>00:00</t></st></dp>".readDocument.parseXPath("/dp")
|
||||||
"<dp><st><t>000000</t></st></dp>".readDocument.parseXPath("/dp")
|
.front.departureTime);
|
||||||
.front.departureTime.shouldThrow!DateTimeException;
|
assertThrown!DateTimeException("<dp><st><t>abcd</t></st></dp>".readDocument.parseXPath("/dp")
|
||||||
|
.front.departureTime);
|
||||||
"<dp><st><t>00:00</t></st></dp>".readDocument.parseXPath("/dp")
|
|
||||||
.front.departureTime.shouldThrow!DateTimeException;
|
|
||||||
|
|
||||||
"<dp><st><t>abcd</t></st></dp>".readDocument.parseXPath("/dp")
|
|
||||||
.front.departureTime.shouldThrow!DateTimeException;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
auto delay(XmlNode dp)
|
auto delay(XmlNode dp)
|
||||||
|
@ -236,59 +173,70 @@ body
|
||||||
|
|
||||||
@system unittest
|
@system unittest
|
||||||
{
|
{
|
||||||
|
import std.exception : assertThrown;
|
||||||
import core.exception : AssertError;
|
import core.exception : AssertError;
|
||||||
|
|
||||||
"<dp><realtime>0</realtime></dp>".readDocument.parseXPath("/dp")
|
auto xml = "<dp><realtime>0</realtime></dp>".readDocument.parseXPath("/dp").front;
|
||||||
.front.delay.shouldEqual(dur!"minutes"(0));
|
assert(xml.delay == dur!"minutes"(0));
|
||||||
|
|
||||||
"<dp><realtime></realtime></dp>".readDocument.parseXPath("/dp")
|
xml = "<dp><realtime></realtime></dp>".readDocument.parseXPath("/dp").front;
|
||||||
.front.delay.shouldThrow!(UnexpectedValueException!string);
|
assertThrown!(UnexpectedValueException!string)(xml.delay);
|
||||||
|
|
||||||
"<dp><realtime>2</realtime></dp>".readDocument.parseXPath("/dp")
|
xml = "<dp><realtime>2</realtime></dp>".readDocument.parseXPath("/dp").front;
|
||||||
.front.delay.shouldThrow!(UnexpectedValueException!string);
|
assertThrown!(UnexpectedValueException!string)(xml.delay);
|
||||||
|
|
||||||
"<dp><realtime>a</realtime></dp>".readDocument.parseXPath("/dp")
|
xml = "<dp><realtime>a</realtime></dp>".readDocument.parseXPath("/dp").front;
|
||||||
.front.delay.shouldThrow!(UnexpectedValueException!string);
|
assertThrown!(UnexpectedValueException!string)(xml.delay);
|
||||||
|
|
||||||
"<dp><realtime>1</realtime></dp>".readDocument.parseXPath("/dp")
|
xml = "<dp><realtime>1</realtime></dp>".readDocument.parseXPath("/dp").front;
|
||||||
.front.delay.shouldEqual(dur!"seconds"(0));
|
assert(xml.delay == dur!"seconds"(0));
|
||||||
|
|
||||||
"<dp><realtime>1</realtime><st><t></t></st></dp>".readDocument.parseXPath("/dp")
|
xml = "<dp><realtime>1</realtime><st><t></t></st></dp>".readDocument.parseXPath("/dp").front;
|
||||||
.front.delay.shouldThrow!(DateTimeException);
|
assertThrown!DateTimeException(xml.delay);
|
||||||
|
|
||||||
"<dp><realtime>1</realtime><st><rt></rt></st></dp>".readDocument.parseXPath("/dp")
|
xml = "<dp><realtime>1</realtime><st><rt></rt></st></dp>".readDocument.parseXPath("/dp").front;
|
||||||
.front.delay.shouldEqual(dur!"seconds"(0));
|
assert(xml.delay == dur!"seconds"(0));
|
||||||
|
|
||||||
"<dp><st><rt></rt><t></t></st></dp>".readDocument.parseXPath("/dp")
|
xml = "<dp><st><rt></rt><t></t></st></dp>".readDocument.parseXPath("/dp").front;
|
||||||
.front.delay.shouldThrow!(AssertError);
|
assertThrown!AssertError(xml.delay);
|
||||||
|
|
||||||
"<dp><realtime>1</realtime><st><rt></rt><t></t></st></dp>".readDocument.parseXPath("/dp")
|
xml = "<dp><realtime>1</realtime><st><rt></rt><t></t></st></dp>".readDocument.parseXPath("/dp")
|
||||||
.front.delay.shouldThrow!(DateTimeException);
|
.front;
|
||||||
|
assertThrown!DateTimeException(xml.delay);
|
||||||
|
|
||||||
"<dp><realtime>1</realtime><st><rt>0000</rt><t></t></st></dp>".readDocument.parseXPath("/dp")
|
xml = "<dp><realtime>1</realtime><st><rt>0000</rt><t></t></st></dp>".readDocument.parseXPath("/dp")
|
||||||
.front.delay.shouldThrow!(DateTimeException);
|
.front;
|
||||||
|
assertThrown!DateTimeException(xml.delay);
|
||||||
|
|
||||||
"<dp><realtime>1</realtime><st><rt></rt><t>0000</t></st></dp>".readDocument.parseXPath("/dp")
|
xml = "<dp><realtime>1</realtime><st><rt></rt><t>0000</t></st></dp>".readDocument.parseXPath("/dp")
|
||||||
.front.delay.shouldThrow!(DateTimeException);
|
.front;
|
||||||
|
assertThrown!DateTimeException(xml.delay);
|
||||||
|
|
||||||
"<dp><realtime>1</realtime><st><rt>0000</rt><t>0000</t></st></dp>".readDocument.parseXPath("/dp")
|
xml = "<dp><realtime>1</realtime><st><rt>0000</rt><t>0000</t></st></dp>"
|
||||||
.front.delay.shouldEqual(dur!"minutes"(0));
|
.readDocument.parseXPath("/dp").front;
|
||||||
|
assert(xml.delay == dur!"minutes"(0));
|
||||||
|
|
||||||
"<dp><realtime>1</realtime><st><rt>0001</rt><t>0000</t></st></dp>".readDocument.parseXPath("/dp")
|
xml = "<dp><realtime>1</realtime><st><rt>0001</rt><t>0000</t></st></dp>"
|
||||||
.front.delay.shouldEqual(dur!"minutes"(1));
|
.readDocument.parseXPath("/dp").front;
|
||||||
|
assert(xml.delay == dur!"minutes"(1));
|
||||||
|
|
||||||
"<dp><realtime>1</realtime><st><rt>1753</rt><t>1751</t></st></dp>".readDocument.parseXPath("/dp")
|
xml = "<dp><realtime>1</realtime><st><rt>1753</rt><t>1751</t></st></dp>"
|
||||||
.front.delay.shouldEqual(dur!"minutes"(2));
|
.readDocument.parseXPath("/dp").front;
|
||||||
|
assert(xml.delay == dur!"minutes"(2));
|
||||||
|
|
||||||
"<dp><realtime>1</realtime><st><rt>1010</rt><t>1000</t></st></dp>".readDocument.parseXPath("/dp")
|
xml = "<dp><realtime>1</realtime><st><rt>1010</rt><t>1000</t></st></dp>"
|
||||||
.front.delay.shouldEqual(dur!"minutes"(10));
|
.readDocument.parseXPath("/dp").front;
|
||||||
|
assert(xml.delay == dur!"minutes"(10));
|
||||||
|
|
||||||
"<dp><realtime>1</realtime><st><rt>1301</rt><t>1242</t></st></dp>".readDocument.parseXPath("/dp")
|
xml = "<dp><realtime>1</realtime><st><rt>1301</rt><t>1242</t></st></dp>"
|
||||||
.front.delay.shouldEqual(dur!"minutes"(19));
|
.readDocument.parseXPath("/dp").front;
|
||||||
|
assert(xml.delay == dur!"minutes"(19));
|
||||||
|
|
||||||
"<dp><realtime>1</realtime><st><rt>0000</rt><t>1242</t></st></dp>".readDocument.parseXPath("/dp")
|
xml = "<dp><realtime>1</realtime><st><rt>0000</rt><t>1242</t></st></dp>"
|
||||||
.front.delay.shouldEqual(dur!"minutes"(678));
|
.readDocument.parseXPath("/dp").front;
|
||||||
|
assert(xml.delay == dur!"minutes"(678));
|
||||||
|
|
||||||
"<dp><realtime>1</realtime><st><rt>0000</rt><t>2359</t></st></dp>".readDocument.parseXPath("/dp")
|
xml = "<dp><realtime>1</realtime><st><rt>0000</rt><t>2359</t></st></dp>"
|
||||||
.front.delay.shouldEqual(dur!"minutes"(1));
|
.readDocument.parseXPath("/dp").front;
|
||||||
|
assert(xml.delay == dur!"minutes"(1));
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,11 +4,6 @@ import std.file : slurp;
|
||||||
import std.meta : AliasSeq;
|
import std.meta : AliasSeq;
|
||||||
import std.traits : Parameters;
|
import std.traits : Parameters;
|
||||||
|
|
||||||
version (unittest)
|
|
||||||
{
|
|
||||||
import unit_threaded;
|
|
||||||
}
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
/***********************************
|
/***********************************
|
||||||
|
@ -35,7 +30,7 @@ void loadSubstitutionFile(alias slurpFun = slurp)(string fileName)
|
||||||
}
|
}
|
||||||
|
|
||||||
loadSubstitutionFile!mockSlurpEmpty("");
|
loadSubstitutionFile!mockSlurpEmpty("");
|
||||||
map.length.shouldEqual(0);
|
assert(map.length == 0);
|
||||||
|
|
||||||
static Tuple!(string, string)[] mockSlurpEmptyEntry(Type1, Type2)(string filename,
|
static Tuple!(string, string)[] mockSlurpEmptyEntry(Type1, Type2)(string filename,
|
||||||
in char[] format)
|
in char[] format)
|
||||||
|
@ -44,9 +39,9 @@ void loadSubstitutionFile(alias slurpFun = slurp)(string fileName)
|
||||||
}
|
}
|
||||||
|
|
||||||
loadSubstitutionFile!mockSlurpEmptyEntry("");
|
loadSubstitutionFile!mockSlurpEmptyEntry("");
|
||||||
"".shouldBeIn(map);
|
assert("" in map);
|
||||||
map.length.shouldEqual(1);
|
assert(map.length == 1);
|
||||||
map[""].shouldEqual("");
|
assert(map[""] == "");
|
||||||
|
|
||||||
static Tuple!(string, string)[] mockSlurpSingleEntry(Type1, Type2)(string filename,
|
static Tuple!(string, string)[] mockSlurpSingleEntry(Type1, Type2)(string filename,
|
||||||
in char[] format)
|
in char[] format)
|
||||||
|
@ -55,9 +50,9 @@ void loadSubstitutionFile(alias slurpFun = slurp)(string fileName)
|
||||||
}
|
}
|
||||||
|
|
||||||
loadSubstitutionFile!mockSlurpSingleEntry("");
|
loadSubstitutionFile!mockSlurpSingleEntry("");
|
||||||
"foo".shouldBeIn(map);
|
assert("foo" in map);
|
||||||
map.length.shouldEqual(1);
|
assert(map.length == 1);
|
||||||
map["foo"].shouldEqual("bar");
|
assert(map["foo"] == "bar");
|
||||||
|
|
||||||
static Tuple!(string, string)[] mockSlurpMultipleEntries(Type1, Type2)(
|
static Tuple!(string, string)[] mockSlurpMultipleEntries(Type1, Type2)(
|
||||||
string filename, in char[] format)
|
string filename, in char[] format)
|
||||||
|
@ -66,13 +61,13 @@ void loadSubstitutionFile(alias slurpFun = slurp)(string fileName)
|
||||||
}
|
}
|
||||||
|
|
||||||
loadSubstitutionFile!mockSlurpMultipleEntries("");
|
loadSubstitutionFile!mockSlurpMultipleEntries("");
|
||||||
"".shouldBeIn(map);
|
assert("" in map);
|
||||||
"0".shouldBeIn(map);
|
assert("0" in map);
|
||||||
"Text in".shouldBeIn(map);
|
assert("Text in" in map);
|
||||||
map.length.shouldEqual(3);
|
assert(map.length == 3);
|
||||||
map[""].shouldEqual("");
|
assert(map[""] == "");
|
||||||
map["0"].shouldEqual("1");
|
assert(map["0"] == "1");
|
||||||
map["Text in"].shouldEqual("wird durch diesen ersetzt");
|
assert(map["Text in"] == "wird durch diesen ersetzt");
|
||||||
}
|
}
|
||||||
|
|
||||||
/***********************************
|
/***********************************
|
||||||
|
@ -89,20 +84,20 @@ auto substitute(string s) @safe nothrow
|
||||||
@safe unittest
|
@safe unittest
|
||||||
{
|
{
|
||||||
map[""] = "";
|
map[""] = "";
|
||||||
"".substitute.shouldEqual("");
|
assert(substitute("") == "");
|
||||||
|
|
||||||
map["a"] = "b";
|
map["a"] = "b";
|
||||||
"a".substitute.shouldEqual("b");
|
assert(substitute("a") == "b");
|
||||||
|
|
||||||
map["Regensburg Danziger Freiheit"] = "Danziger Freiheit";
|
map["Regensburg Danziger Freiheit"] = "Danziger Freiheit";
|
||||||
"Regensburg Danziger Freiheit".substitute.shouldEqual("Danziger Freiheit");
|
assert(substitute("Regensburg Danziger Freiheit") == "Danziger Freiheit");
|
||||||
|
|
||||||
map["Regensburg Danziger Freiheit"] = "Anderer Test";
|
map["Regensburg Danziger Freiheit"] = "Anderer Test";
|
||||||
"Regensburg Danziger Freiheit".substitute.shouldEqual("Anderer Test");
|
assert(substitute("Regensburg Danziger Freiheit") == "Anderer Test");
|
||||||
|
|
||||||
"z".substitute.shouldEqual("z");
|
assert(substitute("z") == "z");
|
||||||
|
|
||||||
"Regensburg Hauptbahnhof".substitute.shouldEqual("Regensburg Hauptbahnhof");
|
assert(substitute("Regensburg Hauptbahnhof") == "Regensburg Hauptbahnhof");
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
Loading…
Reference in a new issue