Blender V5.0
sculpt_undo_test.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2025 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
5#include "BKE_idtype.hh"
6#include "BKE_lib_id.hh"
7
8#include "DNA_mesh_types.h"
9
11
12#include "sculpt_undo.hh"
13
14#include "CLG_log.h"
15
16#include "testing/testing.h"
17
19
20class SculptUndoTest : public testing::Test {
21 public:
23
24 static void SetUpTestSuite()
25 {
26 CLG_init();
28 }
29
30 static void TearDownTestSuite()
31 {
32 CLG_exit();
33 }
34
35 void SetUp() override
36 {
37 cube_mesh = geometry::create_cuboid_mesh(float3(1, 1, 1), 50, 50, 50);
38 }
39
40 void TearDown() override
41 {
42 BKE_id_free(nullptr, cube_mesh);
43 }
44};
45
46TEST_F(SculptUndoTest, CompressRoundTrip)
47{
48 Mesh *mesh = this->cube_mesh;
49
50 Vector<std::byte> buffer;
51 Vector<std::byte> compressed;
52
53 {
54 compression::filter_compress<float3>(mesh->vert_positions(), buffer, compressed);
55 Vector<float3> decompressed;
56 compression::filter_decompress<float3>(compressed, buffer, decompressed);
57 EXPECT_EQ(mesh->vert_positions().size(), decompressed.size());
58 EXPECT_EQ_SPAN(mesh->vert_positions(), decompressed.as_span());
59 }
60
61 {
62 compression::filter_compress<int>(mesh->corner_verts(), buffer, compressed);
63 Vector<int> decompressed;
64 compression::filter_decompress<int>(compressed, buffer, decompressed);
65 EXPECT_EQ(mesh->corner_verts().size(), decompressed.size());
66 EXPECT_EQ_SPAN(mesh->corner_verts(), decompressed.as_span());
67 }
68}
69
70} // namespace blender::ed::sculpt_paint::undo::tests
void BKE_idtype_init()
Definition idtype.cc:121
void BKE_id_free(Main *bmain, void *idv)
EXPECT_EQ(BLI_expr_pylike_eval(expr, nullptr, 0, &result), EXPR_PYLIKE_INVALID)
void CLG_exit()
Definition clog.cc:880
void CLG_init()
Definition clog.cc:873
int64_t size() const
Span< T > as_span() const
template void filter_decompress< float3 >(Span< std::byte >, Vector< std::byte > &, Vector< float3 > &)
template void filter_decompress< int >(Span< std::byte >, Vector< std::byte > &, Vector< int > &)
template void filter_compress< float3 >(Span< float3 >, Vector< std::byte > &, Vector< std::byte > &)
template void filter_compress< int >(Span< int >, Vector< std::byte > &, Vector< std::byte > &)
TEST_F(SculptUndoTest, CompressRoundTrip)
Mesh * create_cuboid_mesh(const float3 &size, int verts_x, int verts_y, int verts_z, std::optional< StringRef > uv_id)
VecBase< float, 3 > float3