Fix Jscl tests

This commit is contained in:
serso 2016-04-27 21:17:22 +02:00
parent 408847f985
commit ed08c88d4f
4 changed files with 20 additions and 9 deletions

View File

@ -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

View File

@ -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);

View File

@ -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();

View File

@ -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();