Пример #1
0
        public void MatchNumber()
        {
            const string str = "123";

            var d       = new Decomposition("#", Array.Empty <string>());
            var matches = d.Match(str, _synonyms);

            Assert.IsNotNull(matches);
            Assert.AreEqual("123", matches[0]);
        }
Пример #2
0
        public void TildeIsIgnored()
        {
            const string str = "abc ~123";

            var d       = new Decomposition("*", Array.Empty <string>());
            var matches = d.Match(str, _synonyms);

            Assert.IsNotNull(matches);
            Assert.AreEqual(str, matches[0]);
        }
Пример #3
0
        public void MatchStringWithSpace()
        {
            const string str = "abc 123";

            var d       = new Decomposition("* *", Array.Empty <string>());
            var matches = d.Match(str, _synonyms);

            Assert.IsNotNull(matches);
            Assert.AreEqual("abc", matches[0]);
            Assert.AreEqual("123", matches[1]);
        }
Пример #4
0
        public void BrotherRegression()
        {
            const string str = "my brother is philip";

            var d       = new Decomposition("*my* brother *", Array.Empty <string>());
            var matches = d.Match(str, _synonyms);

            Assert.IsNotNull(matches);
            Assert.AreEqual("", matches[0]);
            Assert.AreEqual("", matches[1]);
            Assert.AreEqual("is philip", matches[2]);
        }
Пример #5
0
        public void MatchWithSynonyms()
        {
            const string str = "hello aa bb ccc world";

            var d       = new Decomposition("* @a @b @c *", Array.Empty <string>());
            var matches = d.Match(str, _synonyms);

            Assert.IsNotNull(matches);
            Assert.AreEqual("hello", matches[0]);
            Assert.AreEqual("aa", matches[1]);
            Assert.AreEqual("bb", matches[2]);
            Assert.AreEqual("ccc", matches[3]);
            Assert.AreEqual("world", matches[4]);
        }