Skip to content

Commit

Permalink
fix 测试用例
Browse files Browse the repository at this point in the history
  • Loading branch information
linzhijun committed Sep 21, 2023
1 parent 1479170 commit 3db819c
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ public void Test() throws Exception {
e = engine.TryEvaluate("pi", 0.0);
assertEquals(Math.PI - e, 0.0, 0.01);

boolean b = engine.TryEvaluate("true", true);
boolean b = engine.TryEvaluate("true", false);
assertEquals(true, b);
b = engine.TryEvaluate("false", false);
b = engine.TryEvaluate("false", true);
assertEquals(false, b);

int b1 = engine.TryEvaluate("if(true,1,2)", 0);
Expand Down Expand Up @@ -119,7 +119,7 @@ public void base_test() {
boolean b = engine.TryEvaluate("1=1", false);
assertEquals(true, b);

b = engine.TryEvaluate("1=2", false);
b = engine.TryEvaluate("1=2", true);
assertEquals(false, b);

b = engine.TryEvaluate("1<>2", false);
Expand All @@ -128,7 +128,7 @@ public void base_test() {
b = engine.TryEvaluate("1!=2", false);
assertEquals(true, b);

b = engine.TryEvaluate("1>2", false);
b = engine.TryEvaluate("1>2", true);
assertEquals(false, b);

b = engine.TryEvaluate("1<2", false);
Expand All @@ -137,7 +137,7 @@ public void base_test() {
b = engine.TryEvaluate("1<=2", false);
assertEquals(true, b);

b = engine.TryEvaluate("1>=2", false);
b = engine.TryEvaluate("1>=2", true);
assertEquals(false, b);

b = engine.TryEvaluate("'1'='1'", false);
Expand All @@ -146,7 +146,7 @@ public void base_test() {
b = engine.TryEvaluate("'e'='e'", false);
assertEquals(true, b);

b = engine.TryEvaluate("'1'='2'", false);
b = engine.TryEvaluate("'1'='2'", true);
assertEquals(false, b);

b = engine.TryEvaluate("'1'!='2'", false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public void IsRegex_test()
AlgorithmEngine engine = new AlgorithmEngine();
boolean r = engine.TryEvaluate("IsRegex('abcd','a.*c')", false);
assertEquals(r, true);
r = engine.TryEvaluate("IsRegex('abcd','da.*c')", false);
r = engine.TryEvaluate("IsRegex('abcd','da.*c')", true);
assertEquals(r, false);
}

Expand Down Expand Up @@ -211,7 +211,7 @@ public void StartsWith()
AlgorithmEngine engine = new AlgorithmEngine();
boolean dt = engine.TryEvaluate("StartsWith('123456789','12')", false);
assertEquals(dt, true);
dt = engine.TryEvaluate("StartsWith('123456789','127')", false);
dt = engine.TryEvaluate("StartsWith('123456789','127')", true);
assertEquals(dt, false);
}
@Test
Expand All @@ -220,7 +220,7 @@ public void EndsWith()
AlgorithmEngine engine = new AlgorithmEngine();
boolean dt = engine.TryEvaluate("EndsWith('123456789','89')", false);
assertEquals(dt, true);
dt = engine.TryEvaluate("EndsWith('123456789','127')", false);
dt = engine.TryEvaluate("EndsWith('123456789','127')", true);
assertEquals(dt, false);
}

Expand All @@ -230,7 +230,7 @@ public void IsNullOrEmpty()
AlgorithmEngine engine = new AlgorithmEngine();
boolean dt = engine.TryEvaluate("IsNullOrEmpty('')", false);
assertEquals(dt, true);
dt = engine.TryEvaluate("IsNullOrEmpty(' ')", false);
dt = engine.TryEvaluate("IsNullOrEmpty(' ')", true);
assertEquals(dt, false);
}
@Test
Expand All @@ -241,7 +241,7 @@ public void IsNullOrWhiteSpace()
assertEquals(dt, true);
dt = engine.TryEvaluate("IsNullOrWhiteSpace(' ')", false);
assertEquals(dt, true);
dt = engine.TryEvaluate("IsNullOrWhiteSpace(' f ')", false);
dt = engine.TryEvaluate("IsNullOrWhiteSpace(' f ')", true);
assertEquals(dt, false);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,12 +179,12 @@ public void And_Test()
t = engine.TryEvaluate("and(true(),1)", false);
assertEquals(true, t);

t = engine.TryEvaluate("and(true(),false(),1=1)", false);
t = engine.TryEvaluate("and(true(),false(),1=1)", true);
assertEquals(false, t);
t = engine.TryEvaluate("and(true(),false(),1)", false);
t = engine.TryEvaluate("and(true(),false(),1)", true);
assertEquals(false, t);

t = engine.TryEvaluate("and(true(),0)", false);
t = engine.TryEvaluate("and(true(),0)", true);
assertEquals(false, t);
}

Expand All @@ -205,15 +205,15 @@ public void Or_Test()
t = engine.TryEvaluate("or(true(),0)", false);
assertEquals(true, t);

t = engine.TryEvaluate("or(false(),1=2)", false);
t = engine.TryEvaluate("or(false(),1=2)", true);
assertEquals(false, t);
}

@Test
public void Not_Test()
{
AlgorithmEngine engine = new AlgorithmEngine();
boolean t = engine.TryEvaluate("not(true())", false);
boolean t = engine.TryEvaluate("not(true())", true);
assertEquals(false, t);
t = engine.TryEvaluate("not(false())", false);
assertEquals(true, t);
Expand All @@ -231,7 +231,7 @@ public void true_Test()
public void false_Test()
{
AlgorithmEngine engine = new AlgorithmEngine();
boolean t = engine.TryEvaluate("false()", false);
boolean t = engine.TryEvaluate("false()", true);
assertEquals(false, t);
}

Expand All @@ -242,7 +242,7 @@ public void andor_Test()
boolean t = engine.TryEvaluate("1=1 && 2==2 and 3=3", false);
assertEquals(true, t);

t = engine.TryEvaluate("1=1 && 2!=2", false);
t = engine.TryEvaluate("1=1 && 2!=2", true);
assertEquals(false, t);

t = engine.TryEvaluate("1=1 && 2!=2", true);
Expand All @@ -255,7 +255,7 @@ public void andor_Test()
t = engine.TryEvaluate("1=1 and 2==2", false);
assertEquals(true, t);

t = engine.TryEvaluate("1=1 and 2!=2", false);
t = engine.TryEvaluate("1=1 and 2!=2", true);
assertEquals(false, t);

t = engine.TryEvaluate("1=1 and 2!=2", true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,16 +58,12 @@ public void CONCATENATE_test()
public void EXACT_test()
{
AlgorithmEngine engine = new AlgorithmEngine();
boolean t = engine.TryEvaluate("EXACT('tt','33')", false);
assertEquals(t, false);
t = engine.TryEvaluate("EXACT('tt','tt')", true);
assertEquals(t, true);
t = engine.TryEvaluate("EXACT('tt','33')", true);
boolean t = engine.TryEvaluate("EXACT('tt','33')", true);
assertEquals(t, false);
t = engine.TryEvaluate("EXACT('tt','tt')", false);
assertEquals(t, true);
t = engine.TryEvaluate("EXACT('33',33)", true);
assertEquals(t, false);
t = engine.TryEvaluate("EXACT('33',33)", false);
assertEquals(t, true);
t = engine.TryEvaluate("EXACT('331.1',331.1)", false);
assertEquals(t, true);
t = engine.TryEvaluate("EXACT('TRUE',TRUE())", false);
Expand Down

0 comments on commit 3db819c

Please sign in to comment.