Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix Calculator.conversion EmptyStackException bug #2076

Merged
merged 1 commit into from Jan 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -191,7 +191,7 @@ private static String transform(String expression) {
}
}
}
if (arr[0] == '~' || (arr.length > 1 && arr[1] == '(')) {
if (arr[0] == '~' && (arr.length > 1 && arr[1] == '(')) {
arr[0] = '-';
return "0" + new String(arr);
} else {
Expand Down
Expand Up @@ -31,10 +31,15 @@ public void conversationTest4(){
}

@Test
@Ignore
public void conversationTest5(){
// https://github.com/dromara/hutool/issues/1984
final double conversion = Calculator.conversion("((1/1) / (1/1) -1) * 100");
Assert.assertEquals((88D * 66 / 23) % 26, conversion, 2);
Assert.assertEquals(0, conversion, 2);
}

@Test
public void conversationTest6() {
final double conversion = Calculator.conversion("-((2.12-2) * 100)");
Assert.assertEquals(-1D * (2.12 - 2) * 100, conversion, 2);
}
}