File: 041.phpt

package info (click to toggle)
php-msgpack 2.0.2%2B0.5.7-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 2,192 kB
  • ctags: 729
  • sloc: ansic: 6,789; xml: 702; php: 18; makefile: 1
file content (47 lines) | stat: -rw-r--r-- 759 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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
--TEST--
Check for double NaN, Inf, -Inf, 0, and -0
--FILE--
<?php
function test($type, $variable) {
    $serialized = msgpack_serialize($variable);
    $unserialized = msgpack_unserialize($serialized);

    echo $type, PHP_EOL;
    var_dump($variable);
    var_dump($unserialized);

    echo bin2hex($serialized), PHP_EOL;
    echo PHP_EOL;
}

test('double NaN:', NAN);
test('double Inf:', INF);
test('double -Inf:', -INF);
test('double 0.0:', 0.0);
test('double -0.0:', -0.0);

--EXPECTF--
double NaN:
float(NAN)
float(NAN)
cb7ff8000000000000

double Inf:
float(INF)
float(INF)
cb7ff0000000000000

double -Inf:
float(-INF)
float(-INF)
cbfff0000000000000

double 0.0:
float(0)
float(0)
cb0000000000000000

double -0.0:
float(-0)
float(-0)
cb8000000000000000