@@ -251,6 +251,77 @@ public function test65EnumerationsSet()
251
251
$ this ->assertTrue ($ enum ->valid ());
252
252
}
253
253
254
+ public function testGetBinaryBitsetLe ()
255
+ {
256
+ $ enumSet = new EnumSet ('MabeEnumTest\TestAsset\Enum65 ' );
257
+
258
+ $ enum1 = Enum65::ONE ;
259
+ $ enum2 = Enum65::TWO ;
260
+ $ enum3 = Enum65::SIXTYFIVE ;
261
+ $ enum4 = Enum65::SIXTYFOUR ;
262
+
263
+ $ this ->assertNull ($ enumSet ->attach ($ enum1 ));
264
+ $ this ->assertSame ("\x01\x00\x00\x00\x00\x00\x00\x00\x00" , $ enumSet ->getBinaryBitsetLe ());
265
+ $ this ->assertTrue ($ enumSet ->contains ($ enum1 ));
266
+
267
+ $ this ->assertNull ($ enumSet ->attach ($ enum2 ));
268
+ $ this ->assertSame ("\x03\x00\x00\x00\x00\x00\x00\x00\x00" , $ enumSet ->getBinaryBitsetLe ());
269
+ $ this ->assertTrue ($ enumSet ->contains ($ enum2 ));
270
+
271
+ $ this ->assertNull ($ enumSet ->attach ($ enum3 ));
272
+ $ this ->assertSame ("\x03\x00\x00\x00\x00\x00\x00\x00\x01" , $ enumSet ->getBinaryBitsetLe ());
273
+ $ this ->assertTrue ($ enumSet ->contains ($ enum3 ));
274
+
275
+ $ this ->assertNull ($ enumSet ->attach ($ enum4 ));
276
+ $ this ->assertSame ("\x03\x00\x00\x00\x00\x00\x00\x80\x01" , $ enumSet ->getBinaryBitsetLe ());
277
+ $ this ->assertTrue ($ enumSet ->contains ($ enum4 ));
278
+
279
+ $ this ->assertSame (4 , $ enumSet ->count ());
280
+
281
+ $ this ->assertNull ($ enumSet ->detach ($ enum2 ));
282
+ $ this ->assertSame ("\x01\x00\x00\x00\x00\x00\x00\x80\x01" , $ enumSet ->getBinaryBitsetLe ());
283
+ $ this ->assertFalse ($ enumSet ->contains ($ enum2 ));
284
+
285
+ $ this ->assertSame (3 , $ enumSet ->count ());
286
+ }
287
+
288
+ public function testGetBinaryBitsetBe ()
289
+ {
290
+ $ enumSet = new EnumSet ('MabeEnumTest\TestAsset\Enum65 ' );
291
+
292
+ $ enum1 = Enum65::ONE ;
293
+ $ enum2 = Enum65::TWO ;
294
+ $ enum3 = Enum65::SIXTYFIVE ;
295
+ $ enum4 = Enum65::SIXTYFOUR ;
296
+
297
+ $ this ->assertNull ($ enumSet ->attach ($ enum1 ));
298
+ $ this ->assertSame ("\x00\x00\x00\x00\x00\x00\x00\x00\x01" , $ enumSet ->getBinaryBitsetBe ());
299
+ $ this ->assertTrue ($ enumSet ->contains ($ enum1 ));
300
+
301
+ $ this ->assertNull ($ enumSet ->attach ($ enum2 ));
302
+ $ this ->assertSame ("\x00\x00\x00\x00\x00\x00\x00\x00\x03" , $ enumSet ->getBinaryBitsetBe ());
303
+ $ this ->assertTrue ($ enumSet ->contains ($ enum2 ));
304
+
305
+ $ this ->assertNull ($ enumSet ->attach ($ enum3 ));
306
+ $ this ->assertSame ("\x01\x00\x00\x00\x00\x00\x00\x00\x03" , $ enumSet ->getBinaryBitsetBe ());
307
+ $ this ->assertTrue ($ enumSet ->contains ($ enum3 ));
308
+
309
+ $ this ->assertNull ($ enumSet ->attach ($ enum4 ));
310
+ $ this ->assertSame ("\x01\x80\x00\x00\x00\x00\x00\x00\x03" , $ enumSet ->getBinaryBitsetBe ());
311
+ $ this ->assertTrue ($ enumSet ->contains ($ enum4 ));
312
+
313
+ $ this ->assertSame (4 , $ enumSet ->count ());
314
+
315
+ $ this ->assertNull ($ enumSet ->detach ($ enum2 ));
316
+ $ this ->assertSame ("\x01\x80\x00\x00\x00\x00\x00\x00\x01" , $ enumSet ->getBinaryBitsetBe ());
317
+ $ this ->assertFalse ($ enumSet ->contains ($ enum2 ));
318
+
319
+ $ this ->assertSame (3 , $ enumSet ->count ());
320
+ }
321
+
322
+ /**
323
+ * @deprecated
324
+ */
254
325
public function testGetBitset ()
255
326
{
256
327
$ enumSet = new EnumSet ('MabeEnumTest\TestAsset\Enum65 ' );
@@ -265,7 +336,7 @@ public function testGetBitset()
265
336
$ this ->assertTrue ($ enumSet ->contains ($ enum1 ));
266
337
267
338
$ this ->assertNull ($ enumSet ->attach ($ enum2 ));
268
- $ this ->assertSame (' 000000000000000003 ' , \bin2hex ( $ enumSet ->getBitset () ));
339
+ $ this ->assertSame ("\x00\x00\x00\x00\x00\x00\x00\x00\x03" , $ enumSet ->getBitset ());
269
340
$ this ->assertTrue ($ enumSet ->contains ($ enum2 ));
270
341
271
342
$ this ->assertNull ($ enumSet ->attach ($ enum3 ));
@@ -285,6 +356,33 @@ public function testGetBitset()
285
356
$ this ->assertSame (3 , $ enumSet ->count ());
286
357
}
287
358
359
+ public function testSetBinaryBitsetLe ()
360
+ {
361
+ $ enumSet = new EnumSet ('MabeEnumTest\TestAsset\Enum65 ' );
362
+ $ enumSet ->setBinaryBitsetLe ("\x01\x00\x00\x00\x00\x00\x00\x80\x01" );
363
+
364
+ $ this ->assertTrue ($ enumSet ->contains (Enum65::ONE ));
365
+ $ this ->assertFalse ($ enumSet ->contains (Enum65::TWO ));
366
+ $ this ->assertTrue ($ enumSet ->contains (Enum65::SIXTYFIVE ));
367
+ $ this ->assertTrue ($ enumSet ->contains (Enum65::SIXTYFOUR ));
368
+ $ this ->assertTrue ($ enumSet ->count () == 3 );
369
+ }
370
+
371
+ public function testSetBinaryBitsetBe ()
372
+ {
373
+ $ enumSet = new EnumSet ('MabeEnumTest\TestAsset\Enum65 ' );
374
+ $ enumSet ->setBinaryBitsetBe ("\x01\x80\x00\x00\x00\x00\x00\x00\x01" );
375
+
376
+ $ this ->assertTrue ($ enumSet ->contains (Enum65::ONE ));
377
+ $ this ->assertFalse ($ enumSet ->contains (Enum65::TWO ));
378
+ $ this ->assertTrue ($ enumSet ->contains (Enum65::SIXTYFIVE ));
379
+ $ this ->assertTrue ($ enumSet ->contains (Enum65::SIXTYFOUR ));
380
+ $ this ->assertTrue ($ enumSet ->count () == 3 );
381
+ }
382
+
383
+ /**
384
+ * @deprecated
385
+ */
288
386
public function testSetBitset ()
289
387
{
290
388
$ enumSet = new EnumSet ('MabeEnumTest\TestAsset\Enum65 ' );
@@ -297,26 +395,34 @@ public function testSetBitset()
297
395
$ this ->assertTrue ($ enumSet ->count () == 3 );
298
396
}
299
397
300
- public function testSetBitsetShort ()
398
+ public function testSetBinaryBitsetLeShort ()
301
399
{
302
400
$ enumSet = new EnumSet ('MabeEnumTest\TestAsset\Enum65 ' );
303
- $ enumSet ->setBitset ("\x0A" );
304
- $ this ->assertSame ("\x00 \x00\x00\x00\x00\x00\x00\x00\x0A " , $ enumSet ->getBitset ());
401
+ $ enumSet ->setBinaryBitsetLe ("\x0A" );
402
+ $ this ->assertSame ("\x0A \x00\x00\x00\x00\x00\x00\x00\x00 " , $ enumSet ->getBinaryBitsetLe ());
305
403
}
306
404
307
- public function testSetBitsetLong ()
405
+ public function testSetBinaryBitsetLeLong ()
308
406
{
309
407
$ enumSet = new EnumSet ('MabeEnumTest\TestAsset\EnumBasic ' );
310
- $ enumSet ->setBitset ("\xFF\xFF\xFF\xFF\xFF\x0A" );
311
- $ this ->assertSame ("\xFF\x0A" , $ enumSet ->getBitset ());
408
+ $ enumSet ->setBinaryBitsetLe ("\x0A\xFF\xFF\xFF\xFF\xFF" );
409
+ $ this ->assertSame ("\x0A\xFF" , $ enumSet ->getBinaryBitsetLe ());
410
+ }
411
+
412
+ public function testSetBinaryBitsetLeArgumentExceptionIfNotString ()
413
+ {
414
+ $ this ->setExpectedException ('InvalidArgumentException ' );
415
+
416
+ $ enum = new EnumSet ('MabeEnumTest\TestAsset\Enum65 ' );
417
+ $ enum ->setBinaryBitsetLe (0 );
312
418
}
313
419
314
- public function testFalseBitsetArgumentExceptionIfNotString ()
420
+ public function testSetBinaryBitsetBeArgumentExceptionIfNotString ()
315
421
{
316
422
$ this ->setExpectedException ('InvalidArgumentException ' );
317
423
318
424
$ enum = new EnumSet ('MabeEnumTest\TestAsset\Enum65 ' );
319
- $ enum ->setBitset (0 );
425
+ $ enum ->setBinaryBitsetBe (0 );
320
426
}
321
427
322
428
public function testCountingEmptyEnumEmptySet ()
0 commit comments