File: test-ieee-float.lisp

package info (click to toggle)
cl-postmodern 20211113.git9d4332f-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 3,528 kB
  • sloc: lisp: 22,909; sql: 76; makefile: 2
file content (31 lines) | stat: -rw-r--r-- 1,386 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
;;;; -*- Mode: LISP; Syntax: Ansi-Common-Lisp; Base: 10; Package: CL-POSTGRES-TESTS; -*-
(in-package :cl-postgres-tests)

(def-suite :cl-postgres-ieee-float
    :description "Test suite for cl-postgres functions in ieee-floats.lisp"
    :in :cl-postgres)

(in-suite :cl-postgres-ieee-float)

(test ieee-float
  (is (equal (cl-postgres-ieee-floats::encode-float64 1234567.89)
             4698053240367874048))
  (is (equal (cl-postgres-ieee-floats::decode-float64 4698053240367874048)
             1234567.875d0))
  (is (equal (cl-postgres-ieee-floats::encode-float64 -4698053240.28)
             13975092309851635712))
  (is (equal (cl-postgres-ieee-floats::decode-float64 13975092309851635712)
             -4.69805312d9))
  (is (equal (cl-postgres-ieee-floats::encode-float32 1234567.89)
             1234613311))
  (is (equal (cl-postgres-ieee-floats::decode-float32 1234613311)
             1234567.9))
  (is (equal (cl-postgres-ieee-floats::encode-float32 -4698053240.28)
             3482059597))
  (is (equal (cl-postgres-ieee-floats::decode-float32 3482059597)
            -4.698053e9))
  (cl-postgres-ieee-floats::make-float-converters encode-float128 decode-float128 15 112 nil)
  (is (equal (encode-float128 1234567.89)
             85170166357702954636935397302398353408))
  (is (equal (decode-float128 85170166357702954636935397302398353408)
             1234567.875d0)))