diff options
author | ringabout <43030857+ringabout@users.noreply.github.com> | 2023-01-26 03:56:19 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-01-25 14:56:19 -0500 |
commit | c4d3d650baa88820dadeafa81ca75b6e495084f2 (patch) | |
tree | 51abc7bbe6aa06965a0ef2e335775ab35e474662 /tests | |
parent | d54a7f078d29445bc79ec5f117a2ceb73761b4c4 (diff) | |
download | Nim-c4d3d650baa88820dadeafa81ca75b6e495084f2.tar.gz |
fixes #21273; fixes an io.readLine off by one bug [backport 1.0] (#21276)
fixes #21273; io.readLine off by one
Diffstat (limited to 'tests')
-rw-r--r-- | tests/stdlib/tio.nim | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/stdlib/tio.nim b/tests/stdlib/tio.nim index 0e20d6495..ca411379c 100644 --- a/tests/stdlib/tio.nim +++ b/tests/stdlib/tio.nim @@ -36,3 +36,21 @@ block: # readChars break doAssert n2s == @[2,2,2,1,0] doAssert s2 == s + + +import std/strutils + +block: # bug #21273 + let FILE = buildDir / "D20220119T134305.txt" + + let hex = "313632313920313632343720313632353920313632363020313632393020323035363520323037323120323131353020323239393820323331303520323332313020323332343820323332363820" + + + writeFile FILE, parseHexStr(hex) + + doAssert readFile(FILE).toHex == hex + + let f = open(FILE) + var s = newString(80) + while f.readLine(s): + doAssert s.toHex == hex |