registries

This commit is contained in:
Sergey Solovyev
2012-10-07 19:29:37 +04:00
parent d4cff84040
commit 78a1cc4942
32 changed files with 1441 additions and 1290 deletions

View File

@@ -31,7 +31,7 @@ public class FromJsclNumericTextProcessorTest {
public void testCreateResultForComplexNumber() throws Exception {
final FromJsclNumericTextProcessor cm = new FromJsclNumericTextProcessor();
final JsclMathEngine me = JsclMathEngine.instance;
final JsclMathEngine me = JsclMathEngine.getInstance();
final AngleUnit defaultAngleUnits = me.getAngleUnits();
Assert.assertEquals("1.22133+23 123i", cm.process(Expression.valueOf("1.22133232+23123*i").numeric()));

View File

@@ -1,70 +0,0 @@
/*
* Copyright (c) 2009-2011. Created by serso aka se.solovyev.
* For more information, please, contact se.solovyev@gmail.com
* or visit http://se.solovyev.org
*/
package org.solovyev.android.calculator.math;
import junit.framework.Assert;
import org.junit.BeforeClass;
import org.junit.Test;
import org.solovyev.android.calculator.CalculatorLocatorImpl;
/**
* User: serso
* Date: 10/5/11
* Time: 1:25 AM
*/
public class MathTypeTest {
@BeforeClass
public static void setUp() throws Exception {
CalculatorLocatorImpl.getInstance().getEngine().init();
}
@Test
public void testGetType() throws Exception {
Assert.assertEquals(MathType.function, MathType.getType("sin", 0, false).getMathType());
Assert.assertEquals(MathType.text, MathType.getType("sn", 0, false).getMathType());
Assert.assertEquals(MathType.text, MathType.getType("s", 0, false).getMathType());
Assert.assertEquals(MathType.text, MathType.getType("", 0, false).getMathType());
try {
Assert.assertEquals(MathType.text, MathType.getType("22", -1, false).getMathType());
Assert.fail();
} catch (IllegalArgumentException e) {
}
try {
Assert.assertEquals(MathType.text, MathType.getType("22", 2, false).getMathType());
Assert.fail();
} catch (IllegalArgumentException e) {
}
Assert.assertEquals("atanh", MathType.getType("atanh", 0, false).getMatch());
}
/* @Test
public void testPostfixFunctionsProcessing() throws Exception {
org.junit.Assert.assertEquals(-1, MathType.getPostfixFunctionStart("5!", 1));
org.junit.Assert.assertEquals(0, MathType.getPostfixFunctionStart("!", 1));
org.junit.Assert.assertEquals(-1, MathType.getPostfixFunctionStart("5.4434234!", 9));
org.junit.Assert.assertEquals(1, MathType.getPostfixFunctionStart("2+5!", 3));
org.junit.Assert.assertEquals(4, MathType.getPostfixFunctionStart("2.23+5.4434234!", 14));
org.junit.Assert.assertEquals(14, MathType.getPostfixFunctionStart("2.23+5.4434234*5!", 16));
org.junit.Assert.assertEquals(14, MathType.getPostfixFunctionStart("2.23+5.4434234*5.1!", 18));
org.junit.Assert.assertEquals(4, MathType.getPostfixFunctionStart("2.23+(5.4434234*5.1)!", 20));
org.junit.Assert.assertEquals(4, MathType.getPostfixFunctionStart("2.23+(5.4434234*(5.1+1))!", 24));
org.junit.Assert.assertEquals(4, MathType.getPostfixFunctionStart("2.23+(5.4434234*sin(5.1+1))!", 27));
org.junit.Assert.assertEquals(0, MathType.getPostfixFunctionStart("sin(5)!", 6));
org.junit.Assert.assertEquals(-1, MathType.getPostfixFunctionStart(")!", ")!".indexOf("!")));
org.junit.Assert.assertEquals(0, MathType.getPostfixFunctionStart("sin(5sin(5sin(5)))!", 18));
org.junit.Assert.assertEquals(2, MathType.getPostfixFunctionStart("2+sin(5sin(5sin(5)))!", 20));
org.junit.Assert.assertEquals(5, MathType.getPostfixFunctionStart("2.23+sin(5.4434234*sin(5.1+1))!", 30));
org.junit.Assert.assertEquals(5, MathType.getPostfixFunctionStart("2.23+sin(5.4434234*sin(5.1E2+e))!", "2.23+sin(5.4434234*sin(5.1E2+e))!".indexOf("!")));
org.junit.Assert.assertEquals(5, MathType.getPostfixFunctionStart("2.23+sin(5.4434234*sin(5.1E2+5 555 555))!", "2.23+sin(5.4434234*sin(5.1E2+5 555 555))!".indexOf("!")));
org.junit.Assert.assertEquals(5, MathType.getPostfixFunctionStart("2.23+sin(5.4434234^sin(5.1E2!+5'555'555))!", "2.23+sin(5.4434234^sin(5.1E2!+5'555'555))!".lastIndexOf("!")));
}*/
}

View File

@@ -36,7 +36,7 @@ public class NumeralBaseTest {
public void testConversion() throws Exception {
CSVReader reader = null;
try {
final MathEngine me = JsclMathEngine.instance;
final MathEngine me = JsclMathEngine.getInstance();
reader = new CSVReader(new InputStreamReader(NumeralBaseTest.class.getResourceAsStream("/org/solovyev/android/calculator/model/nb_table.csv")), '\t');

View File

@@ -152,15 +152,15 @@ public class ToJsclTextProcessorTest {
public void testNumeralBases() throws Exception {
final TextProcessor<PreparedExpression, String> processor = ToJsclTextProcessor.getInstance();
final NumeralBase defaultNumeralBase = JsclMathEngine.instance.getNumeralBase();
final NumeralBase defaultNumeralBase = JsclMathEngine.getInstance().getNumeralBase();
try{
JsclMathEngine.instance.setNumeralBase(NumeralBase.bin);
Assert.assertEquals("101", JsclMathEngine.instance.evaluate("10+11"));
JsclMathEngine.getInstance().setNumeralBase(NumeralBase.bin);
Assert.assertEquals("101", JsclMathEngine.getInstance().evaluate("10+11"));
JsclMathEngine.instance.setNumeralBase(NumeralBase.hex);
JsclMathEngine.getInstance().setNumeralBase(NumeralBase.hex);
Assert.assertEquals("56CE+CAD", processor.process("56CE+CAD").getExpression());
} finally {
JsclMathEngine.instance.setNumeralBase(defaultNumeralBase);
JsclMathEngine.getInstance().setNumeralBase(defaultNumeralBase);
}
}
}

View File

@@ -0,0 +1,19 @@
package org.solovyev.android.calculator.plot;
import com.xtremelabs.robolectric.RobolectricTestRunner;
import org.jetbrains.annotations.NotNull;
import org.junit.runners.model.InitializationError;
import java.io.File;
/**
* User: serso
* Date: 10/7/12
* Time: 5:36 PM
*/
public class CalculatorppTestRunner extends RobolectricTestRunner {
public CalculatorppTestRunner(@NotNull Class<?> testClass) throws InitializationError {
super(testClass, new File("calculatorpp"));
}
}

View File

@@ -12,13 +12,13 @@ import junit.framework.Assert;
import org.achartengine.model.XYSeries;
import org.jetbrains.annotations.NotNull;
import org.junit.Test;
import org.junit.runner.RunWith;
/**
* User: serso
* Date: 12/5/11
* Time: 9:07 PM
*/
public class PlotUtilsTest {
@Test