Blender V5.0
obj_importer_tests.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2023-2025 Blender Authors
2 *
3 * SPDX-License-Identifier: Apache-2.0 */
4
5#include <gtest/gtest.h>
6
7#include "testing/testing.h"
8
9#include "BLI_string.h"
10
11#include "CLG_log.h"
12
14
15namespace blender::io::obj {
16
17/* Extensive tests for OBJ importing are in `io_obj_import_test.py`.
18 * The tests here are only for testing OBJ reader buffer refill behavior,
19 * by using a very small buffer size on purpose. */
20
21TEST(obj_import, BufferRefillTest)
22{
23 CLG_init();
24
26 /* nurbs_cyclic.obj file has quite long lines, good to test read buffer refill. */
27 std::string obj_path = blender::tests::flags_test_asset_dir() +
28 SEP_STR "io_tests" SEP_STR "obj" SEP_STR + "nurbs_cyclic.obj";
29 STRNCPY(params.filepath, obj_path.c_str());
30
31 /* Use a small read buffer size to test buffer refilling behavior. */
32 const size_t read_buffer_size = 650;
33 OBJParser obj_parser{params, read_buffer_size};
34
36 GlobalVertices global_vertices;
37 obj_parser.parse(all_geometries, global_vertices);
38
39 EXPECT_EQ(1, all_geometries.size());
40 EXPECT_EQ(GEOM_CURVE, all_geometries[0]->geom_type_);
41 EXPECT_EQ(28, global_vertices.vertices.size());
42 EXPECT_EQ(31, all_geometries[0]->nurbs_element_.curv_indices.size());
43 EXPECT_EQ(35, all_geometries[0]->nurbs_element_.parm.size());
44
45 CLG_exit();
46}
47
48} // namespace blender::io::obj
EXPECT_EQ(BLI_expr_pylike_eval(expr, nullptr, 0, &result), EXPR_PYLIKE_INVALID)
char * STRNCPY(char(&dst)[N], const char *src)
Definition BLI_string.h:693
void CLG_exit()
Definition clog.cc:880
void CLG_init()
Definition clog.cc:873
int64_t size() const
void parse(Vector< std::unique_ptr< Geometry > > &r_all_geometries, GlobalVertices &r_global_vertices)
uiWidgetBaseParameters params[MAX_WIDGET_BASE_BATCH]
TEST(obj_exporter_utils, append_negative_frame_to_filename)
#define SEP_STR
Definition unit.cc:39