I/O tests: change all_geometry scene to not have subd surface, and always print obj failure output diff details

The all_objects.blend test scene (in subversion tests repo) contained an
object with a subdivision surface. Which changes vertex positions
slightly, depending on used OpenSubDiv version and the compile flags. It
seems that the intent of the test was "test export of meshes that use
modifiers", so I changed that object to be a cube with a simple "taper"
modifier instead.

While at it, changed OBJ exporter test code to always print the
"expected and what we got" text difference details, when a test fails.
Much easier to see than just "the files are different" output. The code
to print that was behind an off by default flag for some reason.

This diff should get comitted together with updated all_objects templates
in subversion tests repo.

Reviewed By: Sebastian Parborg
Differential Revision: https://developer.blender.org/D14597
This commit is contained in:
Aras Pranckevicius 2022-04-08 15:08:50 +03:00
parent aa1e8bb9ab
commit 9439ac41eb
2 changed files with 16 additions and 24 deletions

View File

@ -273,34 +273,26 @@ parm u 0.0
/* Return true if string #a and string #b are equal after their first newline. */
static bool strings_equal_after_first_lines(const std::string &a, const std::string &b)
{
/* If `dbg_level` is true then a failing test will print context around the first mismatch. */
const bool dbg_level = false;
const size_t a_len = a.size();
const size_t b_len = b.size();
const size_t a_next = a.find_first_of('\n');
const size_t b_next = b.find_first_of('\n');
if (a_next == std::string::npos || b_next == std::string::npos) {
if (dbg_level) {
std::cout << "Couldn't find newline in one of args\n";
std::cout << "Couldn't find newline in one of args\n";
return false;
}
if (a.compare(a_next, a_len - a_next, b, b_next, b_len - b_next) != 0) {
for (int i = 0; i < a_len - a_next && i < b_len - b_next; ++i) {
if (a[a_next + i] != b[b_next + i]) {
std::cout << "Difference found at pos " << a_next + i << " of a\n";
std::cout << "a: " << a.substr(a_next + i, 100) << " ...\n";
std::cout << "b: " << b.substr(b_next + i, 100) << " ... \n";
return false;
}
}
return false;
}
if (dbg_level) {
if (a.compare(a_next, a_len - a_next, b, b_next, b_len - b_next) != 0) {
for (int i = 0; i < a_len - a_next && i < b_len - b_next; ++i) {
if (a[a_next + i] != b[b_next + i]) {
std::cout << "Difference found at pos " << a_next + i << " of a\n";
std::cout << "a: " << a.substr(a_next + i, 100) << " ...\n";
std::cout << "b: " << b.substr(b_next + i, 100) << " ... \n";
return false;
}
}
}
else {
return true;
}
}
return a.compare(a_next, a_len - a_next, b, b_next, b_len - b_next) == 0;
return true;
}
/* From here on, tests are whole file tests, testing for golden output. */

View File

@ -387,15 +387,15 @@ TEST_F(obj_importer_test, import_all_objects)
float3(28, 1, -1),
float3(26, 1, 1),
float3(-1, 0, 0)},
{"OBSubSurfCube",
{"OBTaperCube",
OB_MESH,
106,
208,
104,
416,
float3(24.444445f, 0.444444f, -0.666667f),
float3(23.790743f, 0.490725f, -0.816819f),
float3(0.1697f, 0.1697f, 0.9708f)},
float3(24.444445f, 0.502543f, -0.753814f),
float3(23.790743f, 0.460522f, -0.766546f),
float3(-0.0546f, 0.1716f, 0.9837f)},
{"OBParticleCube",
OB_MESH,
8,