File tree Expand file tree Collapse file tree 3 files changed +21
-5
lines changed
main/java/at/favre/lib/bytes
test/java/at/favre/lib/bytes Expand file tree Collapse file tree 3 files changed +21
-5
lines changed Original file line number Diff line number Diff line change 88 * add appendNullSafe and append string with encoding
99 * add proguard optimized version (can be used with classifier 'optimized')
1010 * add constant time equals
11+ * fix or() operator using and() internally #2
1112
1213## v0.4.6
1314
6667
6768## v0.2.0
6869
69- initial version
70+ initial version
Original file line number Diff line number Diff line change 2121
2222package at .favre .lib .bytes ;
2323
24- import java .io .*;
24+ import java .io .ByteArrayInputStream ;
25+ import java .io .DataInput ;
26+ import java .io .File ;
27+ import java .io .InputStream ;
28+ import java .io .Serializable ;
2529import java .math .BigInteger ;
2630import java .nio .ByteBuffer ;
2731import java .nio .ByteOrder ;
3135import java .nio .charset .StandardCharsets ;
3236import java .security .SecureRandom ;
3337import java .text .Normalizer ;
34- import java .util .*;
38+ import java .util .Arrays ;
39+ import java .util .BitSet ;
40+ import java .util .Collection ;
41+ import java .util .Iterator ;
42+ import java .util .List ;
43+ import java .util .Objects ;
44+ import java .util .Random ;
3545
3646/**
3747 * Bytes is wrapper class for an byte-array that allows a lot of convenience operations on it:
@@ -744,7 +754,7 @@ public Bytes and(byte[] secondArray) {
744754 * @see <a href="https://en.wikipedia.org/wiki/Bitwise_operation#OR">Bitwise operators: OR</a>
745755 */
746756 public Bytes or (Bytes bytes ) {
747- return and (bytes .internalArray ());
757+ return or (bytes .internalArray ());
748758 }
749759
750760 /**
Original file line number Diff line number Diff line change @@ -179,8 +179,13 @@ public void xor() {
179179 @ Test
180180 public void or () {
181181 assertArrayEquals (new byte [0 ], Bytes .from (new byte [0 ]).or (new byte [0 ]).array ());
182+ assertArrayEquals (new byte []{1 }, Bytes .from (new byte []{1 }).or (new byte []{0 }).array ());
182183 assertArrayEquals (new byte [1 ], Bytes .from (new byte [1 ]).or (new byte [1 ]).array ());
183184
185+ assertArrayEquals (new byte [0 ], Bytes .from (new byte [0 ]).or (Bytes .wrap (new byte [0 ])).array ());
186+ assertArrayEquals (new byte []{1 }, Bytes .from (new byte []{1 }).or (Bytes .wrap (new byte []{0 })).array ());
187+ assertArrayEquals (new byte [1 ], Bytes .from (new byte [1 ]).or (Bytes .wrap (new byte [1 ])).array ());
188+
184189 assertArrayEquals (example_bytes_one , Bytes .from (example_bytes_one ).or (new byte [1 ]).array ());
185190 assertArrayEquals (example_bytes_two , Bytes .from (example_bytes_two ).or (new byte [2 ]).array ());
186191 assertArrayEquals (example_bytes_sixteen , Bytes .from (example_bytes_sixteen ).or (new byte [16 ]).array ());
@@ -419,4 +424,4 @@ public int compare(Byte o1, Byte o2) {
419424 }).supportInPlaceTransformation ());
420425 assertTrue (new BytesTransformers .ShuffleTransformer (new SecureRandom ()).supportInPlaceTransformation ());
421426 }
422- }
427+ }
You can’t perform that action at this time.
0 commit comments