Blender V4.3
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
11namespace blender::tests {
12
13TEST(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
EXPECT_EQ(BLI_expr_pylike_eval(expr, nullptr, 0, &result), EXPR_PYLIKE_INVALID)
void join(const T x, const T y)
bool in_same_set(const T x, const T y)
TEST(any, DefaultConstructor)