tmemory.nim 317 B

1234567891011121314151617
  1. import std/assertions
  2. block: # cmpMem
  3. type
  4. SomeHash = array[15, byte]
  5. var
  6. a: SomeHash
  7. b: SomeHash
  8. a[^1] = byte(1)
  9. let c = a
  10. doAssert cmpMem(a.addr, b.addr, sizeof(SomeHash)) > 0
  11. doAssert cmpMem(b.addr, a.addr, sizeof(SomeHash)) < 0
  12. doAssert cmpMem(a.addr, c.addr, sizeof(SomeHash)) == 0