summary refs log tree commit diff stats
path: root/tests/stdlib
diff options
context:
space:
mode:
authorflywind <xzsflywind@gmail.com>2021-04-21 21:07:36 +0800
committerGitHub <noreply@github.com>2021-04-21 15:07:36 +0200
commitc631648cb31b11d61d249e0745181acb0fcc30cc (patch)
tree85f8119e9fb0500e24d61c99182edfa69b3a67c6 /tests/stdlib
parent2951f89374e9797fa5567b5afd4effb3149c1fd5 (diff)
downloadNim-c631648cb31b11d61d249e0745181acb0fcc30cc.tar.gz
close #9372 add std/tempfiles (#17361)
* close #9372 add std/tempfile
Diffstat (limited to 'tests/stdlib')
-rw-r--r--tests/stdlib/ttempfiles.nim17
1 files changed, 17 insertions, 0 deletions
diff --git a/tests/stdlib/ttempfiles.nim b/tests/stdlib/ttempfiles.nim
new file mode 100644
index 000000000..29ef2fb2b
--- /dev/null
+++ b/tests/stdlib/ttempfiles.nim
@@ -0,0 +1,17 @@
+import std/[os, tempfiles]
+
+
+doAssert createTempDir("nim", "tmp") != createTempDir("nim", "tmp")
+
+block:
+  var t1 = createTempFile("nim", ".tmp")
+  var t2 = createTempFile("nim", ".tmp")
+  doAssert t1.path != t2.path
+
+  write(t1.fd, "1234")
+  doAssert readAll(t2.fd) == ""
+
+  close(t1.fd)
+  close(t2.fd)
+  removeFile(t1.path)
+  removeFile(t2.path)