You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by er...@apache.org on 2019/12/05 01:48:00 UTC

[commons-numbers] branch master updated (8963bd1 -> 4cb87cf)

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

erans pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/commons-numbers.git.


    from 8963bd1  Preserve even function in cosh
     new 5fec6e1  Disable SonarQube rule.
     new ff77988  Merge branch 'master' of https://gitbox.apache.org/repos/asf/commons-numbers
     new 4cb87cf  Removed "ComplexParsingException".

The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../numbers/angle/PlaneAngleRadiansTest.java       |  1 +
 .../apache/commons/numbers/complex/Complex.java    | 38 +++++-----------------
 .../commons/numbers/complex/ComplexTest.java       | 10 +++---
 3 files changed, 15 insertions(+), 34 deletions(-)


[commons-numbers] 01/03: Disable SonarQube rule.

Posted by er...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

erans pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-numbers.git

commit 5fec6e10970a7e17e36f5924a14741c726f1ab46
Author: Gilles Sadowski <gi...@harfang.homelinux.org>
AuthorDate: Thu Dec 5 02:23:15 2019 +0100

    Disable SonarQube rule.
    
    The rule was triggered whatever the order of the assertion arguments.
---
 .../java/org/apache/commons/numbers/angle/PlaneAngleRadiansTest.java     | 1 +
 1 file changed, 1 insertion(+)

diff --git a/commons-numbers-angle/src/test/java/org/apache/commons/numbers/angle/PlaneAngleRadiansTest.java b/commons-numbers-angle/src/test/java/org/apache/commons/numbers/angle/PlaneAngleRadiansTest.java
index 27a99e3..35b3f9d 100644
--- a/commons-numbers-angle/src/test/java/org/apache/commons/numbers/angle/PlaneAngleRadiansTest.java
+++ b/commons-numbers-angle/src/test/java/org/apache/commons/numbers/angle/PlaneAngleRadiansTest.java
@@ -24,6 +24,7 @@ import org.junit.jupiter.api.Test;
  */
 public class PlaneAngleRadiansTest {
     @Test
+    SuppressWarnings("squid:S3415")
     public void testConstants() {
         final double eps = 0;
 


[commons-numbers] 03/03: Removed "ComplexParsingException".

Posted by er...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

erans pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-numbers.git

commit 4cb87cfe9d6b3e899165a5f4bf28b667bed417e0
Author: Gilles Sadowski <gi...@harfang.homelinux.org>
AuthorDate: Thu Dec 5 02:46:37 2019 +0100

    Removed "ComplexParsingException".
    
    It was almost a synonym for the standard "NumberFormatException".
---
 .../apache/commons/numbers/complex/Complex.java    | 38 +++++-----------------
 .../commons/numbers/complex/ComplexTest.java       | 10 +++---
 2 files changed, 14 insertions(+), 34 deletions(-)

diff --git a/commons-numbers-complex/src/main/java/org/apache/commons/numbers/complex/Complex.java b/commons-numbers-complex/src/main/java/org/apache/commons/numbers/complex/Complex.java
index e5b9ca8..ab48a20 100644
--- a/commons-numbers-complex/src/main/java/org/apache/commons/numbers/complex/Complex.java
+++ b/commons-numbers-complex/src/main/java/org/apache/commons/numbers/complex/Complex.java
@@ -183,31 +183,33 @@ public final class Complex implements Serializable  {
     public static Complex parse(String s) {
         final int startParen = s.indexOf(FORMAT_START);
         if (startParen != 0) {
-            throw new ComplexParsingException("Expected start string: " + FORMAT_START);
+            throw new NumberFormatException("Expected start string: " + FORMAT_START);
         }
         final int len = s.length();
         final int endParen = s.indexOf(FORMAT_END);
         if (endParen != len - 1) {
-            throw new ComplexParsingException("Expected end string: " + FORMAT_END);
+            throw new NumberFormatException("Expected end string: " + FORMAT_END);
         }
         final String[] elements = s.substring(1, s.length() - 1).split(FORMAT_SEP);
         if (elements.length != TWO_ELEMENTS) {
-            throw new ComplexParsingException("Incorrect number of parts: Expected 2 but was " +
-                                              elements.length +
-                                              " (separator is '" + FORMAT_SEP + "')");
+            throw new NumberFormatException("Incorrect number of parts: Expected 2 but was " +
+                                            elements.length +
+                                            " (separator is '" + FORMAT_SEP + "')");
         }
 
         final double re;
         try {
             re = Double.parseDouble(elements[0]);
         } catch (final NumberFormatException ex) {
-            throw new ComplexParsingException("Could not parse real part" + elements[0], ex);
+            throw new NumberFormatException("Could not parse real part (" + elements[0] + "): " +
+                                            ex.getMessage());
         }
         final double im;
         try {
             im = Double.parseDouble(elements[1]);
         } catch (final NumberFormatException ex) {
-            throw new ComplexParsingException("Could not parse imaginary part" + elements[1], ex);
+            throw new NumberFormatException("Could not parse imaginary part (" + elements[1] + "): " +
+                                            ex.getMessage());
         }
 
         return ofCartesian(re, im);
@@ -1818,26 +1820,4 @@ public final class Complex implements Serializable  {
     private static Complex ofCartesianConjugate(double real, double imaginary) {
         return new Complex(real, -imaginary);
     }
-
-     /** See {@link #parse(String)}. */
-    private static class ComplexParsingException extends NumberFormatException {
-        /** Serializable version identifier. */
-        private static final long serialVersionUID = 20180430L;
-
-        /**
-         * @param msg Error message.
-         */
-        ComplexParsingException(String msg) {
-            super(msg);
-        }
-
-        /**
-         * @param msg Error message.
-         * @param cause Cause.
-         */
-        ComplexParsingException(String msg, Throwable cause) {
-            super(msg);
-            initCause(cause);
-        }
-    }
 }
diff --git a/commons-numbers-complex/src/test/java/org/apache/commons/numbers/complex/ComplexTest.java b/commons-numbers-complex/src/test/java/org/apache/commons/numbers/complex/ComplexTest.java
index b10f80e..b62a649 100644
--- a/commons-numbers-complex/src/test/java/org/apache/commons/numbers/complex/ComplexTest.java
+++ b/commons-numbers-complex/src/test/java/org/apache/commons/numbers/complex/ComplexTest.java
@@ -1215,7 +1215,7 @@ public class ComplexTest {
     public void testParseWrongStart() {
         final String re = "1.234";
         final String im = "5.678";
-        Assertions.assertThrows(IllegalArgumentException.class,
+        Assertions.assertThrows(NumberFormatException.class,
             () -> Complex.parse(re + "," + im + ")")
         );
     }
@@ -1224,7 +1224,7 @@ public class ComplexTest {
     public void testParseWrongEnd() {
         final String re = "1.234";
         final String im = "5.678";
-        Assertions.assertThrows(IllegalArgumentException.class,
+        Assertions.assertThrows(NumberFormatException.class,
             () -> Complex.parse("(" + re + "," + im)
         );
     }
@@ -1233,7 +1233,7 @@ public class ComplexTest {
     public void testParseMissingSeparator() {
         final String re = "1.234";
         final String im = "5.678";
-        Assertions.assertThrows(IllegalArgumentException.class,
+        Assertions.assertThrows(NumberFormatException.class,
             () -> Complex.parse("(" + re + " " + im + ")")
         );
     }
@@ -1242,7 +1242,7 @@ public class ComplexTest {
     public void testParseInvalidRe() {
         final String re = "I.234";
         final String im = "5.678";
-        Assertions.assertThrows(IllegalArgumentException.class,
+        Assertions.assertThrows(NumberFormatException.class,
             () -> Complex.parse("(" + re + "," + im + ")")
         );
     }
@@ -1251,7 +1251,7 @@ public class ComplexTest {
     public void testParseInvalidIm() {
         final String re = "1.234";
         final String im = "5.G78";
-        Assertions.assertThrows(IllegalArgumentException.class,
+        Assertions.assertThrows(NumberFormatException.class,
             () -> Complex.parse("(" + re + "," + im + ")")
         );
     }


[commons-numbers] 02/03: Merge branch 'master' of https://gitbox.apache.org/repos/asf/commons-numbers

Posted by er...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

erans pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-numbers.git

commit ff77988f8b5db27f64b6e7561263dd7a0167997f
Merge: 5fec6e1 8963bd1
Author: Gilles Sadowski <gi...@harfang.homelinux.org>
AuthorDate: Thu Dec 5 02:29:49 2019 +0100

    Merge branch 'master' of https://gitbox.apache.org/repos/asf/commons-numbers

 .../apache/commons/numbers/complex/Complex.java    | 16 ++++-
 .../commons/numbers/complex/CStandardTest.java     | 83 ++++++++++++++++++++--
 2 files changed, 90 insertions(+), 9 deletions(-)