Added unitests for substitution.substiute
This commit is contained in:
parent
11286050ca
commit
7f78ea64c9
1 changed files with 20 additions and 1 deletions
|
@ -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;
|
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:
|
private:
|
||||||
|
|
||||||
string[string] map;
|
string[string] map;
|
||||||
|
|
Loading…
Reference in a new issue