Initial Grease Pencil 3.0 stage #106848
|
@ -841,6 +841,7 @@ if(WITH_GTESTS)
|
|||
intern/lib_remap_test.cc
|
||||
intern/nla_test.cc
|
||||
intern/tracking_test.cc
|
||||
intern/grease_pencil_test.cc
|
||||
)
|
||||
set(TEST_INC
|
||||
../editors/include
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
/* SPDX-License-Identifier: GPL-2.0-or-later
|
||||
* Copyright 2021 Blender Foundation. */
|
||||
|
||||
#include "testing/testing.h"
|
||||
|
||||
#include "BKE_grease_pencil.hh"
|
||||
|
||||
using namespace blender::bke::gpencil;
|
||||
|
||||
namespace blender::bke::gpencil::tests {
|
||||
|
||||
TEST(gpencil, build_layer_tree)
|
||||
{
|
||||
TreeNode root{};
|
||||
|
||||
TreeNode node("Node1");
|
||||
node.add_child(TreeNode("Child1"));
|
||||
node.add_child(TreeNode("Child2"));
|
||||
|
||||
|
||||
root.add_child(std::move(node));
|
||||
root.add_child(TreeNode("Node2"));
|
||||
|
||||
for (TreeNode &node : root.children_in_pre_order()) {
|
||||
std::cout << node.name << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace blender::bke::gpencil::tests
|
Loading…
Reference in New Issue
Use text fixtures: http://google.github.io/googletest/primer.html#same-data-multiple-tests
I used fixtures before, but decided to use this approach instead, because all the tests are then under the same
greasepencil
namespace. I didn't find a way to do this with fixtures, unless I name the class literallygreasepencil
.You can't do that either. It is at a very least discouraged to use the same name for fixture and "regular" test.
Typically the "namespace" defines context you're testing, and it is perfectly fine to have multiple of such contexts per file (
euclidean_resection_test.cc
). But with the monolithic nature of BKE/BLI tests there is no good way to achieve the same behavior.I would love to improve the monolithic state of tests at some point (as it is really in a way every time I work on test), but that is outside of the scope of this patch.
Would be nice to add a comment on top of the
GreasePencilIDTestContext
which briefly summarizes your choice of this approach. Basically, so if someone else stumbles on this code and winders "why not fixtures" they have an answer.