-
Notifications
You must be signed in to change notification settings - Fork 294
/
Copy pathSuffixTree_Tests.cs
40 lines (32 loc) · 1.11 KB
/
SuffixTree_Tests.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
36
37
38
39
40
using System.Linq;
using Advanced.Algorithms.DataStructures;
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace Advanced.Algorithms.Tests.DataStructures
{
[TestClass]
public class SuffixTests
{
/// <summary>
/// A tree test
/// </summary>
[TestMethod]
public void Suffix_Smoke_Test()
{
var tree = new SuffixTree<char>();
tree.Insert("bananaa".ToCharArray());
Assert.IsTrue(tree.Count == 1);
//IEnumerable test
Assert.AreEqual(tree.Count, tree.Count());
Assert.IsTrue(tree.Contains("aa".ToCharArray()));
Assert.IsFalse(tree.Contains("ab".ToCharArray()));
var matches = tree.StartsWith("na".ToCharArray());
Assert.IsTrue(matches.Count == 2);
matches = tree.StartsWith("an".ToCharArray());
Assert.IsTrue(matches.Count == 2);
tree.Delete("bananaa".ToCharArray());
Assert.IsTrue(tree.Count == 0);
//IEnumerable test
Assert.AreEqual(tree.Count, tree.Count());
}
}
}