public void When_Array_Has_Multiple_Elements_Combine_Them_To_Get_The_Length(string[] fragments, int expected)
        {
            StringAssembler assembler = new StringAssembler();
            int             result    = assembler.FindLongestAssembledString(fragments);

            Assert.That(result, Is.EqualTo(expected));
        }
        public void When_Array_Is_Empty_Return_Zero()
        {
            StringAssembler assembler = new StringAssembler();
            int             result    = assembler.FindLongestAssembledString(new string[0]);

            Assert.That(result, Is.EqualTo(0));
        }
        public void When_String_Contains_Duplicate_Letters_Return_True(string word, bool expected)
        {
            StringAssembler assembler = new StringAssembler();
            bool            result    = assembler.CheckForDuplicateLetters(word);

            Assert.That(result, Is.EqualTo(expected));
        }
        public void When_All_Array_Elements_Have_Repeated_Letters_Return_Minus_One()
        {
            StringAssembler assembler = new StringAssembler();
            int             result    = assembler.FindLongestAssembledString(new string[3] {
                "banana", "potato", "racecar"
            });

            Assert.That(result, Is.EqualTo(-1));
        }
        public void When_Array_Has_One_Element_With_Duplicate_Characters_Return_Minus_One()
        {
            StringAssembler assembler = new StringAssembler();
            int             result    = assembler.FindLongestAssembledString(new string[1] {
                "coc"
            });

            Assert.That(result, Is.EqualTo(-1));
        }
Beispiel #6
0
        public static void Test()
        {
            Random Random = new Random(5);

            for (int j = 0; j < 10; j++)
            {
                int[][] Array = new int[Random.Next(1, 5)][];

                Console.WriteLine("===================== 分组组合算法测试(GroupingdataCombinationGenerate) ==========================");

                for (int idx = 0; idx < Array.Length; ++idx)
                {
                    Array[idx] = new int[Random.Next(1, 5)];
                    for (int i = 0; i < Array[idx].Length; i++)
                    {
                        Array[idx][i] = Random.Next();
                    }

                    Console.WriteLine("数组 : " + StringAssembler.StringSplice("   ", Array[idx]));
                }

                AlgorithmCombination.GroupingdataCombinationGenerate(Array, Print);
            }
        }