Skip to content

Commit 876856c

Browse files
committed
stdlib: floating point test: add tests for Float80.{nextUp,nextDown}
1 parent 80a1682 commit 876856c

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

test/1_stdlib/FloatingPoint.swift.gyb

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,25 @@ FloatingPoint.test("Float80/HashValueZero") {
314314
expectEqual(zero.hashValue, negativeZero.hashValue)
315315
}
316316

317+
let float80NextUpDownTests: [(Float80, Float80)] = [
318+
(.nan, .nan),
319+
(.greatestFiniteMagnitude, .infinity),
320+
(0x1.ffff_ffff_ffff_fffep-1, 1.0), (1.0, 0x1.0000_0000_0000_0002p+0),
321+
(0.0, .leastNonzeroMagnitude),
322+
(0x1.efff_ffff_ffff_fffep-1, 0x1.fp-1),
323+
(0x1.fp-1, 0x1.f000_0000_0000_0002p-1),
324+
]
325+
326+
FloatingPoint.test("Float80.nextUp, .nextDown")
327+
.forEach(in: float80NextUpDownTests) {
328+
(prev, succ) in
329+
330+
expectBitwiseEqual(succ, prev.nextUp)
331+
expectBitwiseEqual(prev, succ.nextDown)
332+
expectBitwiseEqual(-succ, (-prev).nextDown)
333+
expectBitwiseEqual(-prev, (-succ).nextUp)
334+
}
335+
317336
#endif
318337

319338
% for FloatSelf in ['Float32', 'Float64']:

0 commit comments

Comments
 (0)