Skip to content

Commit 6f76871

Browse files
committed
add native scalar test case
1 parent 0f68944 commit 6f76871

29 files changed

+483
-29
lines changed

tests/004_decode_bool.phpt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,20 @@ if ($obj instanceof Tutorial_Boolean) {
2020
} else {
2121
var_dump($obj);
2222
}
23+
24+
ini_set("protocolbuffers.native_scalars", 1);
25+
$obj = ProtocolBuffers::decode("Tutorial_Boolean", $data);
26+
27+
if ($obj instanceof Tutorial_Boolean) {
28+
if ($obj->getValue() === true) {
29+
echo "OK" . PHP_EOL;
30+
} else {
31+
var_dump($obj);
32+
}
33+
} else {
34+
var_dump($obj);
35+
}
36+
2337
--EXPECT--
38+
OK
2439
OK

tests/004_decode_bytes.phpt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,20 @@ if ($obj instanceof Tutorial_Bytes) {
1818
} else {
1919
var_dump($obj);
2020
}
21+
22+
ini_set("protocolbuffers.native_scalars", 1);
23+
$obj = ProtocolBuffers::decode("Tutorial_Bytes", $bytes);
24+
25+
if ($obj instanceof Tutorial_Bytes) {
26+
if ($obj->getValue() === $droid) {
27+
echo "OK" . PHP_EOL;
28+
} else {
29+
var_dump($obj);
30+
}
31+
} else {
32+
var_dump($obj);
33+
}
34+
2135
--EXPECT--
36+
OK
2237
OK

tests/004_decode_double_sample.phpt

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,24 @@ $obj = ProtocolBuffers::decode("Tutorial_Double", $bytes);
1010

1111
if ($obj instanceof Tutorial_Double) {
1212
if (round($obj->getValue(), 2) == 1.05) {
13-
echo "OK";
13+
echo "OK" . PHP_EOL;
14+
} else {
15+
var_dump($obj);
16+
}
17+
} else {
18+
var_dump($obj);
19+
}
20+
21+
ini_set("protocolbuffers.native_scalars", 1);
22+
if ($obj instanceof Tutorial_Double) {
23+
if (round($obj->getValue(), 2) === 1.05) {
24+
echo "OK" . PHP_EOL;
1425
} else {
1526
var_dump($obj);
1627
}
1728
} else {
1829
var_dump($obj);
1930
}
2031
--EXPECT--
32+
OK
2133
OK

tests/004_decode_fixed32_init.phpt

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,26 @@ $obj = ProtocolBuffers::decode("Tutorial_Fixed32", $bytes);
1010

1111
if ($obj instanceof Tutorial_Fixed32) {
1212
if ($obj->getValue() == 0) {
13-
echo "OK";
13+
echo "OK" . PHP_EOL;
1414
} else {
1515
var_dump($obj);
1616
}
1717
} else {
1818
var_dump($obj);
1919
}
20+
21+
ini_set("protocolbuffers.native_scalars", 1);
22+
$obj = ProtocolBuffers::decode("Tutorial_Fixed32", $bytes);
23+
if ($obj instanceof Tutorial_Fixed32) {
24+
if ($obj->getValue() === 0) {
25+
echo "OK" . PHP_EOL;
26+
} else {
27+
var_dump($obj);
28+
}
29+
} else {
30+
var_dump($obj);
31+
}
32+
2033
--EXPECT--
34+
OK
2135
OK

tests/004_decode_fixed32_max.phpt

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,26 @@ $obj = ProtocolBuffers::decode("Tutorial_Fixed32", $bytes);
1313

1414
if ($obj instanceof Tutorial_Fixed32) {
1515
if ($obj->getValue() == 4294967295) {
16-
echo "OK";
16+
echo "OK" . PHP_EOL;
1717
} else {
1818
var_dump($obj);
1919
}
2020
} else {
2121
var_dump($obj);
2222
}
23+
24+
ini_set("protocolbuffers.native_scalars", 1);
25+
$obj = ProtocolBuffers::decode("Tutorial_Fixed32", $bytes);
26+
if ($obj instanceof Tutorial_Fixed32) {
27+
if ($obj->getValue() === 4294967295) {
28+
echo "OK" . PHP_EOL;
29+
} else {
30+
var_dump($obj);
31+
}
32+
} else {
33+
var_dump($obj);
34+
}
35+
2336
--EXPECT--
37+
OK
2438
OK

tests/004_decode_float_sample.phpt

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,26 @@ $obj = ProtocolBuffers::decode("Tutorial_Float", $bytes);
1313

1414
if ($obj instanceof Tutorial_Float) {
1515
if (round($obj->getValue(), 2) == 1.05) {
16-
echo "OK";
16+
echo "OK" . PHP_EOL;
1717
} else {
1818
var_dump($obj);
1919
}
2020
} else {
2121
var_dump($obj);
2222
}
23+
24+
ini_set("protocolbuffers.native_scalars", 1);
25+
$obj = ProtocolBuffers::decode("Tutorial_Float", $bytes);
26+
if ($obj instanceof Tutorial_Float) {
27+
if (round($obj->getValue(), 2) === 1.05) {
28+
echo "OK" . PHP_EOL;
29+
} else {
30+
var_dump($obj);
31+
}
32+
} else {
33+
var_dump($obj);
34+
}
35+
2336
--EXPECT--
37+
OK
2438
OK

tests/004_decode_float_signed.phpt

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,26 @@ $obj = ProtocolBuffers::decode("Tutorial_Float", $bytes);
1313

1414
if ($obj instanceof Tutorial_Float) {
1515
if (round($obj->getValue(), 2) == -1.05) {
16-
echo "OK";
16+
echo "OK" . PHP_EOL;
1717
} else {
1818
var_dump($obj);
1919
}
2020
} else {
2121
var_dump($obj);
2222
}
23+
24+
ini_set("protocolbuffers.native_scalars", 1);
25+
$obj = ProtocolBuffers::decode("Tutorial_Float", $bytes);
26+
if ($obj instanceof Tutorial_Float) {
27+
if (round($obj->getValue(), 2) === -1.05) {
28+
echo "OK" . PHP_EOL;
29+
} else {
30+
var_dump($obj);
31+
}
32+
} else {
33+
var_dump($obj);
34+
}
35+
2336
--EXPECT--
37+
OK
2438
OK

tests/004_decode_int32_init.phpt

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,26 @@ $obj = ProtocolBuffers::decode("Tutorial_Integer32", $bytes);
1313

1414
if ($obj instanceof Tutorial_Integer32) {
1515
if ($obj->getValue() == 0) {
16-
echo "OK";
16+
echo "OK" . PHP_EOL;
1717
} else {
1818
var_dump($obj);
1919
}
2020
} else {
2121
var_dump($obj);
2222
}
23+
24+
ini_set("protocolbuffers.native_scalars", 1);
25+
$obj = ProtocolBuffers::decode("Tutorial_Integer32", $bytes);
26+
if ($obj instanceof Tutorial_Integer32) {
27+
if ($obj->getValue() === 0) {
28+
echo "OK" . PHP_EOL;
29+
} else {
30+
var_dump($obj);
31+
}
32+
} else {
33+
var_dump($obj);
34+
}
35+
2336
--EXPECT--
37+
OK
2438
OK

tests/004_decode_int32_max.phpt

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,26 @@ $obj = ProtocolBuffers::decode("Tutorial_Integer32", $bytes);
1313

1414
if ($obj instanceof Tutorial_Integer32) {
1515
if ($obj->getValue() == 2147483647) {
16-
echo "OK";
16+
echo "OK" . PHP_EOL;
1717
} else {
1818
var_dump($obj);
1919
}
2020
} else {
2121
var_dump($obj);
2222
}
23+
24+
ini_set("protocolbuffers.native_scalars", 1);
25+
$obj = ProtocolBuffers::decode("Tutorial_Integer32", $bytes);
26+
if ($obj instanceof Tutorial_Integer32) {
27+
if ($obj->getValue() === 2147483647) {
28+
echo "OK" . PHP_EOL;
29+
} else {
30+
var_dump($obj);
31+
}
32+
} else {
33+
var_dump($obj);
34+
}
35+
2336
--EXPECT--
37+
OK
2438
OK

tests/004_decode_int32_min.phpt

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,25 @@ $obj = ProtocolBuffers::decode("Tutorial_Integer32", $bytes);
1313

1414
if ($obj instanceof Tutorial_Integer32) {
1515
if ($obj->getValue() == -2147483648) {
16-
echo "OK";
16+
echo "OK" . PHP_EOL;
17+
} else {
18+
var_dump($obj);
19+
}
20+
} else {
21+
var_dump($obj);
22+
}
23+
24+
ini_set("protocolbuffers.native_scalars", 1);
25+
$obj = ProtocolBuffers::decode("Tutorial_Integer32", $bytes);
26+
if ($obj instanceof Tutorial_Integer32) {
27+
if ($obj->getValue() == -2147483648) {
28+
echo "OK" . PHP_EOL;
1729
} else {
1830
var_dump($obj);
1931
}
2032
} else {
2133
var_dump($obj);
2234
}
2335
--EXPECT--
36+
OK
2437
OK

0 commit comments

Comments
 (0)