Example #1
0
        public void SubsetsTest_EmptyNums()
        {
            var solution = new _090_Subsets2();
            var result   = solution.SubsetsWithDup(new int[] { });

            Assert.AreEqual(1, result.Count);
            AssertHelper.AssertList(new int[] { }, result[0]);
        }
Example #2
0
        public void SubsetsTest_OneItem()
        {
            var solution = new _090_Subsets2();
            var result   = solution.SubsetsWithDup(new int[] { 1 });

            Assert.AreEqual(2, result.Count);
            AssertHelper.AssertList(new int[] { }, result[0]);
            AssertHelper.AssertList(new int[] { 1 }, result[1]);
        }
Example #3
0
        public void SubsetsTest_Duplicate_2()
        {
            var solution = new _090_Subsets2();
            var result   = solution.SubsetsWithDup(new int[] { 1, 2, 2 });

            Assert.AreEqual(6, result.Count);
            AssertHelper.AssertList(new int[] { }, result[0]);
            AssertHelper.AssertList(new int[] { 1 }, result[1]);
            AssertHelper.AssertList(new int[] { 2 }, result[2]);
            AssertHelper.AssertList(new int[] { 1, 2 }, result[3]);
            AssertHelper.AssertList(new int[] { 2, 2 }, result[4]);
            AssertHelper.AssertList(new int[] { 1, 2, 2 }, result[5]);
        }
Example #4
0
        public void SubsetsTest_NotOrdered()
        {
            var solution = new _090_Subsets2();
            var result   = solution.SubsetsWithDup(new int[] { 3, 2, 1 });

            Assert.AreEqual(8, result.Count);
            AssertHelper.AssertList(new int[] { }, result[0]);
            AssertHelper.AssertList(new int[] { 1 }, result[1]);
            AssertHelper.AssertList(new int[] { 2 }, result[2]);
            AssertHelper.AssertList(new int[] { 1, 2 }, result[3]);
            AssertHelper.AssertList(new int[] { 3 }, result[4]);
            AssertHelper.AssertList(new int[] { 1, 3 }, result[5]);
            AssertHelper.AssertList(new int[] { 2, 3 }, result[6]);
            AssertHelper.AssertList(new int[] { 1, 2, 3 }, result[7]);
        }