public void ProtoVanEmdeBoasSmokeTest() { var tree = new ProtoVanEmdeBoasTree <string>(111); Assert.True(tree.Insert(79, "value 79")); Assert.Equal("value 79", tree.GetValue(79)); Assert.False(tree.Insert(79, "value 79 - 2")); Assert.Equal("value 79 - 2", tree.GetValue(79)); Assert.True(tree.Insert(16, "value 16")); Assert.Equal("value 16", tree.GetValue(16)); Assert.Equal(2, tree.Count); Assert.False(tree.Delete(20)); Assert.Equal(2, tree.Count); Assert.True(tree.Delete(16)); Assert.Equal(1, tree.Count); Assert.False(tree.Delete(16)); Assert.Equal(1, tree.Count); Assert.True(tree.Delete(79)); Assert.Equal(0, tree.Count); Assert.False(tree.Delete(79)); Assert.Equal(0, tree.Count); }
public void NextKeyTest() { var tree = new ProtoVanEmdeBoasTree <int>(111); tree.Insert(100, 1100); tree.Insert(77, 1077); tree.Insert(33, 1033); tree.Insert(55, 1055); Assert.Null(tree.NextKey(100)); Assert.Equal(100, tree.NextKey(77)); Assert.Equal(33, tree.NextKey(10)); Assert.Equal(55, tree.NextKey(33)); Assert.Equal(100, tree.NextKey(77)); Assert.True(tree.Delete(33)); Assert.Equal(55, tree.NextKey(10)); for (int i = 0; i < tree.Capacity; ++i) { tree.Insert(i, i * 100); } for (int i = 0; i < tree.Capacity - 1; ++i) { Assert.Equal(i + 1, tree.NextKey(i)); } Assert.Null(tree.NextKey(tree.Capacity - 1)); }