test
This commit is contained in:
parent
567551d952
commit
22c9225640
@ -388,16 +388,18 @@ public class CalculatorEngineTest {
|
|||||||
Assert.assertEquals("1 446 257 064 651.832", cm.evaluate(JsclOperation.numeric, "28*28 * sin(28) - 0b:1101 + √(28) + exp ( 28) ").getResult());
|
Assert.assertEquals("1 446 257 064 651.832", cm.evaluate(JsclOperation.numeric, "28*28 * sin(28) - 0b:1101 + √(28) + exp ( 28) ").getResult());
|
||||||
Assert.assertEquals("13", cm.evaluate(JsclOperation.numeric, "0b:1101").getResult());
|
Assert.assertEquals("13", cm.evaluate(JsclOperation.numeric, "0b:1101").getResult());
|
||||||
|
|
||||||
|
try {
|
||||||
|
cm.evaluate(JsclOperation.numeric, "0b:π").getResult();
|
||||||
|
Assert.fail();
|
||||||
|
} catch (CalculatorParseException e) {
|
||||||
|
// ok
|
||||||
|
}
|
||||||
|
|
||||||
final NumeralBase defaultNumeralBase = cm.getEngine().getNumeralBase();
|
final NumeralBase defaultNumeralBase = cm.getEngine().getNumeralBase();
|
||||||
try{
|
try{
|
||||||
cm.getEngine().setNumeralBase(NumeralBase.bin);
|
cm.getEngine().setNumeralBase(NumeralBase.bin);
|
||||||
Assert.assertEquals("101", cm.evaluate(JsclOperation.numeric, "10+11").getResult());
|
Assert.assertEquals("101", cm.evaluate(JsclOperation.numeric, "10+11").getResult());
|
||||||
try {
|
Assert.assertEquals("10/11", cm.evaluate(JsclOperation.numeric, "10/11").getResult());
|
||||||
cm.evaluate(JsclOperation.numeric, "10/11");
|
|
||||||
fail();
|
|
||||||
} catch (CalculatorEvalException e) {
|
|
||||||
// ok
|
|
||||||
}
|
|
||||||
|
|
||||||
cm.getEngine().setNumeralBase(NumeralBase.hex);
|
cm.getEngine().setNumeralBase(NumeralBase.hex);
|
||||||
Assert.assertEquals("63 7B", cm.evaluate(JsclOperation.numeric, "56CE+CAD").getResult());
|
Assert.assertEquals("63 7B", cm.evaluate(JsclOperation.numeric, "56CE+CAD").getResult());
|
||||||
|
Loading…
Reference in New Issue
Block a user