-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathQuickUnionUnitTest.cs
35 lines (31 loc) · 947 Bytes
/
QuickUnionUnitTest.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
using Algorithms.UnionFind;
using Xunit;
using Xunit.Abstractions;
namespace AlgorithmsUnitTest.UnionFind
{
public class QuickUnionUnitTest
{
private readonly ITestOutputHelper logger;
public QuickUnionUnitTest(ITestOutputHelper console)
{
this.logger = console;
}
[Fact]
public void test_union_find()
{
var uf = new QuickUnion(10);
uf.Union(1, 3);
uf.Union(2, 3);
uf.Union(5, 6);
uf.Union(4, 5);
Assert.True(uf.IsConnected(1, 3));
Assert.True(uf.IsConnected(2, 3));
Assert.True(uf.IsConnected(1, 2));
Assert.True(uf.IsConnected(4, 5));
Assert.True(uf.IsConnected(4, 6));
Assert.False(uf.IsConnected(1, 6));
Assert.False(uf.IsConnected(3, 4));
this.logger.WriteLine("Connected: {1, 2, 3}");
}
}
}