Пример #1
0
        public void GreatestCommonDivisor()
        {
            var rules = new List<MarkovRule>()
                            {
                                new MarkovRule("|A", "A|"),
                                new MarkovRule("|#|", "A#"),
                                new MarkovRule("|#", "#B"),
                                new MarkovRule("B", "|"),
                                new MarkovRule("A", "C"),
                                new MarkovRule("C", "|"),
                                new MarkovRule("#", "t"),
                                new MarkovRule("t", "", true)
                            };
            var algo = new MarkovAlgorithm(rules);

            Assert.That(algo.Compile("||#|||"), Is.EqualTo("|"));
            Assert.That(algo.Compile("|||#|||"), Is.EqualTo("|||"));
        }
Пример #2
0
        public void LoopsTest1()
        {
            var algo = new MarkovAlgorithm();
            algo.Rules.AddRange(
                new List<MarkovRule>()
                    {
                        new MarkovRule("a", "aa")
                    }
                );

            Assert.Throws<AlgorithmException>(delegate { string s = algo.Compile("a"); });
        }
Пример #3
0
        public void BinaryToUnary()
        {
            var algo = new MarkovAlgorithm();
            algo.Rules.AddRange(
                new List<MarkovRule>()
                    {
                        new MarkovRule("|0", "0||"),
                        new MarkovRule("1", "0|"),
                        new MarkovRule("0", "")
                    }
                );

            Assert.That(algo.Compile("110"), Is.EqualTo("||||||"));
        }