using System.Collections.Generic;
using System.Environment;
public static void Main()
("", Array.Empty<string>()),
("Single line", new []{"Single line"}),
("Line 1\nLine 2", new []{"Line 1", "Line 2"}),
("Line 1\rLine 2", new []{"Line 1", "Line 2"}),
("Line 1\r\nLine 2", new []{"Line 1", "Line 2"}),
("Line 1<NEL>Line 2", new []{"Line 1", "Line 2"}),
("No break\\<NEL>between these", new []{"No break<NEL>between these"}),
("No break\\\rbetween these", new []{"No break\rbetween these"}),
("No break\\\nbetween these", new []{"No break\nbetween these"}),
("No break\\\r\nbetween these", new []{"No break\r\nbetween these"}),
("Line 1\rLine 2\nLine 3\r\nLine 4\\<NEL>continues<NEL>a\\\r\\\n\\\r\nends", new []{"Line 1", "Line 2", "Line 3", "Line 4<NEL>continues", "a\r\n\r\nends"}),
("Line 1<NEL\rLine2", new []{"Line 1<NEL", "Line2"}),
("Line 1<NEL\rLine2\\", new []{"Line 1<NEL", "Line2\\"}),
("Line 1<NE", new []{"Line 1<NE"}),
("\r\n\n\r", new []{"", "", "", ""}),
("Line\r", new []{"Line", ""}),
("Line\n", new []{"Line", ""}),
("Line\r\n", new []{"Line", ""}),
("Line\n\r", new []{"Line", "", ""}),
("Line\fLine", new []{"Line\fLine"})
foreach(var testCase in input)
var expected = testCase.Item2;
var actual = GetLines(testCase.Item1);
Console.WriteLine($"{i} " + testCase.Item1.Replace("\r", @"\r").Replace("\n", @"\n"));
if(expected.Length != actual.Length)
Console.WriteLine($"\t✖ Array lenghts differ: Expected {expected.Length}, actual {actual.Length}");
Console.WriteLine("\t\tExpected:");
foreach(string l in expected) Console.WriteLine("\t\t\t" + l.Replace("\r", @"\r").Replace("\n", @"\n"));
Console.WriteLine("\t\tActual");
foreach(string l in actual) Console.WriteLine("\t\t\t" + l.Replace("\r", @"\r").Replace("\n", @"\n"));
for(int j = 0; j < expected.Length; j++){
if(expected[j] != actual[j])
Console.WriteLine($"\t✖ Line {j + 1} differs: Expected: {expected[j].Replace("\r", @"\r").Replace("\n", @"\n")}, Actual: {actual[j].Replace("\r", @"\r").Replace("\n", @"\n")}");
else Console.WriteLine("\t✔");
Console.WriteLine("✔ All tests passed");
Console.WriteLine($"✖ {fail} tests failed");
public static string[] GetLines(string text)
returnValue = new string[] { };
string text = "asdasd/nsdaasd";
if (text.Split(Environment.NewLine).Length > 0)
returnValue = new string[] { new text.Split(Environment.NewLine).ToArray() };