コード例 #1
0
 public void Test5()
 {
     var builder = new DynPowerPhraseBuilder(new[] {"Ei!", "hi", "hi hi"});
     var result = builder.Build(new[] {MoveType.E, MoveType.SW, MoveType.SW, MoveType.SW, MoveType.SE, MoveType.SW, MoveType.SW, MoveType.SE, MoveType.SW, MoveType.SW});
     Console.WriteLine(result);
     Assert.IsTrue(Regex.IsMatch(result, @"..hi.hi hi", RegexOptions.IgnoreCase));
 }
コード例 #2
0
 public void Test6()
 {
     var builder = new DynPowerPhraseBuilder(new[] {"hi", "hihi", "hihihi", "hihihihi", "hihihihihi", "hihihihihihi", "hihihihihihihi", "hihihihihihihihi", "hihihihihihihihihi", "hihihihihihihihihihi" });
     var moves = Enumerable.Range(0, 10000).Select(i => MoveType.SW).ToArray();
     var sw = Stopwatch.StartNew();
     var result = builder.Build(moves);
     sw.Stop();
     Console.WriteLine(sw.Elapsed);
     Assert.IsTrue(Regex.IsMatch(result, @"(hi)+", RegexOptions.IgnoreCase));
 }
コード例 #3
0
        public void Test10()
        {
            var phrases = new[] {"hi", "ei hi ei"};
            var builder = new DynPowerPhraseBuilder(phrases);

            int score;
            var result = builder.Build(ToMoves("ei hi ei"), out score);
            Console.WriteLine(result);
            Console.WriteLine(score);
        }
コード例 #4
0
        public void Test7()
        {
            var builder = new DynPowerPhraseBuilder(new[] {"hi", "ie!"});

            int score;
            var result = builder.Build(ToMoves("hie!"), out score);
            Console.WriteLine(result);

            Assert.IsTrue(Regex.IsMatch(result, @".ie!"));
            Assert.AreEqual(306, score);
        }
コード例 #5
0
        public void Test8()
        {
            var phrases = new[] {"Ph'nglui mglw'nafh Cthulhu R'lyeh wgah'nagl fhtagn.", "Cthulhu R'lyeh wgah'nagl", "nglui mglw'nafh Cthulhu", "Cthulhu", "fhtagn."};
            var builder = new DynPowerPhraseBuilder(phrases);

            int score;
            var result = builder.Build(ToMoves("Ph'nglui mglw'nafh Cthulhu R'lyeh wgah'nagl fhtagn."), out score);
            Console.WriteLine(result);

            Assert.IsTrue(Regex.IsMatch(result, @"...................cthulhu r'lyeh wgah'nagl.fhtagn\."));
            Assert.AreEqual(662, score);
        }
コード例 #6
0
 public void Test4()
 {
     var builder = new DynPowerPhraseBuilder(new[] {"Ei!"});
     Assert.AreEqual("ei!ei!", builder.Build(new[] {MoveType.E, MoveType.SW, MoveType.W, MoveType.E, MoveType.SW, MoveType.W}));
 }
コード例 #7
0
 public void Test2()
 {
     var builder = new DynPowerPhraseBuilder(null);
     Assert.AreEqual(3, builder.Build(new[] {MoveType.E, MoveType.SW, MoveType.W}).Length);
 }
コード例 #8
0
 public void Test1()
 {
     var builder = new DynPowerPhraseBuilder(null);
     Assert.AreEqual("", builder.Build(new MoveType[0]));
 }
コード例 #9
0
        public void Test9()
        {
            var phrases = new[] {"aa", "!hi!"};
            var builder = new DynPowerPhraseBuilder(phrases);

            int score;
            var result = builder.Build(ToMoves("!hi!zz!hi!"), out score);
            Console.WriteLine(result);

            Assert.IsTrue(Regex.IsMatch(result, @"!hi!...aa.", RegexOptions.IgnoreCase));
            Assert.AreEqual(612, score);
        }