Added cmpMem export (#16484)

* added cmpMem export

* updates

* fix test

* Tiny changelog change

* Add a dot.

Co-authored-by: Clyybber <darkmine956@gmail.com>
This commit is contained in:
Antonis Geralis
2020-12-29 14:27:08 +02:00
committed by GitHub
parent fc1a4faf56
commit d5a3c2c2da
4 changed files with 81 additions and 49 deletions

15
tests/stdlib/tmemory.nim Normal file
View File

@@ -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