From ed08c88d4fa5b3f65506119d163e9ec8448c4cc7 Mon Sep 17 00:00:00 2001 From: serso Date: Wed, 27 Apr 2016 21:17:22 +0200 Subject: [PATCH] Fix Jscl tests --- jscl/build.gradle | 9 +++++++++ jscl/src/test/java/jscl/JsclMathEngineTest.java | 16 +++++++++------- .../jscl/math/NumeralBaseConversionTest.java | 2 +- .../test/java/jscl/math/TrigonometricTest.java | 2 +- 4 files changed, 20 insertions(+), 9 deletions(-) diff --git a/jscl/build.gradle b/jscl/build.gradle index 015ec872..c7793d4c 100644 --- a/jscl/build.gradle +++ b/jscl/build.gradle @@ -32,5 +32,14 @@ dependencies { testCompile 'net.sf.opencsv:opencsv:2.0' } +sourceSets { + main { + output.resourcesDir = "build/classes/main" + } + test { + output.resourcesDir = "build/classes/test" + } +} + sourceCompatibility = JavaVersion.VERSION_1_7 targetCompatibility = JavaVersion.VERSION_1_7 \ No newline at end of file diff --git a/jscl/src/test/java/jscl/JsclMathEngineTest.java b/jscl/src/test/java/jscl/JsclMathEngineTest.java index 92b271fa..ae3cb0c7 100644 --- a/jscl/src/test/java/jscl/JsclMathEngineTest.java +++ b/jscl/src/test/java/jscl/JsclMathEngineTest.java @@ -1,6 +1,7 @@ package jscl; import midpcalc.Real; +import org.junit.Before; import org.junit.Test; import static org.junit.Assert.assertEquals; @@ -11,10 +12,16 @@ import static org.junit.Assert.assertEquals; * Time: 11:25 AM */ public class JsclMathEngineTest { + + private JsclMathEngine me; + + @Before + public void setUp() throws Exception { + me = new JsclMathEngine(); + } + @Test public void testFormat() throws Exception { - final MathContext me = JsclMathEngine.getInstance(); - try { me.setUseGroupingSeparator(true); assertEquals("1", me.format(1d, NumeralBase.bin)); @@ -80,13 +87,11 @@ public class JsclMathEngineTest { @Test public void testPiComputation() throws Exception { - final JsclMathEngine me = JsclMathEngine.getInstance(); assertEquals("-1+0.0000000000000001*i", me.evaluate("exp(√(-1)*Π)")); } @Test public void testBinShouldAlwaysUseSpaceAsGroupingSeparator() throws Exception { - final JsclMathEngine me = new JsclMathEngine(); me.setGroupingSeparator('\''); me.setUseGroupingSeparator(true); @@ -95,7 +100,6 @@ public class JsclMathEngineTest { @Test public void testHexShouldAlwaysUseSpaceAsGroupingSeparator() throws Exception { - final JsclMathEngine me = new JsclMathEngine(); me.setGroupingSeparator('\''); me.setUseGroupingSeparator(true); @@ -104,7 +108,6 @@ public class JsclMathEngineTest { @Test public void testEngineeringNotationWithRounding() throws Exception { - final JsclMathEngine me = JsclMathEngine.getInstance(); me.setNumberFormat(Real.NumberFormat.FSE_ENG); me.setRoundResult(true); me.setPrecision(5); @@ -161,7 +164,6 @@ public class JsclMathEngineTest { @Test public void testEngineeringNotationWithoutRounding() throws Exception { - final JsclMathEngine me = JsclMathEngine.getInstance(); me.setNumberFormat(Real.NumberFormat.FSE_ENG); me.setRoundResult(false); diff --git a/jscl/src/test/java/jscl/math/NumeralBaseConversionTest.java b/jscl/src/test/java/jscl/math/NumeralBaseConversionTest.java index 4cc3636b..1a025815 100644 --- a/jscl/src/test/java/jscl/math/NumeralBaseConversionTest.java +++ b/jscl/src/test/java/jscl/math/NumeralBaseConversionTest.java @@ -40,7 +40,7 @@ public class NumeralBaseConversionTest { try { final MathEngine me = JsclMathEngine.getInstance(); - reader = new CSVReader(new InputStreamReader(NumeralBaseConversionTest.class.getResourceAsStream("/jscl/math/nb_table.csv")), '\t'); + reader = new CSVReader(new InputStreamReader(NumeralBaseConversionTest.class.getResourceAsStream("nb_table.csv")), '\t'); // skip first line reader.readNext(); diff --git a/jscl/src/test/java/jscl/math/TrigonometricTest.java b/jscl/src/test/java/jscl/math/TrigonometricTest.java index 4574e982..310b905a 100644 --- a/jscl/src/test/java/jscl/math/TrigonometricTest.java +++ b/jscl/src/test/java/jscl/math/TrigonometricTest.java @@ -31,7 +31,7 @@ public class TrigonometricTest { try { final MathEngine me = JsclMathEngine.getInstance(); - reader = new CSVReader(new InputStreamReader(TrigonometricTest.class.getResourceAsStream("/jscl/math/trig_table.csv")), '\t'); + reader = new CSVReader(new InputStreamReader(TrigonometricTest.class.getResourceAsStream("./trig_table.csv")), '\t'); // skip first line reader.readNext();