From ce7caec4b3beab913d801e6be7f0bed0728c791c Mon Sep 17 00:00:00 2001 From: Timothee Cour Date: Mon, 22 Feb 2021 11:13:08 -0800 Subject: add io.readChars overload (simpler, less error prone) (#16044) * add simpler to use readChars overload * use new readChars overload * Update lib/wrappers/openssl.nim Co-authored-by: Andreas Rumpf Co-authored-by: flywind --- tests/stdlib/tio.nim | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 tests/stdlib/tio.nim (limited to 'tests/stdlib/tio.nim') diff --git a/tests/stdlib/tio.nim b/tests/stdlib/tio.nim new file mode 100644 index 000000000..0da64f9c2 --- /dev/null +++ b/tests/stdlib/tio.nim @@ -0,0 +1,37 @@ +# xxx move to here other tests that belong here; io is a proper module + +import std/os +from stdtest/specialpaths import buildDir + +block: # readChars + let file = buildDir / "D20201118T205105.txt" + let s = "he\0l\0lo" + writeFile(file, s) + defer: removeFile(file) + let f = open(file) + defer: close(f) + let n = f.getFileInfo.blockSize + var buf = newString(n) + template fn = + let n2 = f.readChars(buf) + doAssert n2 == s.len + doAssert buf[0..