summary refs log tree commit diff stats
path: root/tests
diff options
context:
space:
mode:
authorAraq <rumpf_a@web.de>2011-12-31 02:21:01 -0800
committerAraq <rumpf_a@web.de>2011-12-31 02:21:01 -0800
commit61ff32933789ea5d0c327d7a5c5d7b1f4dfc8499 (patch)
tree28ff00cbc675e9e1113637bf2d952d2ace616d00 /tests
parent9fdfda136c4d3ec0d8e72867345b427b30e88ef4 (diff)
parentcf2078aed8c0b706f2e3576914558c9530fcb832 (diff)
downloadNim-61ff32933789ea5d0c327d7a5c5d7b1f4dfc8499.tar.gz
Merge pull request #79 from Tass/master
readAll
Diffstat (limited to 'tests')
-rw-r--r--tests/specials.nim7
-rw-r--r--tests/system/helpers/readall_echo.nim1
-rw-r--r--tests/system/io.nim29
3 files changed, 37 insertions, 0 deletions
diff --git a/tests/specials.nim b/tests/specials.nim
index a1aa1bc5a..ea3e58fbf 100644
--- a/tests/specials.nim
+++ b/tests/specials.nim
@@ -128,12 +128,19 @@ proc rejectThreadTests(r: var TResults, options: string) =
   rejectSingleTest(r, "tests/threads/tthreadanalysis3", options)
   rejectSingleTest(r, "tests/threads/tthreadheapviolation1", options)
 
+# ------------------------- IO tests -----------------------------------
+
+proc runIOTests(r: var TResults, options: string) =
+  compileSingleTest(r, "tests/system/helpers/readall_echo.nim", options)
+  runSingleTest(r, "tests/system/io", options)
+
 # ------------------------- register special tests here -----------------------
 proc runSpecialTests(r: var TResults, options: string) =
   runRodFiles(r, options)
   runDLLTests(r, options)
   runGCTests(r, options)
   runThreadTests(r, options & " --threads:on")
+  runIOTests(r, options)
 
 proc rejectSpecialTests(r: var TResults, options: string) =
   rejectThreadTests(r, options)
diff --git a/tests/system/helpers/readall_echo.nim b/tests/system/helpers/readall_echo.nim
new file mode 100644
index 000000000..2890217ef
--- /dev/null
+++ b/tests/system/helpers/readall_echo.nim
@@ -0,0 +1 @@
+echo(stdin.readAll)
diff --git a/tests/system/io.nim b/tests/system/io.nim
new file mode 100644
index 000000000..4837f7093
--- /dev/null
+++ b/tests/system/io.nim
@@ -0,0 +1,29 @@
+discard """output: '''[OK] stdin
+
+[OK] file'''"""
+
+import
+  unittest, osproc, streams, os, readall_echo
+const STRING_DATA = """Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet."""
+const TEST_FILE = "tests/testdata/string"
+
+proc echoLoop(str: string): string =
+  result = ""
+  var process = startProcess(os.addFileExt("tests/system/helpers/readall_echo", ExeExt))
+  var input = process.inputStream
+  input.write(str)
+  input.close()
+  var output = process.outputStream
+  discard process.waitForExit
+  while not output.atEnd:
+    result.add(output.readLine)
+    
+suite "io":
+  suite "readAll":
+    test "stdin":
+      check:
+        echoLoop(STRING_DATA) == STRING_DATA
+        echoLoop(STRING_DATA[0..3999]) == STRING_DATA[0..3999]
+    test "file":
+      check:
+        readFile(TEST_FILE) == STRING_DATA