public void LongestPrefix_EmptyTree_NotFound(string input) { // Arrange var radixTree = new RadixTree <int>(); // Act var(_, _, found) = radixTree.LongestPrefix(input); // Assert Assert.False(found, "should not find longest prefix match"); }
public void LongestPrefix_ExistingPrefix_ReturnsValue(string input, string expected) { // Arrange var rand = new Random(); var keys = new[] { "", "foo", "foobar", "foobarbaz", "foobarbazzip", "foozip", }; var dictionary = keys.ToDictionary(x => x, _ => rand.Next()); var radixTree = new RadixTree <int>(dictionary); // Act var(key, value, found) = radixTree.LongestPrefix(input); // Assert Assert.True(found, "should find longest prefix match"); Assert.Equal(expected, key); Assert.Equal(dictionary[expected], value); }