public void ContainsTest() { #pragma warning disable xUnit2017 // Do not use Contains() to check if a value exists in a collection Assert.True(_array.Contains(56)); Assert.False(_array.Contains(100)); #pragma warning restore xUnit2017 // Do not use Contains() to check if a value exists in a collection }
public void ContainsTest() { var a = new SparseArray <bool> { [5] = true, [90] = true }; Assert.That(a.Contains(true), Is.True); Assert.That(a.Contains(false), Is.False); }
public void SparseArrayContainsTest() { SparseArray <Int32> array = new SparseArray <Int32>(_values); Assert.IsTrue(array.Contains(0)); Assert.IsFalse(array.Contains(-1)); Assert.IsTrue(array.Contains(1)); Assert.IsTrue(array.Contains(2)); Assert.IsFalse(array.Contains(4)); }
public void Contains_2() { var a = new SparseArray <char>(10); a.Set(1, 'a'); Assert.IsTrue(a.Contains(1)); Assert.IsFalse(a.Contains(0)); Assert.IsFalse(a.Contains(9)); a.Set(1, 'a'); Assert.IsTrue(a.Contains(1)); Assert.IsFalse(a.Contains(0)); Assert.IsFalse(a.Contains(9)); a.Set(1, 'b'); Assert.IsTrue(a.Contains(1)); Assert.IsFalse(a.Contains(0)); Assert.IsFalse(a.Contains(9)); }
public void SparseArrayContainsTest() { SparseArray <Int32> array = new SparseArray <Int32>(this.values); array.Contains(0).ShouldBeTrue(); array.Contains(5).ShouldBeTrue(); array.Contains(10).ShouldBeTrue(); array.Contains(100).ShouldBeTrue(); array.Contains(-10).ShouldBeFalse(); array.Contains(1000).ShouldBeFalse(); }
public void Contains_ValueExists() { var sa = new SparseArray <decimal>(2, new Dictionary <int, decimal>() { { 0, 1M }, { 1, 2M } }); Assert.AreEqual(2, sa.Capacity, "Incorrect capacity."); Assert.AreEqual(2, sa.Count, "Incorrect count."); Assert.AreEqual(2, sa.Sparsity, "Incorrect sparsity."); Assert.AreEqual(1.0M, sa.SparsityPercent, "Incorrect sparsity percent."); Assert.IsTrue(sa.Keys.SequenceEqual(new List <int> { 0, 1 }), "Incorrect keys."); Assert.IsTrue(sa.ToArray().SequenceEqual(new[] { 1M, 2M }), "Unequal elements in sparse array"); Assert.IsTrue(sa.Contains(2M), "Failed to find value that should exist"); }
public void Contains_1() { var a = new SparseArray <char>(10); a.Set(1, 'a'); a.Set(5, 'e'); a.Set(3, 'c'); Assert.IsTrue(a.Contains(1)); Assert.IsTrue(a.Contains(3)); Assert.IsTrue(a.Contains(5)); Assert.IsFalse(a.Contains(0)); Assert.IsFalse(a.Contains(2)); Assert.IsFalse(a.Contains(4)); Assert.IsFalse(a.Contains(6)); a.Set(2, 'b'); a.Set(4, 'd'); Assert.IsTrue(a.Contains(1)); Assert.IsTrue(a.Contains(2)); Assert.IsTrue(a.Contains(3)); Assert.IsTrue(a.Contains(4)); Assert.IsTrue(a.Contains(5)); Assert.IsFalse(a.Contains(0)); Assert.IsFalse(a.Contains(6)); }