Added unitests for substitution.substiute

This commit is contained in:
Johannes Loher 2016-12-29 13:33:41 +01:00
parent 11286050ca
commit 7f78ea64c9
1 changed files with 20 additions and 1 deletions

View File

@ -19,11 +19,30 @@ void loadSubstitutionFile(string fileName)
}
}
auto substitute(string s)
auto substitute(string s) @safe nothrow
{
return s in map ? map[s] : s;
}
@safe unittest
{
map[""] = "";
assert(substitute("") == "");
map["a"] = "b";
assert(substitute("a") == "b");
map["Regensburg Danziger Freiheit"] = "Danziger Freiheit";
assert(substitute("Regensburg Danziger Freiheit") == "Danziger Freiheit");
map["Regensburg Danziger Freiheit"] = "Anderer Test";
assert(substitute("Regensburg Danziger Freiheit") == "Anderer Test");
assert(substitute("z") == "z");
assert(substitute("Regensburg Hauptbahnhof") == "Regensburg Hauptbahnhof");
}
private:
string[string] map;