Blender
V4.3
source
blender
blenlib
tests
BLI_disjoint_set_test.cc
Go to the documentation of this file.
1
/* SPDX-FileCopyrightText: 2023 Blender Authors
2
*
3
* SPDX-License-Identifier: Apache-2.0 */
4
5
#include "testing/testing.h"
6
7
#include "
BLI_disjoint_set.hh
"
8
9
#include "
BLI_strict_flags.h
"
/* Keep last. */
10
11
namespace
blender::tests
{
12
13
TEST
(disjoint_set, Test)
14
{
15
DisjointSet
disjoint_set(6);
16
EXPECT_FALSE(disjoint_set.
in_same_set
(1, 2));
17
EXPECT_FALSE(disjoint_set.
in_same_set
(5, 3));
18
EXPECT_TRUE(disjoint_set.
in_same_set
(2, 2));
19
EXPECT_EQ
(disjoint_set.
find_root
(3), 3);
20
21
disjoint_set.
join
(1, 2);
22
23
EXPECT_TRUE(disjoint_set.
in_same_set
(1, 2));
24
EXPECT_FALSE(disjoint_set.
in_same_set
(0, 1));
25
26
disjoint_set.
join
(3, 4);
27
28
EXPECT_FALSE(disjoint_set.
in_same_set
(2, 3));
29
EXPECT_TRUE(disjoint_set.
in_same_set
(3, 4));
30
31
disjoint_set.
join
(1, 4);
32
33
EXPECT_TRUE(disjoint_set.
in_same_set
(1, 4));
34
EXPECT_TRUE(disjoint_set.
in_same_set
(1, 3));
35
EXPECT_TRUE(disjoint_set.
in_same_set
(2, 4));
36
EXPECT_FALSE(disjoint_set.
in_same_set
(0, 4));
37
}
38
39
}
// namespace blender::tests
BLI_disjoint_set.hh
EXPECT_EQ
EXPECT_EQ(BLI_expr_pylike_eval(expr, nullptr, 0, &result), EXPR_PYLIKE_INVALID)
BLI_strict_flags.h
blender::DisjointSet
Definition
BLI_disjoint_set.hh:18
blender::DisjointSet::join
void join(const T x, const T y)
Definition
BLI_disjoint_set.hh:39
blender::DisjointSet::find_root
T find_root(const T x)
Definition
BLI_disjoint_set.hh:73
blender::DisjointSet::in_same_set
bool in_same_set(const T x, const T y)
Definition
BLI_disjoint_set.hh:63
blender::tests
Definition
BLI_any_test.cc:10
blender::tests::TEST
TEST(any, DefaultConstructor)
Definition
BLI_any_test.cc:12
Generated on Thu Feb 6 2025 07:36:39 for Blender by
doxygen
1.11.0