public void TestHashIncrements() { var bc = new BucketCounter(8); for (int i = 0; i <= 255; i++) { var hash = bc.GetHash(new[] { (byte)i }); var baseline = bc.Get(hash); Assert.Equal(baseline, bc.Get(hash)); bc.Increment(hash); Assert.Equal(baseline + 1, bc.Get(hash)); bc.Increment(hash); Assert.Equal(baseline + 2, bc.Get(hash)); } }
public void TestTransition() { var bc = new BucketCounter(21, true, 512); bc.Increment(1); bc.Increment(2); bc.Increment(2); bc.Increment(3); bc.Increment(3); bc.Increment(3); for (var i = 4; i < bc.MaxDictionarySize + 2; i++) { bc.Increment(i); } Assert.Equal(1, bc.Get(1)); Assert.Equal(2, bc.Get(2)); Assert.Equal(3, bc.Get(3)); for (var i = 4; i < bc.MaxDictionarySize + 2; i++) { Assert.Equal(1, bc.Get(i)); } }