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

解决单字符无法比较bug #21

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/main/java/com/ql/util/express/Operator.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ public static int compareData(Object op1,Object op2) throws Exception{
//数字比较
compareResult = OperatorOfNumber.compareNumber((Number)op1, (Number)op2);
}
else if (op1 instanceof Character && op2 instanceof Character) {
compareResult = ((Character) op1).compareTo((Character) op2);
}
else if ((op1 instanceof Boolean) && (op2 instanceof Boolean))
{
if (((Boolean)op1).booleanValue() ==((Boolean)op2).booleanValue())
Expand Down
7 changes: 7 additions & 0 deletions src/test/java/com/ql/util/express/example/OperatorTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -86,4 +86,11 @@ public void testAddTwiceWithParams() throws Exception{
System.out.println(r);
Assert.assertTrue("操作符执行错误",r==49);
}
@Test
public void testCharcharComapre() throws Exception {
ExpressRunner runner = new ExpressRunner();
String express = "'a'=='a' && '9.2'>='9.2' && '2018-05-09 17:47:31'>='2018-05-09 17:47:30'";
Boolean r = (Boolean) runner.execute(express, null, null, true, false);
assert r == true;
}
}