public void InconsistentComparisons2() { var bag1 = new Bag <string>(new string[] { "foo", "Bar" }, StringComparer.CurrentCulture); var bag2 = new Bag <string>(new string[] { "bada", "bing" }, StringComparer.InvariantCulture); bag1.Intersection(bag2); }
public void Intersection() { var bagOdds = new Bag <int>(new int[] { 1, 1, 1, 3, 3, 3, 5, 7, 7, 9, 11, 11, 13, 15, 17, 17, 19 }); var bagDigits = new Bag <int>(new int[] { 1, 2, 2, 3, 3, 3, 4, 5, 5, 6, 7, 7, 7, 7, 7, 7, 8, 9 }); // Algorithms work different depending on sizes, so try both ways. Bag <int> bag1 = bagOdds.Clone(); Bag <int> bag2 = bagDigits.Clone(); bag1.IntersectionWith(bag2); InterfaceTests.TestReadWriteCollectionGeneric(bag1, new int[] { 1, 3, 3, 3, 5, 7, 7, 9 }, false); bag1 = bagOdds.Clone(); bag2 = bagDigits.Clone(); bag2.IntersectionWith(bag1); InterfaceTests.TestReadWriteCollectionGeneric(bag2, new int[] { 1, 3, 3, 3, 5, 7, 7, 9 }, false); bag1 = bagOdds.Clone(); bag2 = bagDigits.Clone(); var bag3 = bag1.Intersection(bag2); InterfaceTests.TestReadWriteCollectionGeneric(bag3, new int[] { 1, 3, 3, 3, 5, 7, 7, 9 }, false); bag1 = bagOdds.Clone(); bag2 = bagDigits.Clone(); bag3 = bag2.Intersection(bag1); InterfaceTests.TestReadWriteCollectionGeneric(bag3, new int[] { 1, 3, 3, 3, 5, 7, 7, 9 }, false); // Make sure intersection with itself works. bag1 = bagDigits.Clone(); bag1.IntersectionWith(bag1); InterfaceTests.TestReadWriteCollectionGeneric(bag1, new int[] { 1, 2, 2, 3, 3, 3, 4, 5, 5, 6, 7, 7, 7, 7, 7, 7, 8, 9 }, false); bag1 = bagDigits.Clone(); bag3 = bag1.Intersection(bag1); InterfaceTests.TestReadWriteCollectionGeneric(bag3, new int[] { 1, 2, 2, 3, 3, 3, 4, 5, 5, 6, 7, 7, 7, 7, 7, 7, 8, 9 }, false); }