2121 */
2222package org .firebirdsql .decimal ;
2323
24- import org .junit .Test ;
25- import org .junit .runner . RunWith ;
26- import org .junit .runners . Parameterized ;
24+ import org .junit .jupiter . params . ParameterizedTest ;
25+ import org .junit .jupiter . params . provider . Arguments ;
26+ import org .junit .jupiter . params . provider . MethodSource ;
2727
2828import java .math .BigDecimal ;
29- import java .util .Arrays ;
30- import java .util .Collection ;
29+ import java .util .stream .Stream ;
3130
3231import static org .firebirdsql .decimal .util .ByteArrayHelper .hexToBytes ;
33- import static org .junit .Assert .assertArrayEquals ;
34- import static org .junit .Assert .assertEquals ;
35- import static org .junit .Assume .assumeTrue ;
32+ import static org .junit .jupiter . api . Assertions .assertArrayEquals ;
33+ import static org .junit .jupiter . api . Assertions .assertEquals ;
34+ import static org .junit .jupiter . api . Assumptions .assumeTrue ;
3635
37- /**
38- * @author <a href="mailto:mark@lawinegevaar.nl">Mark Rotteveel</a>
39- */
40- @ RunWith (Parameterized .class )
41- public class Decimal128ByteConversionTest {
42-
43- @ Parameterized .Parameter
44- public String description ;
45- @ Parameterized .Parameter (1 )
46- public byte [] sourceBytes ;
47- @ Parameterized .Parameter (2 )
48- public Decimal128 decimalValue ;
49- @ Parameterized .Parameter (3 )
50- public byte [] targetBytes ;
36+ class Decimal128ByteConversionTest {
5137
52- @ Test
53- public void testConversionFromBytesToDecimal128 () {
54- assumeTrue ("No source bytes for " + description , sourceBytes != null );
38+ @ SuppressWarnings ("unused" )
39+ @ ParameterizedTest (name = "{index}: value {0} ({2})" )
40+ @ MethodSource ("data" )
41+ void testConversionFromBytesToDecimal128 (String description , byte [] sourceBytes , Decimal128 decimalValue ,
42+ byte [] targetBytes ) {
43+ assumeTrue (sourceBytes != null , "No source bytes for " + description );
5544 Decimal128 result = Decimal128 .parseBytes (sourceBytes );
5645
57- assertEquals ("Expected " + description , decimalValue , result );
46+ assertEquals (decimalValue , result , "Expected " + description );
5847 }
5948
60- @ Test
61- public void testConversionFromDecimal128ToBytes () {
62- assumeTrue ("No target bytes for " + description , targetBytes != null );
49+ @ SuppressWarnings ("unused" )
50+ @ ParameterizedTest (name = "{index}: value {0} ({2})" )
51+ @ MethodSource ("data" )
52+ void testConversionFromDecimal128ToBytes (String description , byte [] sourceBytes , Decimal128 decimalValue ,
53+ byte [] targetBytes ) {
54+ assumeTrue (targetBytes != null , "No target bytes for " + description );
6355 byte [] result = decimalValue .toBytes ();
6456
6557 assertArrayEquals (targetBytes , result );
6658 }
6759
68- @ Parameterized .Parameters (name = "{index}: value {0} ({2})" )
69- public static Collection <Object []> data () {
70- return Arrays .asList (
60+ static Stream <Arguments > data () {
61+ return Stream .of (
7162 testCase ("POSITIVE_INFINITY" ,
7263 new byte [] { 0b0_11110_00, 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 },
7364 Decimal128 .POSITIVE_INFINITY ),
@@ -446,7 +437,7 @@ public static Collection<Object[]> data() {
446437 * String encoding of the decimal value (compatible with parsing by {@link BigDecimal}
447438 * @return Test case data
448439 */
449- private static Object [] testCase (String sourceEncodedString , String decimalString ) {
440+ private static Arguments testCase (String sourceEncodedString , String decimalString ) {
450441 return testCase (decimalString , hexToBytes (sourceEncodedString ), dec (decimalString ));
451442 }
452443
@@ -464,7 +455,7 @@ private static Object[] testCase(String sourceEncodedString, String decimalStrin
464455 * Hex string of binary encoding of decimal (target)
465456 * @return Test case data
466457 */
467- private static Object [] testCase (String sourceEncodedString , String decimalString , String targetEncodedString ) {
458+ private static Arguments testCase (String sourceEncodedString , String decimalString , String targetEncodedString ) {
468459 return testCase (decimalString , hexToBytes (sourceEncodedString ), dec (decimalString ),
469460 hexToBytes (targetEncodedString ));
470461 }
@@ -481,7 +472,7 @@ private static Object[] testCase(String sourceEncodedString, String decimalStrin
481472 * Decimal128 value
482473 * @return Test case data
483474 */
484- private static Object [] testCase (String description , byte [] sourceBytes , Decimal128 decimal128Value ) {
475+ private static Arguments testCase (String description , byte [] sourceBytes , Decimal128 decimal128Value ) {
485476 return testCase (description , sourceBytes , decimal128Value , sourceBytes );
486477 }
487478
@@ -499,9 +490,9 @@ private static Object[] testCase(String description, byte[] sourceBytes, Decimal
499490 * Binary encoding of decimal (target)
500491 * @return Test case data
501492 */
502- private static Object [] testCase (String description , byte [] sourceBytes , Decimal128 decimal128Value ,
493+ private static Arguments testCase (String description , byte [] sourceBytes , Decimal128 decimal128Value ,
503494 byte [] targetBytes ) {
504- return new Object [] { description , sourceBytes , decimal128Value , targetBytes } ;
495+ return Arguments . of ( description , sourceBytes , decimal128Value , targetBytes ) ;
505496 }
506497
507498 private static Decimal128 dec (String decimalString ) {
0 commit comments