1; Adapted from the R6RS reference implementation by Harald Glab-Phlak, which is: 2 3; Copyright 2007 William D Clinger. 4 5; Permission to copy this software, in whole or in part, to use this 6; software for any lawful purpose, and to redistribute this software 7; is granted subject to the restriction that all copies made of this 8; software must include this copyright notice in full. 9; 10; I also request that you send me a copy of any improvements that you 11; make to this software so that they may be incorporated within it to 12; the benefit of the Scheme community. 13 14(define-test-case ieee/heavy-test ieee-bytevectors-tests 15 (letrec ((roundtrip 16 (lambda (x getter setter! k endness) 17 (let ((b (make-bytevector 400))) 18 (setter! b k x endness) 19 (check (getter b k endness) => x))))) 20 (roundtrip 21 +inf.0 22 bytevector-ieee-single-ref bytevector-ieee-single-set! 0 (endianness big)) 23 24 (roundtrip 25 -inf.0 26 bytevector-ieee-single-ref bytevector-ieee-single-set! 0 (endianness big)) 27 28 29 (roundtrip 30 1e10 31 bytevector-ieee-single-ref bytevector-ieee-single-set! 0 (endianness little)) 32 33 (roundtrip 34 -0.2822580337524414 35 bytevector-ieee-single-ref bytevector-ieee-single-set! 1 (endianness big)) 36 37 (roundtrip 38 1e10 39 bytevector-ieee-single-ref bytevector-ieee-single-set! 0 (endianness big)) 40 41 (roundtrip 42 +inf.0 43 bytevector-ieee-single-ref bytevector-ieee-single-set! 1 (endianness big)) 44 (roundtrip 45 -inf.0 46 bytevector-ieee-single-ref bytevector-ieee-single-set! 1 (endianness big)) 47 48 (roundtrip 49 1e10 50 bytevector-ieee-single-ref bytevector-ieee-single-set! 1 (endianness big)) 51 52 53 (roundtrip 54 -0.2822580337524414 55 bytevector-ieee-single-ref bytevector-ieee-single-set! 1 (endianness big)) 56 57 58 (roundtrip 59 +inf.0 60 bytevector-ieee-single-ref bytevector-ieee-single-set! 1 (endianness little)) 61 62 (roundtrip 63 -inf.0 64 bytevector-ieee-single-ref bytevector-ieee-single-set! 1 (endianness little)) 65 66 (roundtrip 67 1e10 68 bytevector-ieee-single-ref bytevector-ieee-single-set! 1 (endianness little)) 69 70 (roundtrip 71 -0.2822580337524414 72 bytevector-ieee-single-ref bytevector-ieee-single-set! 1 (endianness little)) 73 74 (roundtrip 75 +inf.0 76 bytevector-ieee-single-ref bytevector-ieee-single-set! 2 (endianness big)) 77 78 (roundtrip 79 -inf.0 80 bytevector-ieee-single-ref bytevector-ieee-single-set! 2 (endianness big)) 81 82 (roundtrip 83 1e10 84 bytevector-ieee-single-ref bytevector-ieee-single-set! 2 (endianness big)) 85 (roundtrip 86 -0.2822580337524414 87 bytevector-ieee-single-ref bytevector-ieee-single-set! 2 (endianness big)) 88 (roundtrip 89 +inf.0 90 bytevector-ieee-single-ref bytevector-ieee-single-set! 2 (endianness little)) 91 (roundtrip 92 -inf.0 93 bytevector-ieee-single-ref bytevector-ieee-single-set! 2 (endianness little)) 94 (roundtrip 95 1e10 96 bytevector-ieee-single-ref bytevector-ieee-single-set! 2 (endianness little)) 97 98 ;; Double precision, offset 0, big-endian 99 (roundtrip 100 +inf.0 101 bytevector-ieee-double-ref bytevector-ieee-double-set! 0 (endianness big)) 102 103 104 (roundtrip 105 -inf.0 106 bytevector-ieee-double-ref bytevector-ieee-double-set! 0 (endianness big)) 107 108 109 (roundtrip 110 1e10 111 bytevector-ieee-double-ref bytevector-ieee-double-set! 0 (endianness big)) 112 113 114 (roundtrip 115 -0.2822580337524414 116 bytevector-ieee-double-ref bytevector-ieee-double-set! 0 (endianness big)) 117 118 ;; Double precision, offset 0, little-endian 119 (roundtrip 120 +inf.0 121 bytevector-ieee-double-ref bytevector-ieee-double-set! 0 (endianness little)) 122 123 124 (roundtrip 125 -inf.0 126 bytevector-ieee-double-ref bytevector-ieee-double-set! 0 (endianness little)) 127 128 129 130 (roundtrip 131 1e10 132 bytevector-ieee-double-ref bytevector-ieee-double-set! 0 (endianness little)) 133 134 135 (roundtrip 136 -0.2822580337524414 137 bytevector-ieee-double-ref bytevector-ieee-double-set! 0 (endianness little)) 138 139 ;; Double precision, offset 1, big-endian 140 (roundtrip 141 +inf.0 142 bytevector-ieee-double-ref bytevector-ieee-double-set! 1 (endianness big)) 143 144 (roundtrip 145 -inf.0 146 bytevector-ieee-double-ref bytevector-ieee-double-set! 1 (endianness big)) 147 148 (roundtrip 149 1e10 150 bytevector-ieee-double-ref bytevector-ieee-double-set! 1 (endianness big)) 151 152 (roundtrip 153 -0.2822580337524414 154 bytevector-ieee-double-ref bytevector-ieee-double-set! 1 (endianness big)) 155 156 ;; Double precision, offset 1, little-endian 157 158 (roundtrip 159 +inf.0 160 bytevector-ieee-double-ref bytevector-ieee-double-set! 1 (endianness little)) 161 162 (roundtrip 163 -inf.0 164 bytevector-ieee-double-ref bytevector-ieee-double-set! 1 (endianness little)) 165 166 (roundtrip 167 -0.2822580337524414 168 bytevector-ieee-double-ref bytevector-ieee-double-set! 2 (endianness big)) 169 170 ;; Double precision, offset 2, little-endian 171 172 (roundtrip 173 +inf.0 174 bytevector-ieee-double-ref bytevector-ieee-double-set! 2 (endianness little)) 175 176 (roundtrip 177 -inf.0 178 bytevector-ieee-double-ref bytevector-ieee-double-set! 2 (endianness little)) 179 180 (roundtrip 181 1e10 182 bytevector-ieee-double-ref bytevector-ieee-double-set! 2 (endianness little)) 183 184 (roundtrip 185 -0.2822580337524414 186 bytevector-ieee-double-ref bytevector-ieee-double-set! 2 (endianness little)) 187 188 ;; Double precision, offset 3, big-endian 189 190 (roundtrip 191 +inf.0 192 bytevector-ieee-double-ref bytevector-ieee-double-set! 3 (endianness big)) 193 194 (roundtrip 195 -inf.0 196 bytevector-ieee-double-ref bytevector-ieee-double-set! 3 (endianness big)) 197 198 (roundtrip 199 1e10 200 bytevector-ieee-double-ref bytevector-ieee-double-set! 3 (endianness big)) 201 202 (roundtrip 203 -0.2822580337524414 204 bytevector-ieee-double-ref bytevector-ieee-double-set! 3 (endianness big)) 205 206 ;; Double precision, offset 3, little-endian 207 208 (roundtrip 209 +inf.0 210 bytevector-ieee-double-ref bytevector-ieee-double-set! 3 (endianness little)) 211 212 (roundtrip 213 -inf.0 214 bytevector-ieee-double-ref bytevector-ieee-double-set! 3 (endianness little)) 215 216 (roundtrip 217 1e10 218 bytevector-ieee-double-ref bytevector-ieee-double-set! 3 (endianness little)) 219 220 (roundtrip 221 -0.2822580337524414 222 bytevector-ieee-double-ref bytevector-ieee-double-set! 3 (endianness little)))) 223