summary refs log tree commit diff stats
path: root/tests/stdlib
diff options
context:
space:
mode:
authorAntonis Geralis <43617260+planetis-m@users.noreply.github.com>2020-12-29 14:27:08 +0200
committerGitHub <noreply@github.com>2020-12-29 13:27:08 +0100
commitd5a3c2c2da2e3b2f6deeb2c1cd5430db90bc4fd5 (patch)
treed804dd9244a8e8362e50ccc3aa0b04f3cc3b2770 /tests/stdlib
parentfc1a4faf568424b221e6690257ee96c66e68408e (diff)
downloadNim-d5a3c2c2da2e3b2f6deeb2c1cd5430db90bc4fd5.tar.gz
Added cmpMem export (#16484)
* added cmpMem export

* updates

* fix test

* Tiny changelog change

* Add a dot.

Co-authored-by: Clyybber <darkmine956@gmail.com>
Diffstat (limited to 'tests/stdlib')
-rw-r--r--tests/stdlib/tmemory.nim15
1 files changed, 15 insertions, 0 deletions
diff --git a/tests/stdlib/tmemory.nim b/tests/stdlib/tmemory.nim
new file mode 100644
index 000000000..25b5d526a
--- /dev/null
+++ b/tests/stdlib/tmemory.nim
@@ -0,0 +1,15 @@
+
+block: # cmpMem
+  type
+    SomeHash = array[15, byte]
+
+  var
+    a: SomeHash
+    b: SomeHash
+
+  a[^1] = byte(1)
+  let c = a
+
+  doAssert cmpMem(a.addr, b.addr, sizeof(SomeHash)) > 0
+  doAssert cmpMem(b.addr, a.addr, sizeof(SomeHash)) < 0
+  doAssert cmpMem(a.addr, c.unsafeAddr, sizeof(SomeHash)) == 0