public void PooledList_GottenTooBig() { var bigPool = ListPool <int> .Create(1, 16, 2048); var smallPool = ListPool <int> .Create(1, 16, 16); TooBig(() => PooledList <int> .New(), h => h.List, (h, n) => h.AddRange(Enumerable.Range(0, n)), 1024); TooBig(() => bigPool.New(), h => h.List, (h, n) => h.AddRange(Enumerable.Range(0, n)), 2048); TooBig(() => smallPool.New(), h => h.List, (h, n) => h.AddRange(Enumerable.Range(0, n)), 16); }
public void PooledList_GlobalPool() { for (var i = 0; i < 100; i++) { using var obj = PooledList <string> .New(); var lst = obj.List; Assert.AreEqual(0, lst.Count); lst.Add("qux"); lst.Add("foo"); lst.Add("bar"); lst.Add("baz"); Assert.IsTrue(exp.SequenceEqual(lst)); } }
private static void PooledList_Simple_Impl(ListPool <string> pool) { for (var i = 0; i < 100; i++) { using var obj = i % 2 == 0 ? pool.New() : PooledList <string> .New(pool); var lst = obj.List; Assert.AreEqual(0, lst.Count); lst.Add("qux"); lst.Add("foo"); lst.Add("bar"); lst.Add("baz"); Assert.IsTrue(exp.SequenceEqual(lst)); } }