Fix Jscl tests
This commit is contained in:
parent
408847f985
commit
ed08c88d4f
@ -32,5 +32,14 @@ dependencies {
|
|||||||
testCompile 'net.sf.opencsv:opencsv:2.0'
|
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
|
sourceCompatibility = JavaVersion.VERSION_1_7
|
||||||
targetCompatibility = JavaVersion.VERSION_1_7
|
targetCompatibility = JavaVersion.VERSION_1_7
|
@ -1,6 +1,7 @@
|
|||||||
package jscl;
|
package jscl;
|
||||||
|
|
||||||
import midpcalc.Real;
|
import midpcalc.Real;
|
||||||
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
@ -11,10 +12,16 @@ import static org.junit.Assert.assertEquals;
|
|||||||
* Time: 11:25 AM
|
* Time: 11:25 AM
|
||||||
*/
|
*/
|
||||||
public class JsclMathEngineTest {
|
public class JsclMathEngineTest {
|
||||||
|
|
||||||
|
private JsclMathEngine me;
|
||||||
|
|
||||||
|
@Before
|
||||||
|
public void setUp() throws Exception {
|
||||||
|
me = new JsclMathEngine();
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFormat() throws Exception {
|
public void testFormat() throws Exception {
|
||||||
final MathContext me = JsclMathEngine.getInstance();
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
me.setUseGroupingSeparator(true);
|
me.setUseGroupingSeparator(true);
|
||||||
assertEquals("1", me.format(1d, NumeralBase.bin));
|
assertEquals("1", me.format(1d, NumeralBase.bin));
|
||||||
@ -80,13 +87,11 @@ public class JsclMathEngineTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testPiComputation() throws Exception {
|
public void testPiComputation() throws Exception {
|
||||||
final JsclMathEngine me = JsclMathEngine.getInstance();
|
|
||||||
assertEquals("-1+0.0000000000000001*i", me.evaluate("exp(√(-1)*Π)"));
|
assertEquals("-1+0.0000000000000001*i", me.evaluate("exp(√(-1)*Π)"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testBinShouldAlwaysUseSpaceAsGroupingSeparator() throws Exception {
|
public void testBinShouldAlwaysUseSpaceAsGroupingSeparator() throws Exception {
|
||||||
final JsclMathEngine me = new JsclMathEngine();
|
|
||||||
me.setGroupingSeparator('\'');
|
me.setGroupingSeparator('\'');
|
||||||
me.setUseGroupingSeparator(true);
|
me.setUseGroupingSeparator(true);
|
||||||
|
|
||||||
@ -95,7 +100,6 @@ public class JsclMathEngineTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testHexShouldAlwaysUseSpaceAsGroupingSeparator() throws Exception {
|
public void testHexShouldAlwaysUseSpaceAsGroupingSeparator() throws Exception {
|
||||||
final JsclMathEngine me = new JsclMathEngine();
|
|
||||||
me.setGroupingSeparator('\'');
|
me.setGroupingSeparator('\'');
|
||||||
me.setUseGroupingSeparator(true);
|
me.setUseGroupingSeparator(true);
|
||||||
|
|
||||||
@ -104,7 +108,6 @@ public class JsclMathEngineTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testEngineeringNotationWithRounding() throws Exception {
|
public void testEngineeringNotationWithRounding() throws Exception {
|
||||||
final JsclMathEngine me = JsclMathEngine.getInstance();
|
|
||||||
me.setNumberFormat(Real.NumberFormat.FSE_ENG);
|
me.setNumberFormat(Real.NumberFormat.FSE_ENG);
|
||||||
me.setRoundResult(true);
|
me.setRoundResult(true);
|
||||||
me.setPrecision(5);
|
me.setPrecision(5);
|
||||||
@ -161,7 +164,6 @@ public class JsclMathEngineTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testEngineeringNotationWithoutRounding() throws Exception {
|
public void testEngineeringNotationWithoutRounding() throws Exception {
|
||||||
final JsclMathEngine me = JsclMathEngine.getInstance();
|
|
||||||
me.setNumberFormat(Real.NumberFormat.FSE_ENG);
|
me.setNumberFormat(Real.NumberFormat.FSE_ENG);
|
||||||
me.setRoundResult(false);
|
me.setRoundResult(false);
|
||||||
|
|
||||||
|
@ -40,7 +40,7 @@ public class NumeralBaseConversionTest {
|
|||||||
try {
|
try {
|
||||||
final MathEngine me = JsclMathEngine.getInstance();
|
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
|
// skip first line
|
||||||
reader.readNext();
|
reader.readNext();
|
||||||
|
@ -31,7 +31,7 @@ public class TrigonometricTest {
|
|||||||
try {
|
try {
|
||||||
final MathEngine me = JsclMathEngine.getInstance();
|
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
|
// skip first line
|
||||||
reader.readNext();
|
reader.readNext();
|
||||||
|
Loading…
Reference in New Issue
Block a user