@@ -81,6 +81,8 @@ public function testIntegerTypes()
81
81
$ this ->assertEncode ('-13371337 ' , -13371337 , ['integer.type ' => 'decimal ' ]);
82
82
$ this ->assertEncode ('0xcc07c9 ' , 13371337 , ['integer.type ' => 'hexadecimal ' ]);
83
83
$ this ->assertEncode ('-0xcc07c9 ' , -13371337 , ['integer.type ' => 'hexadecimal ' ]);
84
+ $ this ->assertEncode ('0xCC07C9 ' , 13371337 , ['integer.type ' => 'hexadecimal ' , 'hex.capitalize ' => true ]);
85
+ $ this ->assertEncode ('-0xCC07C9 ' , -13371337 , ['integer.type ' => 'hexadecimal ' , 'hex.capitalize ' => true ]);
84
86
}
85
87
86
88
public function testInvalidIntegerType ()
@@ -156,6 +158,8 @@ public function testFloatIntegers()
156
158
$ this ->assertEncode ('1337 ' , 1337 , $ encoder , 1337.0 );
157
159
$ this ->assertEncode ('-1337 ' , -1337 , $ encoder , -1337.0 );
158
160
$ this ->assertEncode ('2000000000 ' , 2000000000 , $ encoder , 2000000000.0 );
161
+
162
+ $ this ->assertEncode ('0xf ' , 15 , ['float.integers ' => true , 'integer.type ' => 'hexadecimal ' ], 15.0 );
159
163
}
160
164
161
165
public function testMaximumFloatIntegers ()
@@ -223,6 +227,8 @@ public function testStringEncoding()
223
227
$ this ->assertEncode ('"\t\$foo" ' , "\t\$foo " );
224
228
$ this ->assertEncode ('"\t{\$foo}" ' , "\t{ \$foo} " );
225
229
$ this ->assertEncode ('"\x00" ' , "\x00" );
230
+ $ this ->assertEncode ('"\xff" ' , "\xFF" );
231
+ $ this ->assertEncode ('"\xFF" ' , "\xFF" , ['hex.capitalize ' => true ]);
226
232
$ this ->assertEncode ("' \r' " , "\r" , ['string.escape ' => false ]);
227
233
}
228
234
@@ -240,7 +246,7 @@ public function testUtf8String()
240
246
$ encoder = new PHPEncoder (['string.utf8 ' => true ]);
241
247
242
248
$ this ->assertEncode ('"\nA" ' , "\nA " , $ encoder );
243
- $ this ->assertEncode ('"\nA\u{c4}\x00" ' , "\nAÄ \x00" , $ encoder );
249
+ $ this ->assertSame ('"\nA\u{c4}\x00" ' , $ encoder -> encode ( "\nAÄ \x00" ) );
244
250
245
251
if (version_compare (PHP_VERSION , '7 ' , '< ' )) {
246
252
$ this ->assertSame ('"\u{a2}" ' , $ encoder ->encode ("\xC2\xA2" ));
@@ -253,6 +259,9 @@ public function testUtf8String()
253
259
$ this ->assertEncode ('"\u{10348}" ' , "\u{10348}" , $ encoder );
254
260
$ this ->assertEncode ('"\u{e5}\u{e4}\u{f6}\u{c5}\u{c4}\u{d6}" ' , 'åäöÅÄÖ ' , $ encoder );
255
261
}
262
+
263
+ $ encoder ->setOption ('hex.capitalize ' , true );
264
+ $ this ->assertSame ('"\nA\u{C4}\x00" ' , $ encoder ->encode ("\nAÄ \x00" ));
256
265
}
257
266
258
267
public function testGMPEncoding ()
0 commit comments