Add unit tests for most of util.cpp
This commit is contained in:
@@ -188,24 +188,6 @@ PlaneMap::IdVector PlaneMap::scan_radius(const std::string &plane, double x, dou
|
||||
return result;
|
||||
}
|
||||
|
||||
util::IdVector PlaneMap::sort_union_id_vectors(const IdVector &v1, const IdVector &v2) {
|
||||
IdVector result(v1.size() + v2.size());
|
||||
int next = 0;
|
||||
for (int64_t id : v1) result[next++] = id;
|
||||
for (int64_t id : v2) result[next++] = id;
|
||||
std::sort(result.begin(), result.end());
|
||||
int64_t prev = -1;
|
||||
int64_t count = 0;
|
||||
for (int64_t id : result) {
|
||||
if (id != prev) {
|
||||
prev = id;
|
||||
result[count++] = id;
|
||||
}
|
||||
}
|
||||
result.resize(count);
|
||||
return result;
|
||||
}
|
||||
|
||||
LuaDefine(unittests_planemap, "c") {
|
||||
double SC = CELL_SCALE;
|
||||
double E = CELL_SCALE * 0.4;
|
||||
@@ -316,20 +298,5 @@ LuaDefine(unittests_planemap, "c") {
|
||||
LuaAssert(L, ids[0] == 123);
|
||||
LuaAssert(L, ids[1] == 456);
|
||||
|
||||
// Test the unioning of ID vectors.
|
||||
PlaneMap::IdVector idv1,idv2;
|
||||
idv1.push_back(1);
|
||||
idv1.push_back(6);
|
||||
idv1.push_back(4);
|
||||
idv2.push_back(1);
|
||||
idv2.push_back(5);
|
||||
idv2.push_back(6);
|
||||
PlaneMap::IdVector joined = PlaneMap::sort_union_id_vectors(idv1, idv2);
|
||||
LuaAssert(L, joined.size() == 4);
|
||||
LuaAssert(L, joined[0] == 1);
|
||||
LuaAssert(L, joined[1] == 4);
|
||||
LuaAssert(L, joined[2] == 5);
|
||||
LuaAssert(L, joined[3] == 6);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user