public void TestContains()
        {
            CopyOnWriteArraySet <Object> full = PopulatedSet(3);

            Assert.IsTrue(full.Contains(1));
            Assert.IsFalse(full.Contains(five));
        }
        public void TestAdd2()
        {
            CopyOnWriteArraySet <Object> full = PopulatedSet(3);

            full.Add(1);
            Assert.AreEqual(3, full.Size());
        }
        public void TestAdd3()
        {
            CopyOnWriteArraySet <Object> full = PopulatedSet(3);

            full.Add(three);
            Assert.IsTrue(full.Contains(three));
        }
        public void TestClear()
        {
            CopyOnWriteArraySet <Object> full = PopulatedSet(3);

            full.Clear();
            Assert.AreEqual(0, full.Size());
        }
        public void TestSize()
        {
            CopyOnWriteArraySet <Object> empty = new CopyOnWriteArraySet <Object>();
            CopyOnWriteArraySet <Object> full  = PopulatedSet(3);

            Assert.AreEqual(3, full.Size());
            Assert.AreEqual(0, empty.Size());
        }
        public void TestRemove()
        {
            CopyOnWriteArraySet <Object> full = PopulatedSet(3);

            full.Remove(1);
            Assert.IsFalse(full.Contains(one));
            Assert.AreEqual(2, full.Size());
        }
        public void TestIsEmpty()
        {
            CopyOnWriteArraySet <Object> empty = new CopyOnWriteArraySet <Object>();
            CopyOnWriteArraySet <Object> full  = PopulatedSet(3);

            Assert.IsTrue(empty.IsEmpty());
            Assert.IsFalse(full.IsEmpty());
        }
        public void TestRemoveAll()
        {
            CopyOnWriteArraySet <Object> full = PopulatedSet(3);
            ArrayList <Object>           v    = new ArrayList <Object>();

            v.Add(1);
            v.Add(2);
            full.RemoveAll(v);
            Assert.AreEqual(1, full.Size());
        }
        public void TestToArray()
        {
            CopyOnWriteArraySet <Object> full = PopulatedSet(3);

            Object[] o = full.ToArray();
            Assert.AreEqual(3, o.Length);
            Assert.AreEqual(0, o[0]);
            Assert.AreEqual(1, o[1]);
            Assert.AreEqual(2, o[2]);
        }
        public void TestToString()
        {
            CopyOnWriteArraySet <Object> full = PopulatedSet(3);
            String s = full.ToString();

            for (int i = 0; i < 3; ++i)
            {
                Assert.IsTrue(s.IndexOf(i.ToString()) >= 0);
            }
        }
        public void TestAddAll2()
        {
            CopyOnWriteArraySet <Object> full = PopulatedSet(3);
            ArrayList <Object>           v    = new ArrayList <Object>();

            v.Add(3);
            v.Add(4);
            v.Add(1);  // will not add this element
            full.AddAll(v);
            Assert.AreEqual(5, full.Size());
        }
        public void TestAddAll()
        {
            CopyOnWriteArraySet <Object> full = PopulatedSet(3);
            ArrayList <Object>           v    = new ArrayList <Object>();

            v.Add(three);
            v.Add(four);
            v.Add(five);
            full.AddAll(v);
            Assert.AreEqual(6, full.Size());
        }
        public void TestContainsAll()
        {
            CopyOnWriteArraySet <Object> full = PopulatedSet(3);
            ArrayList <Object>           v    = new ArrayList <Object>();

            v.Add(1);
            v.Add(2);
            Assert.IsTrue(full.ContainsAll(v));
            v.Add(6);
            Assert.IsFalse(full.ContainsAll(v));
        }
        public void TestIterator()
        {
            CopyOnWriteArraySet <Object> full = PopulatedSet(3);
            Iterator <Object>            i    = full.Iterator();
            int j;

            for (j = 0; i.HasNext; j++)
            {
                Assert.AreEqual(j, i.Next());
            }
            Assert.AreEqual(3, j);
        }
        public void TestConstructor3()
        {
            Object[] ints = new Object[SIZE];
            for (int i = 0; i < SIZE - 1; ++i)
            {
                ints[i] = i;
            }
            CopyOnWriteArraySet <Object> a = new CopyOnWriteArraySet <Object>(Arrays.AsList(ints));

            for (int i = 0; i < SIZE; ++i)
            {
                Assert.IsTrue(a.Contains(ints[i]));
            }
        }
        public void TestIteratorRemove()
        {
            CopyOnWriteArraySet <Object> full = PopulatedSet(3);
            Iterator <Object>            it   = full.Iterator();

            it.Next();
            try
            {
                it.Remove();
                ShouldThrow();
            }
            catch (NotSupportedException)
            {}
        }
        static CopyOnWriteArraySet <Object> PopulatedSet(int n)
        {
            CopyOnWriteArraySet <Object> a = new CopyOnWriteArraySet <Object>();

            Assert.IsTrue(a.IsEmpty());

            for (int i = 0; i < n; ++i)
            {
                a.Add(i);
            }

            Assert.IsFalse(a.IsEmpty());
            Assert.AreEqual(n, a.Size());
            return(a);
        }
        public void TestEquals()
        {
            CopyOnWriteArraySet <Object> a = PopulatedSet(3);
            CopyOnWriteArraySet <Object> b = PopulatedSet(3);

            Assert.IsTrue(a.Equals(b));
            Assert.IsTrue(b.Equals(a));
            Assert.AreEqual(a.GetHashCode(), b.GetHashCode());
            a.Add(m1);
            Assert.IsFalse(a.Equals(b));
            Assert.IsFalse(b.Equals(a));
            b.Add(m1);
            Assert.IsTrue(a.Equals(b));
            Assert.IsTrue(b.Equals(a));
            Assert.AreEqual(a.GetHashCode(), b.GetHashCode());
        }
        public void TestConstructor()
        {
            CopyOnWriteArraySet <Object> a = new CopyOnWriteArraySet <Object>();

            Assert.IsTrue(a.IsEmpty());
        }