Advertisement
Guest User

Untitled

a guest
Oct 20th, 2018
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.65 KB | None | 0 0
  1. using System.Collections.Generic;
  2. using Microsoft.VisualStudio.TestTools.UnitTesting;
  3. using TableParser;
  4. using System;
  5.  
  6. namespace Parser.Tests
  7. {
  8. [TestClass]
  9. public class UnitTest1
  10. {
  11. void Test(string input, string[] expected)
  12. {
  13. var actual = FieldsParserTask.GetFields(input);
  14. for (var i = 0; i < actual.Count; i++)
  15. Assert.AreEqual(expected[i], actual[i]);
  16. }
  17.  
  18. [TestMethod]
  19. public void OneTwoThree()
  20. {
  21. Test("1 2 3", new[] { "1", "2", "3" });
  22. }
  23.  
  24. [TestMethod]
  25. public void AllTypeBrackets()
  26. {
  27. Test("a \"b\" \'c\'", new[] { "a", "b", "c" });
  28. }
  29.  
  30. [TestMethod]
  31. public void HiddenBackSlash()
  32. {
  33. Test("\"a \\\"c\\\"\"", new[] { "a \"c\"" });
  34. }
  35.  
  36. [TestMethod]
  37. public void BracketsWithoutSpace()
  38. {
  39. Test("a\"b\"c", new[] { "a", "b", "c" });
  40. }
  41.  
  42. [TestMethod]
  43. public void SlashBrackets()
  44. {
  45. Test(@"\""a""", new[] { "\\", "a" });
  46. }
  47.  
  48. [TestMethod]
  49. public void DoubleBracketsInBrackets()
  50. {
  51. Test("\"\'a\'\"", new[] { "'a'" });
  52. }
  53.  
  54. [TestMethod]
  55. public void SingleBracketsInBrackets()
  56. {
  57. Test("'\\'a\\''", new[] { "'a'" });
  58. }
  59.  
  60. [TestMethod]
  61. public void SpaceBracket()
  62. {
  63. Test("a \"b", new[] { "a", "b" });
  64. }
  65.  
  66. [TestMethod]
  67. public void OpenBracketKillSlash()
  68. {
  69. Test("'\"a\"", new[] { "\"a\"" });
  70. }
  71.  
  72. [TestMethod]
  73. public void SpaceBetwen()
  74. {
  75. Test("a b", new[] { "a", "b" });
  76. }
  77.  
  78. [TestMethod]
  79. public void DoubleSlash()
  80. {
  81. Test(@"""\\""", new[] { "\\" });
  82. }
  83.  
  84.  
  85. [TestMethod]
  86. public void BracketSpace()
  87. {
  88. Test("\" ", new[] { " " });
  89. }
  90.  
  91. [TestMethod]
  92. public void SpaceAfter()
  93. {
  94. Test("a ", new[] { "a" });
  95. }
  96.  
  97. [TestMethod]
  98. public void PreSpace()
  99. {
  100. Test(" b", new[] { "b" });
  101. }
  102.  
  103. [TestMethod]
  104. public void Empty()
  105. {
  106. Test("", new string[] { });
  107. }
  108.  
  109. [TestMethod]
  110. public void JustBracket()
  111. {
  112. Test("\"", new[] { "" });
  113. }
  114.  
  115. [TestMethod]
  116. public void HellWorld()
  117. {
  118. Test("Hello world", new[] { "Hello", "world" });
  119. }
  120. }
  121. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement