private static FastByIDMap <String> buildTestFastMap() { FastByIDMap <String> map = new FastByIDMap <String>(); map.Put(500000L, "alpha"); map.Put(47L, "bang"); map.Put(2L, "beta"); return(map); }
public void testGrow() { FastByIDMap <String> map = new FastByIDMap <String>(1, 1); map.Put(500000L, "alpha"); map.Put(47L, "bang"); Assert.IsNull(map.Get(500000L)); Assert.AreEqual("bang", map.Get(47L)); }
public void testMaxSize() { FastByIDMap <String> map = new FastByIDMap <String>(); map.Put(4, "bang"); Assert.AreEqual(1, map.Count()); map.Put(47L, "bang"); Assert.AreEqual(2, map.Count()); Assert.IsNull(map.Get(500000L)); map.Put(47L, "buzz"); Assert.AreEqual(2, map.Count()); Assert.AreEqual("buzz", map.Get(47L)); }
public void testVersusHashMap() { FastByIDMap <String> actual = new FastByIDMap <String>(); IDictionary <long, string> expected = new Dictionary <long, string>(1000000); var r = RandomUtils.getRandom(); for (int i = 0; i < 1000000; i++) { double d = r.nextDouble(); long key = (long)r.nextInt(100); if (d < 0.4) { Assert.AreEqual(expected.ContainsKey(key)?expected[key]:null, actual.Get(key)); } else { if (d < 0.7) { var expectedOldVal = expected.ContainsKey(key) ? expected[key] : null; expected[key] = "bang"; Assert.AreEqual(expectedOldVal, actual.Put(key, "bang")); } else { var expectedOldVal = expected.ContainsKey(key) ? expected[key] : null; expected.Remove(key); Assert.AreEqual(expectedOldVal, actual.Remove(key)); } Assert.AreEqual(expected.Count, actual.Count()); Assert.AreEqual(expected.Count == 0, actual.IsEmpty()); } } }
public void testPutAndGet() { FastByIDMap <long?> map = new FastByIDMap <long?>(); Assert.IsNull(map.Get(500000L)); map.Put(500000L, 2L); Assert.AreEqual(2L, (long)map.Get(500000L)); }
public void testClear() { FastByIDMap <long?> map = new FastByIDMap <long?>(); map.Put(500000L, 2L); map.Clear(); Assert.AreEqual(0, map.Count()); Assert.True(map.IsEmpty()); Assert.IsNull(map.Get(500000L)); }
public void testSizeEmpty() { FastByIDMap <long> map = new FastByIDMap <long>(); Assert.AreEqual(0, map.Count()); Assert.True(map.IsEmpty()); map.Put(500000L, 2L); Assert.AreEqual(1, map.Count()); Assert.False(map.IsEmpty()); map.Remove(500000L); Assert.AreEqual(0, map.Count()); Assert.True(map.IsEmpty()); }