File: 050.phpt

package info (click to toggle)
php-msgpack 1%3A2.2.0~rc2-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 2,200 kB
  • sloc: ansic: 3,817; xml: 416; makefile: 2
file content (111 lines) | stat: -rw-r--r-- 1,617 bytes parent folder | download | duplicates (8)
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
--TEST--
Check for array unserialization
--SKIPIF--
--FILE--
<?php
if(!extension_loaded('msgpack')) {
    dl('msgpack.' . PHP_SHLIB_SUFFIX);
}

function test($type, $variable) {
    $unserialized = msgpack_unserialize(pack('H*', $variable));

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

test('empty array:', '90');
test('array(1, 2, 3)', '93010203');
test('array(array(1, 2, 3), arr...', '93930102039304050693070809');
test('array("foo", "FOO", "Foo")', '93a3666f6fa3464f4fa3466f6f');
test('array(1, 123.45,  true, ...', '9701cb405edccccccccccdc3c293010293090807c0a3666f6f');
?>
--EXPECT--
empty array:
90
array(0) {
}
array(1, 2, 3)
93010203
array(3) {
  [0]=>
  int(1)
  [1]=>
  int(2)
  [2]=>
  int(3)
}
array(array(1, 2, 3), arr...
93930102039304050693070809
array(3) {
  [0]=>
  array(3) {
    [0]=>
    int(1)
    [1]=>
    int(2)
    [2]=>
    int(3)
  }
  [1]=>
  array(3) {
    [0]=>
    int(4)
    [1]=>
    int(5)
    [2]=>
    int(6)
  }
  [2]=>
  array(3) {
    [0]=>
    int(7)
    [1]=>
    int(8)
    [2]=>
    int(9)
  }
}
array("foo", "FOO", "Foo")
93a3666f6fa3464f4fa3466f6f
array(3) {
  [0]=>
  string(3) "foo"
  [1]=>
  string(3) "FOO"
  [2]=>
  string(3) "Foo"
}
array(1, 123.45,  true, ...
9701cb405edccccccccccdc3c293010293090807c0a3666f6f
array(7) {
  [0]=>
  int(1)
  [1]=>
  float(123.45)
  [2]=>
  bool(true)
  [3]=>
  bool(false)
  [4]=>
  array(3) {
    [0]=>
    int(1)
    [1]=>
    int(2)
    [2]=>
    array(3) {
      [0]=>
      int(9)
      [1]=>
      int(8)
      [2]=>
      int(7)
    }
  }
  [5]=>
  NULL
  [6]=>
  string(3) "foo"
}