This is an automated email from the ASF dual-hosted git repository.

toulmean pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-tuweni.git


The following commit(s) were added to refs/heads/master by this push:
     new 032a73f  Add more coverage to ConcatenatedBytes class. (#100)
032a73f is described below

commit 032a73f4fa56014970405d00250b275e0dca2819
Author: Antoine Toulme <atou...@users.noreply.github.com>
AuthorDate: Sat Jun 27 10:41:41 2020 -0700

    Add more coverage to ConcatenatedBytes class. (#100)
---
 .../java/org/apache/tuweni/bytes/ConcatenatedBytes.java   |  7 +------
 .../org/apache/tuweni/bytes/ConcatenatedBytesTest.java    | 15 +++++++++++++++
 2 files changed, 16 insertions(+), 6 deletions(-)

diff --git a/bytes/src/main/java/org/apache/tuweni/bytes/ConcatenatedBytes.java 
b/bytes/src/main/java/org/apache/tuweni/bytes/ConcatenatedBytes.java
index 39cd362..62362a3 100644
--- a/bytes/src/main/java/org/apache/tuweni/bytes/ConcatenatedBytes.java
+++ b/bytes/src/main/java/org/apache/tuweni/bytes/ConcatenatedBytes.java
@@ -152,12 +152,7 @@ final class ConcatenatedBytes extends AbstractBytes {
 
   @Override
   public Bytes copy() {
-    if (size == 0) {
-      return Bytes.EMPTY;
-    }
-    MutableBytes result = MutableBytes.create(size);
-    copyToUnchecked(result, 0);
-    return result;
+    return mutableCopy();
   }
 
   @Override
diff --git 
a/bytes/src/test/java/org/apache/tuweni/bytes/ConcatenatedBytesTest.java 
b/bytes/src/test/java/org/apache/tuweni/bytes/ConcatenatedBytesTest.java
index 74efb44..fc74296 100644
--- a/bytes/src/test/java/org/apache/tuweni/bytes/ConcatenatedBytesTest.java
+++ b/bytes/src/test/java/org/apache/tuweni/bytes/ConcatenatedBytesTest.java
@@ -97,4 +97,19 @@ class ConcatenatedBytesTest {
     assertEquals(24, bytes.size());
     assertEquals("0x0123456789abcdef0123456789abcdef0123456789abcdef", 
bytes.toHexString());
   }
+
+  @Test
+  void testCopy() {
+    Bytes bytes = wrap(fromHexString("0x01234567"), 
fromHexString("0x89ABCDEF"));
+    assertEquals(bytes, bytes.copy());
+    assertEquals(bytes, bytes.mutableCopy());
+  }
+
+  @Test
+  void testCopyTo() {
+    Bytes bytes = wrap(fromHexString("0x0123"), fromHexString("0x4567"));
+    MutableBytes dest = MutableBytes.create(32);
+    bytes.copyTo(dest, 10);
+    
assertEquals(Bytes.fromHexString("0x0000000000000000000001234567000000000000000000000000000000000000"),
 dest);
+  }
 }


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@tuweni.apache.org
For additional commands, e-mail: commits-h...@tuweni.apache.org

Reply via email to