Exemple #1
0
        private static void TestGetPalindromes(string text)
        {
            var sw = new Stopwatch();

            Implementation1.count = 0;
            sw.Restart();
            var expected = Implementation1.GetPalindromes(text).ToArray();

            sw.Stop();
            var simpleCount = Implementation1.count;
            var simpleTime  = sw.Elapsed;

            Implementation2.count = 0;
            sw.Restart();
            var actual = Implementation2.GetPalindromes(text).ToArray();

            sw.Stop();
            var newCount = Implementation2.count;
            var newTime  = sw.Elapsed;

            Console.WriteLine("べた実装 {0}, {2}. 新実装 {1}, {3}", simpleCount, newCount, simpleTime, newTime);

            if (!expected.OrderBy(x => x).SequenceEqual(actual.OrderBy(x => x)))
            {
                Console.WriteLine("error GetPalindromes");

                Console.WriteLine(string.Join(", ", expected));
                Console.WriteLine(string.Join(", ", actual));
            }
        }
Exemple #2
0
        private static void TestGetSubstrings(string text)
        {
            var expected = SimpleImplementation.GetSubstrings(text).ToArray();
            var actual   = Implementation1.GetSubstrings(text).ToArray();

            if (!expected.OrderBy(x => x).SequenceEqual(actual.OrderBy(x => x)))
            {
                Console.WriteLine("error GetSbustrings");
            }
        }
Exemple #3
0
        private static void TestGetPalindromes(string text)
        {
            var expected = SimpleImplementation.GetPalindromes(text).OrderBy(x => x).ToArray();
            var actual   = Implementation1.GetPalindromes(text).OrderBy(x => x).ToArray();

            if (!expected.SequenceEqual(actual))
            {
                Console.WriteLine("error GetPalindromes");

                Console.WriteLine(string.Join(", ", expected));
                Console.WriteLine(string.Join(", ", actual));
            }
        }
Exemple #4
0
        private static void Write(string text)
        {
            Console.WriteLine("----- substrings -----");
            foreach (var x in Implementation1.GetSubstrings(text))
            {
                Console.WriteLine(x);
            }

            Console.WriteLine("----- palindromes -----");
            foreach (var x in Implementation1.GetPalindromes(text))
            {
                Console.WriteLine(x);
            }
        }