Esempio n. 1
0
        public static void AllTokensTest()
        {
            var         tokens = GitCmdTokens.Tokenize("a - -- \"b\"");
            GitCmdToken token;

            token = tokens.Dequeue();
            Assert.AreEqual(GitCmdTokenType.Literal, token.Type);
            Assert.AreEqual("a", token.Value);
            Assert.AreEqual(0, token.Position);

            token = tokens.Dequeue();
            Assert.AreEqual(GitCmdTokenType.Dash, token.Type);
            Assert.AreEqual("-", token.Value);
            Assert.AreEqual(2, token.Position);

            token = tokens.Dequeue();
            Assert.AreEqual(GitCmdTokenType.DoubleDash, token.Type);
            Assert.AreEqual("--", token.Value);
            Assert.AreEqual(4, token.Position);

            token = tokens.Dequeue();
            Assert.AreEqual(GitCmdTokenType.Literal, token.Type);
            Assert.AreEqual("b", token.Value);
            Assert.AreEqual(7, token.Position);
        }
Esempio n. 2
0
        public static void ConcatQuotedLiteralTest()
        {
            var tokens = GitCmdTokens.Tokenize("ab\"cd\"ef\"gh\"ij");

            Assert.AreEqual(2, tokens.Count());

            var token = GitCmdTokens.Tokenize("ab\"cd\"ef\"gh\"ij").First();

            Assert.AreEqual(GitCmdTokenType.Literal, token.Type);
            Assert.AreEqual("abcdefghij", token.Value);
            Assert.AreEqual(0, token.Position);
        }
Esempio n. 3
0
        public static void QuotedLiteralTest()
        {
            var tokens = GitCmdTokens.Tokenize("\"a b c\"");

            Assert.AreEqual(2, tokens.Count());

            var token = GitCmdTokens.Tokenize("\"a b c\"").First();

            Assert.AreEqual(GitCmdTokenType.Literal, token.Type);
            Assert.AreEqual("a b c", token.Value);
            Assert.AreEqual(0, token.Position);
        }
Esempio n. 4
0
        public static void QuotedQuoteTest()
        {
            var bs     = "\\";
            var qu     = "\"";
            var tokens = GitCmdTokens.Tokenize($"{qu}{bs}{qu}{qu}");

            Assert.AreEqual(2, tokens.Count());

            var token = tokens.First();

            Assert.AreEqual(GitCmdTokenType.Literal, token.Type);
            Assert.AreEqual($"{qu}", token.Value);
            Assert.AreEqual(0, token.Position);
        }
Esempio n. 5
0
        public static void SimpleLiteralTest()
        {
            var tokens = GitCmdTokens.Tokenize("a");

            Assert.AreEqual(2, tokens.Count());

            var token = tokens.First();

            Assert.AreEqual(GitCmdTokenType.Literal, token.Type);
            Assert.AreEqual("a", token.Value);
            Assert.AreEqual(0, token.Position);

            Assert.IsTrue(token.ToString().Contains("a"));
            Assert.IsTrue(token.ToString().Contains("0"));
            Assert.IsTrue(token.ToString().Contains($"{GitCmdTokenType.Literal}"));
        }
Esempio n. 6
0
 public static void ThrowsTest()
 {
     Throws(() => GitCmdTokens.Tokenize("\""));
 }