Fix tests: some relation tags wouldn't be included in the lua testing, causing the tests to fail

This commit is contained in:
Pieter Vander Vennet 2021-02-20 14:31:35 +01:00
parent f343637f21
commit 00fa1a8b67
3 changed files with 14 additions and 4 deletions

View file

@ -23,14 +23,16 @@ namespace AspectedRouting.IO.itinero1
var aspectTestSuite = var aspectTestSuite =
string.Join("\n\n", aspectTests string.Join("\n\n",
aspectTests
.Where(x => x != null) .Where(x => x != null)
.Select( .Select(
GenerateAspectTestSuite GenerateAspectTestSuite
)); ));
var profileTestSuite = var profileTestSuite =
string.Join("\n\n", profileTests string.Join("\n\n",
profileTests
.Where(x => x != null) .Where(x => x != null)
.Select( .Select(
t => GenerateProfileTestSuite(t, invertPriority) t => GenerateProfileTestSuite(t, invertPriority)
@ -79,6 +81,9 @@ namespace AspectedRouting.IO.itinero1
foreach (var key in keysToCheck) foreach (var key in keysToCheck)
{ {
var newKey = key.Replace(".", "_"); var newKey = key.Replace(".", "_");
if (newKey == key) {
continue;
}
tags[newKey] = tags[key]; tags[newKey] = tags[key];
tags.Remove(key); tags.Remove(key);
} }

View file

@ -84,6 +84,7 @@ namespace AspectedRouting.IO.itinero2
_skeleton.AddDependenciesFor(_profile.Speed); _skeleton.AddDependenciesFor(_profile.Speed);
_skeleton.AddDep("eq"); _skeleton.AddDep("eq");
_skeleton.AddDep("remove_relation_prefix");
var code = new List<string> var code = new List<string>
{ {
"--[[", "--[[",
@ -91,6 +92,9 @@ namespace AspectedRouting.IO.itinero2
"]]", "]]",
"function factor(tags, result)", "function factor(tags, result)",
" ", " ",
" -- Cleanup the relation tags to make them usable with this profile",
$" tags = remove_relation_prefix(tags, \"{_behaviourName}\")",
" ",
" -- initialize the result table on the default values", " -- initialize the result table on the default values",
" result.forward_speed = 0", " result.forward_speed = 0",
" result.backward_speed = 0", " result.backward_speed = 0",

View file

@ -64,8 +64,9 @@ namespace AspectedRouting.IO.itinero2
$"description = \"{profileDescr} ({_profile.Description})\"" $"description = \"{profileDescr} ({_profile.Description})\""
}; };
var tests = new LuaTestPrinter(_skeleton, var testPrinter = new LuaTestPrinter(_skeleton,
new List<string>() {"unitTestProfile2"}).GenerateFullTestSuite( new List<string>() {"unitTestProfile2"});
var tests = testPrinter.GenerateFullTestSuite(
_behaviourTestSuite.ToList(), _behaviourTestSuite.ToList(),
new List<AspectTestSuite>(), new List<AspectTestSuite>(),
true); true);