diff options
author | Ludovic Courtès <ludo@gnu.org> | 2011-05-06 17:43:37 +0200 |
---|---|---|
committer | Ludovic Courtès <ludo@gnu.org> | 2011-05-06 17:43:37 +0200 |
commit | 1f78c6691fbcfe059c74ac93b64a453eb2353ced (patch) | |
tree | 22dfe645512a1ddc792110faca8100df13d62204 | |
parent | a2a6c0e319b5c146c484cb1fe8ffc9b14b9a9876 (diff) | |
download | guile-1f78c6691fbcfe059c74ac93b64a453eb2353ced.tar.gz |
Fix `foreign.test' for big endian machines.
* test-suite/tests/foreign.test ("pointer<->bytevector")["pointer from
bits", "dereference-pointer"]: Fix iteration order for big endian
machines.
-rw-r--r-- | test-suite/tests/foreign.test | 28 |
1 files changed, 18 insertions, 10 deletions
diff --git a/test-suite/tests/foreign.test b/test-suite/tests/foreign.test index 60b466e1c..5ddd31c1d 100644 --- a/test-suite/tests/foreign.test +++ b/test-suite/tests/foreign.test @@ -124,24 +124,32 @@ (pass-if "pointer from bits" (let* ((bytes (iota (sizeof '*))) - (bv (u8-list->bytevector bytes))) + (bv (u8-list->bytevector bytes)) + (fold (case (native-endianness) + ((little) fold-right) + ((big) fold) + (else (error "unsupported endianness"))))) (= (pointer-address (make-pointer (bytevector-uint-ref bv 0 (native-endianness) (sizeof '*)))) - (fold-right (lambda (byte address) - (+ byte (* 256 address))) - 0 - bytes)))) + (fold (lambda (byte address) + (+ byte (* 256 address))) + 0 + bytes)))) (pass-if "dereference-pointer" (let* ((bytes (iota (sizeof '*))) - (bv (u8-list->bytevector bytes))) + (bv (u8-list->bytevector bytes)) + (fold (case (native-endianness) + ((little) fold-right) + ((big) fold) + (else (error "unsupported endianness"))))) (= (pointer-address (dereference-pointer (bytevector->pointer bv))) - (fold-right (lambda (byte address) - (+ byte (* 256 address))) - 0 - bytes))))) + (fold (lambda (byte address) + (+ byte (* 256 address))) + 0 + bytes))))) (with-test-prefix "pointer<->string" |