示例#1
0
 public override Object Clone()
 {
     try
     {
         HashMap <K, V> map = (HashMap <K, V>)base.Clone();
         map.elementCount = 0;
         map.elementData  = NewElementArray(elementData.Length);
         map.PutAll(this);
         return(map);
     }
     catch (NotSupportedException)
     {
         return(null);
     }
 }
示例#2
0
        public void TestPutAll()
        {
            HashMap <Object, Object> hm2 = new HashMap <Object, Object>();

            hm2.PutAll(hm);

            for (int i = 0; i < 1000; i++)
            {
                Assert.IsTrue(hm2.Get(i.ToString()).Equals((i)), "Assert.Failed to Clear all elements");
            }

            Map <Object, Object> mockMap = new MockMap();

            hm2 = new HashMap <Object, Object>();
            hm2.PutAll(mockMap);
            Assert.AreEqual(0, hm2.Size(), "Size should be 0");
        }
示例#3
0
        public void TestPutAllMockMapNull()
        {
            HashMap <Object, Object> hashMap = new HashMap <Object, Object>();

            try
            {
                hashMap.PutAll(new MockMapNull());
                Assert.Fail("Should throw NullReferenceException");
            }
            catch (NullReferenceException)
            {
            }

            try
            {
                hashMap = new HashMap <Object, Object>(new MockMapNull());
                Assert.Fail("Should throw NullReferenceException");
            }
            catch (NullReferenceException)
            {
            }
        }