@@ -251,31 +251,64 @@ public function test65EnumerationsSet()
251
251
$ this ->assertTrue ($ enum ->valid ());
252
252
}
253
253
254
- public function testBitset ()
254
+ public function testGetBitset ()
255
255
{
256
- $ enumSet1 = new EnumSet ('MabeEnumTest\TestAsset\Enum65 ' );
256
+ $ enumSet = new EnumSet ('MabeEnumTest\TestAsset\Enum65 ' );
257
257
258
258
$ enum1 = Enum65::ONE ;
259
259
$ enum2 = Enum65::TWO ;
260
260
$ enum3 = Enum65::SIXTYFIVE ;
261
261
$ enum4 = Enum65::SIXTYFOUR ;
262
+
263
+ $ this ->assertNull ($ enumSet ->attach ($ enum1 ));
264
+ $ this ->assertSame ('000000000000000001 ' , bin2hex ($ enumSet ->getBitset ()));
265
+ $ this ->assertTrue ($ enumSet ->contains ($ enum1 ));
266
+
267
+ $ this ->assertNull ($ enumSet ->attach ($ enum2 ));
268
+ $ this ->assertSame ('000000000000000003 ' , bin2hex ($ enumSet ->getBitset ()));
269
+ $ this ->assertTrue ($ enumSet ->contains ($ enum2 ));
270
+
271
+ $ this ->assertNull ($ enumSet ->attach ($ enum3 ));
272
+ $ this ->assertSame ('010000000000000003 ' , bin2hex ($ enumSet ->getBitset ()));
273
+ $ this ->assertTrue ($ enumSet ->contains ($ enum3 ));
274
+
275
+ $ this ->assertNull ($ enumSet ->attach ($ enum4 ));
276
+ $ this ->assertSame ('018000000000000003 ' , bin2hex ($ enumSet ->getBitset ()));
277
+ $ this ->assertTrue ($ enumSet ->contains ($ enum4 ));
262
278
263
- $ this ->assertNull ($ enumSet1 ->attach ($ enum1 ));
264
- $ this ->assertNull ($ enumSet1 ->attach ($ enum2 ));
265
- $ this ->assertNull ($ enumSet1 ->attach ($ enum3 ));
266
- $ this ->assertNull ($ enumSet1 ->attach ($ enum4 ));
267
-
268
- $ this ->assertNull ($ enumSet1 ->detach ($ enum1 ));
269
- $ bitset = $ enumSet1 ->getBitset ();
270
- $ this ->assertTrue (strlen ($ bitset ) > 8 );
271
- $ enumSet2 = new EnumSet ('MabeEnumTest\TestAsset\Enum65 ' );
272
- $ enumSet2 ->setBitset ($ bitset );
279
+ $ this ->assertSame (4 , $ enumSet ->count ());
280
+
281
+ $ this ->assertNull ($ enumSet ->detach ($ enum2 ));
282
+ $ this ->assertSame ('018000000000000001 ' , bin2hex ($ enumSet ->getBitset ()));
283
+ $ this ->assertFalse ($ enumSet ->contains ($ enum2 ));
273
284
274
- $ this ->assertFalse ($ enumSet2 ->contains ($ enum1 ));
275
- $ this ->assertTrue ($ enumSet2 ->contains ($ enum2 ));
276
- $ this ->assertTrue ($ enumSet2 ->contains ($ enum3 ));
277
- $ this ->assertTrue ($ enumSet2 ->contains ($ enum4 ));
278
- $ this ->assertTrue ($ enumSet2 ->count () == 3 );
285
+ $ this ->assertSame (3 , $ enumSet ->count ());
286
+ }
287
+
288
+ public function testSetBitset ()
289
+ {
290
+ $ enumSet = new EnumSet ('MabeEnumTest\TestAsset\Enum65 ' );
291
+ $ enumSet ->setBitset (hex2bin ('018000000000000001 ' ));
292
+
293
+ $ this ->assertTrue ($ enumSet ->contains (Enum65::ONE ));
294
+ $ this ->assertFalse ($ enumSet ->contains (Enum65::TWO ));
295
+ $ this ->assertTrue ($ enumSet ->contains (Enum65::SIXTYFIVE ));
296
+ $ this ->assertTrue ($ enumSet ->contains (Enum65::SIXTYFOUR ));
297
+ $ this ->assertTrue ($ enumSet ->count () == 3 );
298
+ }
299
+
300
+ public function testSetBitsetShort ()
301
+ {
302
+ $ enumSet = new EnumSet ('MabeEnumTest\TestAsset\Enum65 ' );
303
+ $ enumSet ->setBitset (hex2bin ('0A ' ));
304
+ $ this ->assertSame ('00000000000000000a ' , bin2hex ($ enumSet ->getBitset ()));
305
+ }
306
+
307
+ public function testSetBitsetLong ()
308
+ {
309
+ $ enumSet = new EnumSet ('MabeEnumTest\TestAsset\EnumBasic ' );
310
+ $ enumSet ->setBitset (hex2bin ('FFFFFFFFFF0A ' ));
311
+ $ this ->assertSame ('ff0a ' , bin2hex ($ enumSet ->getBitset ()));
279
312
}
280
313
281
314
public function testFalseBitsetArgumentExceptionIfNotString ()
0 commit comments