Fixed 7478: splitLines keepEol option (#8621)

This commit is contained in:
Iván Montes
2018-08-13 11:42:50 +02:00
committed by Andreas Rumpf
parent e839c01f5b
commit ee29370f60
2 changed files with 29 additions and 13 deletions

View File

@@ -199,6 +199,12 @@ proc testRFind =
assert "0123456789ABCDEFGAH".rfind({'A'..'C'}, 13) == 12
assert "0123456789ABCDEFGAH".rfind({'G'..'H'}, 13) == -1
proc testSplitLines() =
let fixture = "a\nb\rc\r\nd"
assert len(fixture.splitLines) == 4
assert splitLines(fixture) == @["a", "b", "c", "d"]
assert splitLines(fixture, keepEol=true) == @["a\n", "b\r", "c\r\n", "d"]
proc testCountLines =
proc assertCountLines(s: string) = assert s.countLines == s.splitLines.len
assertCountLines("")
@@ -229,7 +235,7 @@ proc testParseInts =
assert "72".parseHexInt == 114
assert "FF".parseHexInt == 255
assert "ff".parseHexInt == 255
assert "fF".parseHexInt == 255
assert "fF".parseHexInt == 255
assert "0x7_2".parseHexInt == 114
rejectParse "".parseHexInt
rejectParse "_".parseHexInt
@@ -252,6 +258,7 @@ proc testParseInts =
testDelete()
testFind()
testRFind()
testSplitLines()
testCountLines()
testParseInts()