Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHoward Trickey <howard.trickey@gmail.com>2022-01-18 07:22:40 +0300
committerHoward Trickey <howard.trickey@gmail.com>2022-01-18 07:22:40 +0300
commit6dd89afa966042f8ae402c848655ac0dc0d795fe (patch)
tree9c46d63d75f17bfa40a1622d6be2480a413eea22 /source/blender/io/wavefront_obj/tests
parentdb496a0b7dcf1ab024aece9858257c40529138e4 (diff)
Fix obj exporter tests by deduping normals and printing with less precision.
Some new obj exporter tests were disabled because the normals were different in the last decimal place on different platforms. The old python exporter deduped normals with their coordinates rounded to four decimal places. This change does the same in the new exporter. On one test, this produced a file 25% smaller and even ran 10% faster.
Diffstat (limited to 'source/blender/io/wavefront_obj/tests')
-rw-r--r--source/blender/io/wavefront_obj/tests/obj_exporter_tests.cc14
1 files changed, 10 insertions, 4 deletions
diff --git a/source/blender/io/wavefront_obj/tests/obj_exporter_tests.cc b/source/blender/io/wavefront_obj/tests/obj_exporter_tests.cc
index 3b44a72ca0c..1890b349fd1 100644
--- a/source/blender/io/wavefront_obj/tests/obj_exporter_tests.cc
+++ b/source/blender/io/wavefront_obj/tests/obj_exporter_tests.cc
@@ -29,6 +29,8 @@
#include "obj_exporter_tests.hh"
namespace blender::io::obj {
+/* Set this true to keep comparison-failing test ouput in temp file directory. */
+constexpr bool save_failing_test_output = false;
/* This is also the test name. */
class obj_exporter_test : public BlendfileLoadingBaseTest {
@@ -294,8 +296,14 @@ class obj_exporter_regression_test : public obj_exporter_test {
std::string golden_file_path = blender::tests::flags_test_asset_dir() + "/" + golden_obj;
std::string golden_str = read_temp_file_in_string(golden_file_path);
- ASSERT_TRUE(strings_equal_after_first_lines(output_str, golden_str));
- BLI_delete(out_file_path.c_str(), false, false);
+ bool are_equal = strings_equal_after_first_lines(output_str, golden_str);
+ if (save_failing_test_output && !are_equal) {
+ printf("failing test output in %s\n", out_file_path.c_str());
+ }
+ ASSERT_TRUE(are_equal);
+ if (!save_failing_test_output || are_equal) {
+ BLI_delete(out_file_path.c_str(), false, false);
+ }
if (!golden_mtl.empty()) {
std::string out_mtl_file_path = tempdir + BLI_path_basename(golden_mtl.c_str());
std::string output_mtl_str = read_temp_file_in_string(out_mtl_file_path);
@@ -390,7 +398,6 @@ TEST_F(obj_exporter_regression_test, cube_all_data_triangulated)
_export.params);
}
-#if 0
TEST_F(obj_exporter_regression_test, suzanne_all_data)
{
OBJExportParamsDefault _export;
@@ -415,6 +422,5 @@ TEST_F(obj_exporter_regression_test, all_objects)
"io_tests/obj/all_objects.mtl",
_export.params);
}
-#endif
} // namespace blender::io::obj