コード例 #1
0
        public virtual void TestDifferentKeysSameHashCode()
        {
            Hashtable4TestCase.Key key1  = new Hashtable4TestCase.Key(1);
            Hashtable4TestCase.Key key2  = new Hashtable4TestCase.Key(1);
            Hashtable4TestCase.Key key3  = new Hashtable4TestCase.Key(2);
            Hashtable4             table = new Hashtable4(2);

            table.Put(key1, "foo");
            table.Put(key2, "bar");
            Assert.AreEqual("foo", table.Get(key1));
            Assert.AreEqual("bar", table.Get(key2));
            Assert.AreEqual(2, CountKeys(table));
            table.Put(key2, "baz");
            Assert.AreEqual("foo", table.Get(key1));
            Assert.AreEqual("baz", table.Get(key2));
            Assert.AreEqual(2, CountKeys(table));
            table.Put(key1, "spam");
            Assert.AreEqual("spam", table.Get(key1));
            Assert.AreEqual("baz", table.Get(key2));
            Assert.AreEqual(2, CountKeys(table));
            table.Put(key3, "eggs");
            Assert.AreEqual("spam", table.Get(key1));
            Assert.AreEqual("baz", table.Get(key2));
            Assert.AreEqual("eggs", table.Get(key3));
            Assert.AreEqual(3, CountKeys(table));
            table.Put(key2, "mice");
            Assert.AreEqual("spam", table.Get(key1));
            Assert.AreEqual("mice", table.Get(key2));
            Assert.AreEqual("eggs", table.Get(key3));
            Assert.AreEqual(3, CountKeys(table));
        }
コード例 #2
0
        private Hashtable4TestCase.Key[] CreateKeys(int begin, int end)
        {
            int factor = 10;
            int count  = (end - begin);

            Hashtable4TestCase.Key[] keys = new Hashtable4TestCase.Key[count * factor];
            for (int i = 0; i < count; ++i)
            {
                int baseIndex = i * factor;
                for (int j = 0; j < factor; ++j)
                {
                    keys[baseIndex + j] = new Hashtable4TestCase.Key(begin + i);
                }
            }
            return(keys);
        }
コード例 #3
0
ファイル: Hashtable4TestCase.cs プロジェクト: Galigator/db4o
		public virtual void TestDifferentKeysSameHashCode()
		{
			Hashtable4TestCase.Key key1 = new Hashtable4TestCase.Key(1);
			Hashtable4TestCase.Key key2 = new Hashtable4TestCase.Key(1);
			Hashtable4TestCase.Key key3 = new Hashtable4TestCase.Key(2);
			Hashtable4 table = new Hashtable4(2);
			table.Put(key1, "foo");
			table.Put(key2, "bar");
			Assert.AreEqual("foo", table.Get(key1));
			Assert.AreEqual("bar", table.Get(key2));
			Assert.AreEqual(2, CountKeys(table));
			table.Put(key2, "baz");
			Assert.AreEqual("foo", table.Get(key1));
			Assert.AreEqual("baz", table.Get(key2));
			Assert.AreEqual(2, CountKeys(table));
			table.Put(key1, "spam");
			Assert.AreEqual("spam", table.Get(key1));
			Assert.AreEqual("baz", table.Get(key2));
			Assert.AreEqual(2, CountKeys(table));
			table.Put(key3, "eggs");
			Assert.AreEqual("spam", table.Get(key1));
			Assert.AreEqual("baz", table.Get(key2));
			Assert.AreEqual("eggs", table.Get(key3));
			Assert.AreEqual(3, CountKeys(table));
			table.Put(key2, "mice");
			Assert.AreEqual("spam", table.Get(key1));
			Assert.AreEqual("mice", table.Get(key2));
			Assert.AreEqual("eggs", table.Get(key3));
			Assert.AreEqual(3, CountKeys(table));
		}
コード例 #4
0
ファイル: Hashtable4TestCase.cs プロジェクト: Galigator/db4o
		private Hashtable4TestCase.Key[] CreateKeys(int begin, int end)
		{
			int factor = 10;
			int count = (end - begin);
			Hashtable4TestCase.Key[] keys = new Hashtable4TestCase.Key[count * factor];
			for (int i = 0; i < count; ++i)
			{
				int baseIndex = i * factor;
				for (int j = 0; j < factor; ++j)
				{
					keys[baseIndex + j] = new Hashtable4TestCase.Key(begin + i);
				}
			}
			return keys;
		}