This repository has been archived on 2023-10-09. You can view files and clone it, but cannot push or open issues or pull requests.
Files
blender-archive/source/blender/blenlib/tests/BLI_disjoint_set_test.cc
Campbell Barton c434782e3a File headers: SPDX License migration
Use a shorter/simpler license convention, stops the header taking so
much space.

Follow the SPDX license specification: https://spdx.org/licenses

- C/C++/objc/objc++
- Python
- Shell Scripts
- CMake, GNUmakefile

While most of the source tree has been included

- `./extern/` was left out.
- `./intern/cycles` & `./intern/atomic` are also excluded because they
  use different header conventions.

doc/license/SPDX-license-identifiers.txt has been added to list SPDX all
used identifiers.

See P2788 for the script that automated these edits.

Reviewed By: brecht, mont29, sergey

Ref D14069
2022-02-11 09:14:36 +11:00

37 lines
907 B
C++

/* SPDX-License-Identifier: Apache-2.0 */
#include "BLI_disjoint_set.hh"
#include "BLI_strict_flags.h"
#include "testing/testing.h"
namespace blender::tests {
TEST(disjoint_set, Test)
{
DisjointSet disjoint_set(6);
EXPECT_FALSE(disjoint_set.in_same_set(1, 2));
EXPECT_FALSE(disjoint_set.in_same_set(5, 3));
EXPECT_TRUE(disjoint_set.in_same_set(2, 2));
EXPECT_EQ(disjoint_set.find_root(3), 3);
disjoint_set.join(1, 2);
EXPECT_TRUE(disjoint_set.in_same_set(1, 2));
EXPECT_FALSE(disjoint_set.in_same_set(0, 1));
disjoint_set.join(3, 4);
EXPECT_FALSE(disjoint_set.in_same_set(2, 3));
EXPECT_TRUE(disjoint_set.in_same_set(3, 4));
disjoint_set.join(1, 4);
EXPECT_TRUE(disjoint_set.in_same_set(1, 4));
EXPECT_TRUE(disjoint_set.in_same_set(1, 3));
EXPECT_TRUE(disjoint_set.in_same_set(2, 4));
EXPECT_FALSE(disjoint_set.in_same_set(0, 4));
}
} // namespace blender::tests