@@ -2381,8 +2381,8 @@ public static void TestRandomOne(byte[] array) {
23812381 o = CBORObject .Read (inputStream );
23822382 long cborlen = (startingAvailable - inputStream .available ()) - oldPos ;
23832383 if (cborlen > 3000 ) {
2384- System .out .println ("pos=" + (startingAvailable - inputStream .available ()) + " of " +
2385- startingAvailable + ", cborlen=" + cborlen );
2384+ System .out .println ("pos=" + (startingAvailable - inputStream .available ()) + " of " +
2385+ startingAvailable + ", cborlen=" + cborlen );
23862386 }
23872387 byte [] encodedBytes = (o == null ) ? null : o .EncodeToBytes ();
23882388 try {
@@ -2400,11 +2400,11 @@ public static void TestRandomOne(byte[] array) {
24002400 }
24012401 if (o != null ) {
24022402 try {
2403- if (cborlen > 3000 ) {
2403+ if (cborlen > 3000 ) {
24042404 System .out .println ("toJSONString " + java .util .Date .UtcNow );
24052405 }
24062406 jsonString = o .ToJSONString ();
2407- if (cborlen > 3000 ) {
2407+ if (cborlen > 3000 ) {
24082408 System .out .println ("jsonStringLen = " + jsonString .length ());
24092409 }
24102410 } catch (CBORException ex ) {
@@ -2877,66 +2877,66 @@ public void TestAsNumberAddSubtract() {
28772877 public static boolean TestAsNumberMultiplyDivideOne (
28782878 CBORObject o1 ,
28792879 CBORObject o2 ) {
2880- if (o1 == null ) {
2881- throw new NullPointerException ("o1" );
2882- }
2883- if (o2 == null ) {
2884- throw new NullPointerException ("o2" );
2885- }
2886- if (!o1 .isNumber () || !o2 .isNumber ()) {
2887- return false ;
2888- }
2889- byte [] eb1 = o1 .EncodeToBytes ();
2890- byte [] eb2 = o2 .EncodeToBytes ();
2891- CBORTestCommon .AssertRoundTrip (o1 );
2892- CBORTestCommon .AssertRoundTrip (o2 );
2893- CBORNumber on1 = o1 .AsNumber ();
2894- CBORNumber on2 = o2 .AsNumber ();
2895- CBORNumber onSum = null ;
2896- try {
2897- onSum = on1 .Multiply (on2 );
2898- } catch (OutOfMemoryError ex ) {
2899- return false ;
2900- }
2901- if (!onSum .IsFinite ()) {
2902- // System.out.println("on1=" + o1);
2903- // System.out.println("on2=" + o2);
2904- return false ;
2905- }
2906- // System.out.println(i+"");
2907- // System.out.println(i+" "+Chop(o1.toString()));
2908- // System.out.println(i+" "+Chop(o2.toString()));
2909- // System.out.println(i + " " + Chop(onSum.toString()));
2910- if (!onSum .IsFinite ()) {
2911- Assert .fail ("onSum is not finite\n " +
2912- "o1=" + TestCommon .ToByteArrayString (eb1 ) + "\n " +
2913- "o2=" + TestCommon .ToByteArrayString (eb2 ) + "\n " );
2914- }
2915- CBORNumber on2a = onSum .Divide (on1 );
2916- // NOTE: Ignore if divisor is zero
2917- if (!on1 .IsZero () && !on2a .IsFinite ()) {
2918- Assert .fail ("on2a is not finite\n " +
2919- "o1=" + TestCommon .ToByteArrayString (eb1 ) + "\n " +
2920- "o2=" + TestCommon .ToByteArrayString (eb2 ) + "\n " );
2921- }
2922- if (!on1 .IsZero () && !on2 .IsZero ()) {
2923- VerifyEqual (on2a , on2 , o1 , o2 );
2924- }
2925- CBORNumber on1a = onSum .Divide (on2 );
2926- // NOTE: Ignore if divisor is zero
2927- if (!on2 .IsZero () && !on1a .IsFinite ()) {
2928- Assert .fail ("on1a is not finite\n " +
2929- "o1=" + on1 + "\n " + "o2=" + on2 + "\n " +
2930- "{\n byte[] bytes1 = " + TestCommon .ToByteArrayString (eb1 ) + ";\n " +
2931- "byte[] bytes2 =" + TestCommon .ToByteArrayString (eb2 ) + ";\n " +
2932- "TestAsNumberMultiplyDivideOne(\n CBORObject.D" +
2933- "ecodeFromBytes(bytes1),\n " +
2934- "CBORObject.DecodeFromBytes(bytes2));\n }\n " );
2935- }
2936- if (!on1 .IsZero () && !on2 .IsZero ()) {
2937- VerifyEqual (on1a , on1 , o1 , o2 );
2938- }
2939- return true ;
2880+ if (o1 == null ) {
2881+ throw new NullPointerException ("o1" );
2882+ }
2883+ if (o2 == null ) {
2884+ throw new NullPointerException ("o2" );
2885+ }
2886+ if (!o1 .isNumber () || !o2 .isNumber ()) {
2887+ return false ;
2888+ }
2889+ byte [] eb1 = o1 .EncodeToBytes ();
2890+ byte [] eb2 = o2 .EncodeToBytes ();
2891+ CBORTestCommon .AssertRoundTrip (o1 );
2892+ CBORTestCommon .AssertRoundTrip (o2 );
2893+ CBORNumber on1 = o1 .AsNumber ();
2894+ CBORNumber on2 = o2 .AsNumber ();
2895+ CBORNumber onSum = null ;
2896+ try {
2897+ onSum = on1 .Multiply (on2 );
2898+ } catch (OutOfMemoryError ex ) {
2899+ return false ;
2900+ }
2901+ if (!onSum .IsFinite ()) {
2902+ // System.out.println("on1=" + o1);
2903+ // System.out.println("on2=" + o2);
2904+ return false ;
2905+ }
2906+ // System.out.println(i+"");
2907+ // System.out.println(i+" "+Chop(o1.toString()));
2908+ // System.out.println(i+" "+Chop(o2.toString()));
2909+ // System.out.println(i + " " + Chop(onSum.toString()));
2910+ if (!onSum .IsFinite ()) {
2911+ Assert .fail ("onSum is not finite\n " +
2912+ "o1=" + TestCommon .ToByteArrayString (eb1 ) + "\n " +
2913+ "o2=" + TestCommon .ToByteArrayString (eb2 ) + "\n " );
2914+ }
2915+ CBORNumber on2a = onSum .Divide (on1 );
2916+ // NOTE: Ignore if divisor is zero
2917+ if (!on1 .IsZero () && !on2a .IsFinite ()) {
2918+ Assert .fail ("on2a is not finite\n " +
2919+ "o1=" + TestCommon .ToByteArrayString (eb1 ) + "\n " +
2920+ "o2=" + TestCommon .ToByteArrayString (eb2 ) + "\n " );
2921+ }
2922+ if (!on1 .IsZero () && !on2 .IsZero ()) {
2923+ VerifyEqual (on2a , on2 , o1 , o2 );
2924+ }
2925+ CBORNumber on1a = onSum .Divide (on2 );
2926+ // NOTE: Ignore if divisor is zero
2927+ if (!on2 .IsZero () && !on1a .IsFinite ()) {
2928+ Assert .fail ("on1a is not finite\n " +
2929+ "o1=" + on1 + "\n " + "o2=" + on2 + "\n " +
2930+ "{\n byte[] bytes1 = " + TestCommon .ToByteArrayString (eb1 ) + ";\n " +
2931+ "byte[] bytes2 =" + TestCommon .ToByteArrayString (eb2 ) + ";\n " +
2932+ "TestAsNumberMultiplyDivideOne(\n CBORObject.D" +
2933+ "ecodeFromBytes(bytes1),\n " +
2934+ "CBORObject.DecodeFromBytes(bytes2));\n }\n " );
2935+ }
2936+ if (!on1 .IsZero () && !on2 .IsZero ()) {
2937+ VerifyEqual (on1a , on1 , o1 , o2 );
2938+ }
2939+ return true ;
29402940 }
29412941
29422942 @ Test (timeout = 100000 )
0 commit comments