From 3de2a0c9144ea9baa1e36f2ad8cef5a5497c6de8 Mon Sep 17 00:00:00 2001 From: Joerg Schaible Date: Thu, 27 Sep 2012 21:52:05 +0000 Subject: [PATCH] Implement test TODO. git-svn-id: https://svn.apache.org/repos/asf/commons/proper/lang/trunk@1391233 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/commons/lang3/ConversionTest.java | 24 +++++++++++++++---- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/src/test/java/org/apache/commons/lang3/ConversionTest.java b/src/test/java/org/apache/commons/lang3/ConversionTest.java index 0db80fd9c..f0288d5f7 100644 --- a/src/test/java/org/apache/commons/lang3/ConversionTest.java +++ b/src/test/java/org/apache/commons/lang3/ConversionTest.java @@ -492,9 +492,23 @@ public class ConversionTest { // assertEquals(0x0F12345678000000L,Conversion.intsToLong(src,1,0x123456789ABCDEF0L,32,2)); } - public void todoTestShortsToLong() { - // TODO: implement this test. This is somehow low priority since intsToLong and - // bytesToLong are tested + /** + * Tests {@link Conversion#shortsToLong(short[], int, long, int, int)}. + */ + @Test + public void testShortsToLong() { + short[] src = new short[]{ + (short)0xCDF1, (short)0xF0C1, (short)0x0F12, (short)0x3456, (short)0x7800}; + assertEquals(0x0000000000000000L, Conversion.shortsToLong(src, 0, 0L, 0, 0)); + assertEquals(0x000000000000CDF1L, Conversion.shortsToLong(src, 0, 0L, 0, 1)); + assertEquals(0x00000000F0C1CDF1L, Conversion.shortsToLong(src, 0, 0L, 0, 2)); + assertEquals(0x780034560F12F0C1L, Conversion.shortsToLong(src, 1, 0L, 0, 4)); + assertEquals( + 0x123456789ABCDEF0L, Conversion.shortsToLong(src, 0, 0x123456789ABCDEF0L, 0, 0)); + assertEquals( + 0x123456CDF1BCDEF0L, Conversion.shortsToLong(src, 0, 0x123456789ABCDEF0L, 24, 1)); + assertEquals( + 0x123478003456DEF0L, Conversion.shortsToLong(src, 3, 0x123456789ABCDEF0L, 16, 2)); } /** @@ -513,7 +527,8 @@ public class ConversionTest { 0x123456789ABCDEF0L, Conversion.bytesToLong(src, 0, 0x123456789ABCDEF0L, 0, 0)); assertEquals( 0x12345678CDBCDEF0L, Conversion.bytesToLong(src, 0, 0x123456789ABCDEF0L, 24, 1)); - // assertEquals(0x123456789A7856F0L,Conversion.bytesToLong(src,7,0x123456789ABCDEF0L,8,2)); + assertEquals( + 0x123456789A7856F0L, Conversion.bytesToLong(src, 7, 0x123456789ABCDEF0L, 8, 2)); } /** @@ -530,7 +545,6 @@ public class ConversionTest { assertEquals(0x12345678, Conversion.shortsToInt(src, 0, 0x12345678, 0, 0)); assertEquals(0xCDF15678, Conversion.shortsToInt(src, 0, 0x12345678, 16, 1)); // assertEquals(0x34567800,Conversion.shortsToInt(src, 3, 0x12345678, 16, 2)); - } /**