Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections.Generic;
- using Microsoft.VisualStudio.TestTools.UnitTesting;
- using TableParser;
- using System;
- namespace Parser.Tests
- {
- [TestClass]
- public class UnitTest1
- {
- void Test(string input, string[] expected)
- {
- var actual = FieldsParserTask.GetFields(input);
- for (var i = 0; i < actual.Count; i++)
- Assert.AreEqual(expected[i], actual[i]);
- }
- [TestMethod]
- public void OneTwoThree()
- {
- Test("1 2 3", new[] { "1", "2", "3" });
- }
- [TestMethod]
- public void AllTypeBrackets()
- {
- Test("a \"b\" \'c\'", new[] { "a", "b", "c" });
- }
- [TestMethod]
- public void HiddenBackSlash()
- {
- Test("\"a \\\"c\\\"\"", new[] { "a \"c\"" });
- }
- [TestMethod]
- public void BracketsWithoutSpace()
- {
- Test("a\"b\"c", new[] { "a", "b", "c" });
- }
- [TestMethod]
- public void SlashBrackets()
- {
- Test(@"\""a""", new[] { "\\", "a" });
- }
- [TestMethod]
- public void DoubleBracketsInBrackets()
- {
- Test("\"\'a\'\"", new[] { "'a'" });
- }
- [TestMethod]
- public void SingleBracketsInBrackets()
- {
- Test("'\\'a\\''", new[] { "'a'" });
- }
- [TestMethod]
- public void SpaceBracket()
- {
- Test("a \"b", new[] { "a", "b" });
- }
- [TestMethod]
- public void OpenBracketKillSlash()
- {
- Test("'\"a\"", new[] { "\"a\"" });
- }
- [TestMethod]
- public void SpaceBetwen()
- {
- Test("a b", new[] { "a", "b" });
- }
- [TestMethod]
- public void DoubleSlash()
- {
- Test(@"""\\""", new[] { "\\" });
- }
- [TestMethod]
- public void BracketSpace()
- {
- Test("\" ", new[] { " " });
- }
- [TestMethod]
- public void SpaceAfter()
- {
- Test("a ", new[] { "a" });
- }
- [TestMethod]
- public void PreSpace()
- {
- Test(" b", new[] { "b" });
- }
- [TestMethod]
- public void Empty()
- {
- Test("", new string[] { });
- }
- [TestMethod]
- public void JustBracket()
- {
- Test("\"", new[] { "" });
- }
- [TestMethod]
- public void HellWorld()
- {
- Test("Hello world", new[] { "Hello", "world" });
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement