Exemplo n.º 1
0
 public void TestMergeKeepDuplicates()
 {
     var arg = new List<List<int>> { new List<int> { 1, 3, 5 }, new List<int> { -1, 1, 2, 4 }, new List<int> { 6, 7 } };
     var expected = new List<int> { -1, 1, 1, 2, 3, 4, 5, 6, 7 };
     var res = arg.Merge(false).ToList();
     Assert.IsTrue(expected.SequenceEqual(res), "Merge of [{0}] with duplicates gives {1} instead of {2}", string.Join(", ", arg.Select(IntsToString)), IntsToString(res), IntsToString(expected));
 }
Exemplo n.º 2
0
 public void TestMergeIsLazy()
 {
     // Elements go -4, -2, error, ...
     var badlist = Enumerable.Range(-2, 5).Select(i => i == 0 ? 1 / i : 2 * i);
     var arg = new List<IEnumerable<int>> { badlist, Enumerable.Range(-5, 5), Enumerable.Range(-3, 5) };
     var expected = new List<int> {-5, -4, -3, -2};
     var res = arg.Merge().Take(4);
     Assert.IsTrue(expected.SequenceEqual(res), "Partial enumeration of sequence merge should not raise an error");
 }
Exemplo n.º 3
0
        public void MergeTest()
        {
            List<int> l1 = new List<int>() {1, 3, 5};
            List<int> l2 = new List<int>() { 2, 4 };
            IList<int> merged = l1.Merge(l2);

            Assert.AreEqual(1, merged[0]);
            Assert.AreEqual(2, merged[1]);
            Assert.AreEqual(3, merged[2]);
            Assert.AreEqual(4, merged[3]);
            Assert.AreEqual(5, merged[4]);
        }
Exemplo n.º 4
0
 public void TestMergeCopy_WithComparison_NullList2_Throws()
 {
     IReadOnlySublist<List<int>, int> list1 = new List<int>().ToSublist();
     IExpandableSublist<List<int>, int> list2 = null;
     Func<int, int, int> comparison = Comparer<int>.Default.Compare;
     list1.Merge(list2, comparison);
 }
Exemplo n.º 5
0
 public void TestMergeCopy_WithComparer_NullDestination_Throws()
 {
     IReadOnlySublist<List<int>, int> list1 = new List<int>().ToSublist();
     IExpandableSublist<List<int>, int> list2 = new List<int>().ToSublist();
     IExpandableSublist<List<int>, int> destination = null;
     IComparer<int> comparer = Comparer<int>.Default;
     list1.Merge(list2, comparer).CopyTo(destination);
 }
Exemplo n.º 6
0
 public void TestMergeCopy_NullList2_Throws()
 {
     IReadOnlySublist<List<int>, int> list1 = new List<int>().ToSublist();
     IExpandableSublist<List<int>, int> list2 = null;
     list1.Merge(list2);
 }
Exemplo n.º 7
0
 public void TestMergeCopy_NullDestination_Throws()
 {
     IReadOnlySublist<List<int>, int> list1 = new List<int>().ToSublist();
     IExpandableSublist<List<int>, int> list2 = new List<int>().ToSublist();
     IExpandableSublist<List<int>, int> destination = null;
     list1.Merge(list2).CopyTo(destination);
 }
Exemplo n.º 8
0
 public void TestMergeCopy_NullComparison_Throws()
 {
     IReadOnlySublist<List<int>, int> list1 = new List<int>().ToSublist();
     IExpandableSublist<List<int>, int> list2 = new List<int>().ToSublist();
     Func<int, int, int> comparison = null;
     list1.Merge(list2, comparison);
 }
Exemplo n.º 9
0
 public void TestMergeCopy_NullComparer_Throws()
 {
     IReadOnlySublist<List<int>, int> list1 = new List<int>().ToSublist();
     IExpandableSublist<List<int>, int> list2 = new List<int>().ToSublist();
     IComparer<int> comparer = null;
     list1.Merge(list2, comparer);
 }
Exemplo n.º 10
0
 public void TestMergeAdd_WithComparison_NullDestination_Throws()
 {
     IReadOnlySublist<List<int>, int> list1 = new List<int>().ToSublist();
     IExpandableSublist<List<int>, int> list2 = new List<int>().ToSublist();
     IExpandableSublist<List<int>, int> destination = null;
     Func<int, int, int> comparison = Comparer<int>.Default.Compare;
     list1.Merge(list2, comparison).AddTo(destination);
 }
Exemplo n.º 11
0
 public void TestMergeAdd_WithComparer_NullList2_Throws()
 {
     IReadOnlySublist<List<int>, int> list1 = new List<int>().ToSublist();
     IExpandableSublist<List<int>, int> list2 = null;
     IComparer<int> comparer = Comparer<int>.Default;
     list1.Merge(list2, comparer);
 }