public void ClearTest()
        {
            var q = new SPSCQueue <int>(10);

            //Inserts 10 items.
            QueueTestSetup.SplitQueue(q);

            Assert.AreEqual(10, q.Count);
            q.Clear();
            Assert.AreEqual(0, q.Count);

            Assert.IsTrue(q.IsEmpty);
        }
Example #2
0
        public void SPSCQueue()
        {
            // ADD values
            for (int i = 0; i < COUNT; i++)
            {
                _spscQueue.TryEnqueue(i);
            }

            for (int i = 0; i < COUNT; i++)
            {
                _spscQueue.TryDequeue(out long result);
            }

            _spscQueue.Clear();
        }
        public void EnqueueTest()
        {
            var q = new SPSCQueue <int>(10);

            for (int i = 0; i < 10; i++)
            {
                q.TryEnqueue(i * i);
            }

            Assert.AreEqual(10, q.Count);
            Assert.AreEqual(10, q.Capacity);

            q.Clear();

            Assert.AreEqual(0, q.Count);
            Assert.AreEqual(10, q.Capacity);
        }