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