Ejemplo n.º 1
0
 public void EdgeTest()
 {
     Assert.AreEqual(new List <string>(), CodeWars.Anagrams("dddddd", new List <string> {
         "xxxxx"
     }));
     Assert.AreEqual(new List <string>(), CodeWars.Anagrams("ddddddddddd", new List <string> {
         "nnnnnnnnnn"
     }));
     Assert.AreEqual(new List <string>(), CodeWars.Anagrams("ln", new List <string> {
         "cx"
     }));
 }
Ejemplo n.º 2
0
 public void SampleTest()
 {
     Assert.AreEqual(new List <string> {
         "a"
     }, CodeWars.Anagrams("a", new List <string> {
         "a", "b", "c", "d"
     }));
     Assert.AreEqual(new List <string> {
         "carer", "arcre", "carre"
     }, CodeWars.Anagrams("racer", new List <string> {
         "carer", "arcre", "carre", "racrs", "racers", "arceer", "raccer", "carrer", "cerarr"
     }));
 }
Ejemplo n.º 3
0
 public void FixedTest()
 {
     Assert.AreEqual(new List <string> {
         "ab", "ba"
     }, CodeWars.Anagrams("ab", new List <string> {
         "ab", "aa", "bb", "cc", "ac", "bc", "cd", "ba"
     }));
     Assert.AreEqual(new List <string> {
         "aabb", "bbaa", "abab", "baba", "baab"
     }, CodeWars.Anagrams("abba", new List <string> {
         "aabb", "bbaa", "abcd", "abbba", "baaab", "abbab", "abbaa", "babaa", "abab", "baba", "baab"
     }));
     Assert.AreEqual(new List <string> {
     }, CodeWars.Anagrams("big", new List <string> {
         "gig", "dib", "bid", "biig"
     }));
 }
Ejemplo n.º 4
0
        public void RandomTest()
        {
            const int    Tests  = 1000;
            StreamWriter stream = new StreamWriter(@"D:\test.txt");

            for (int i = 0; i < Tests; ++i)
            {
                string        word  = generateWord();
                List <string> words = new string[rnd.Next(3, 20)].Select(_ => rnd.Next(0, 2) == 0 ? String.Concat(word.OrderBy(__ => rnd.Next())) : generateWord()).ToList();

                List <string> expected = solution(word, words);
                List <string> actual   = CodeWars.Anagrams(word, words);


                Assert.AreEqual(expected, actual);

                foreach (string wrd in words)
                {
                    stream.Write(wrd);
                }
                stream.Write("Test numer:{0}", i);
            }
        }