예제 #1
0
        public void PooledStack_GlobalPool()
        {
            for (var i = 0; i < 100; i++)
            {
                using var obj = PooledStack <string> .New();

                var stack = obj.Stack;

                Assert.AreEqual(0, stack.Count);

                stack.Push("qux");
                stack.Push("foo");
                stack.Push("bar");
                stack.Push("baz");

                Assert.IsTrue(exp.SequenceEqual(stack));
            }
        }
예제 #2
0
        private static void PooledStack_Simple_Impl(StackPool <string> pool)
        {
            for (var i = 0; i < 100; i++)
            {
                using var obj = i % 2 == 0 ? pool.New() : PooledStack <string> .New(pool);

                var stack = obj.Stack;

                Assert.AreEqual(0, stack.Count);

                stack.Push("qux");
                stack.Push("foo");
                stack.Push("bar");
                stack.Push("baz");

                Assert.IsTrue(exp.SequenceEqual(stack));
            }
        }
예제 #3
0
        public void PooledStack_GottenTooBig()
        {
            var bigPool = StackPool <int> .Create(1, 16, 2048);

            var smallPool = StackPool <int> .Create(1, 16, 16);

            TooBig(() => PooledStack <int> .New(), h => h.Stack, (h, n) => { for (var i = 0; i < n; i++)
                                                                             {
                                                                                 h.Push(i);
                                                                             }
                   }, 1024);
            TooBig(() => bigPool.New(), h => h.Stack, (h, n) => { for (var i = 0; i < n; i++)
                                                                  {
                                                                      h.Push(i);
                                                                  }
                   }, 2048);
            TooBig(() => smallPool.New(), h => h.Stack, (h, n) => { for (var i = 0; i < n; i++)
                                                                    {
                                                                        h.Push(i);
                                                                    }
                   }, 16);
        }