File tree Expand file tree Collapse file tree 2 files changed +12
-1
lines changed Expand file tree Collapse file tree 2 files changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -97,7 +97,7 @@ public function toBinaryString(): string
97
97
$ words = [];
98
98
99
99
// ensure all slots between 0 and maxKey have a value
100
- $ maxKey = max (...array_keys ($ this ->words ));
100
+ $ maxKey = max (0 , ...array_keys ($ this ->words ));
101
101
for ($ i = 0 ; $ i <= $ maxKey ; $ i ++) {
102
102
$ words [$ i ] = $ this ->words [$ i ] ?? 0 ;
103
103
}
Original file line number Diff line number Diff line change @@ -142,6 +142,17 @@ public function testSerializeBinaryString(): void
142
142
static ::assertEquals ($ bitSet , $ newBitSet );
143
143
}
144
144
145
+ public function testSerializeBinaryStringSingleEntry (): void
146
+ {
147
+ $ bitSet = new BitSet ();
148
+ $ bitSet ->set (5 , 6 );
149
+
150
+ $ binaryString = $ bitSet ->toBinaryString ();
151
+ $ newBitSet = BitSet::fromBinaryString ($ binaryString );
152
+
153
+ static ::assertEquals ($ bitSet , $ newBitSet );
154
+ }
155
+
145
156
public function testSerializeBinaryStringEmptyBitSet (): void
146
157
{
147
158
$ bitSet = new BitSet ();
You can’t perform that action at this time.
0 commit comments