naturallogarithmtest.java

来自「这个是一个计算表达式的java包」· Java 代码 · 共 38 行

JAVA
38
字号
package com.singularsys.jeptests.functions;

import com.singularsys.jep.EvaluationException;
import com.singularsys.jep.functions.NaturalLogarithm;

import junit.framework.Assert;
import junit.framework.TestCase;

public class NaturalLogarithmTest extends TestCase {

	public NaturalLogarithmTest(String name) {
		super(name);
	}

	/**
	 * Test method for 'org.nfunk.jep.function.Logarithm.run(Stack)'
	 * Tests the return value of log(NaN). This is a test for bug #1177557
	 */
	public void testNaturalLogarithm() {
		NaturalLogarithm logFunction = new NaturalLogarithm();
		java.util.Stack<Object> stack = new java.util.Stack<Object>();
		stack.push(new Double(Double.NaN));
		try {
			logFunction.run(stack);
		} catch (EvaluationException e) {
			Assert.fail();
		}
		Object returnValue = stack.pop();

		if (returnValue instanceof Double) {
			Assert.assertTrue(Double.isNaN(((Double)returnValue).doubleValue()));
		} else {
			Assert.fail();
		}
	}

}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?