Skip to content

Commit ba849f5

Browse files
author
linzhijun
committed
添加 测试案例
1 parent 803f803 commit ba849f5

File tree

2 files changed

+28
-12
lines changed

2 files changed

+28
-12
lines changed

java/toolgood.algorithm/src/main/java/toolgood/algorithm/Operand.java

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public int IntValue() {
4747
public long LongValue() {
4848
return 0;
4949
}
50-
50+
public Object Value(){return null;}
5151

5252
public String TextValue() {
5353
return null;
@@ -292,10 +292,15 @@ else if (v.IsNull())
292292
}
293293

294294
static abstract class OperandT<T> extends Operand {
295-
public T Value;
295+
protected T _value;
296+
297+
@Override
298+
public Object Value() {
299+
return _value;
300+
}
296301

297302
public OperandT(final T obj) {
298-
Value = obj;
303+
_value = obj;
299304
}
300305
}
301306

@@ -311,7 +316,7 @@ public OperandType Type() {
311316

312317
@Override
313318
public List<Operand> ArrayValue() {
314-
return Value;
319+
return _value;
315320
}
316321
}
317322

@@ -327,7 +332,7 @@ public OperandType Type() {
327332

328333
@Override
329334
public boolean BooleanValue() {
330-
return Value;
335+
return _value;
331336
}
332337
}
333338

@@ -343,7 +348,7 @@ public OperandType Type() {
343348

344349
@Override
345350
public MyDate DateValue() {
346-
return Value;
351+
return _value;
347352
}
348353
}
349354

@@ -381,7 +386,7 @@ public OperandType Type() {
381386

382387
@Override
383388
public JsonData JsonValue() {
384-
return Value;
389+
return _value;
385390
}
386391
}
387392

@@ -414,22 +419,22 @@ public OperandType Type() {
414419

415420
@Override
416421
public int IntValue() {
417-
return Value.intValue();
422+
return _value.intValue();
418423
}
419424

420425
@Override
421426
public BigDecimal NumberValue() {
422-
return Value;
427+
return _value;
423428
}
424429

425430
@Override
426431
public double DoubleValue() {
427-
return Value.doubleValue();
432+
return _value.doubleValue();
428433
}
429434

430435
@Override
431436
public long LongValue(){
432-
return Value.longValue();
437+
return _value.longValue();
433438
}
434439
}
435440

@@ -446,7 +451,7 @@ public OperandType Type() {
446451

447452
@Override
448453
public String TextValue() {
449-
return Value;
454+
return _value;
450455
}
451456

452457
}

java/toolgood.algorithm/src/test/java/toolgood/algorithm/Tests/AlgorithmEngineTest.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
import org.junit.Test;
99

1010
import toolgood.algorithm.AlgorithmEngine;
11+
import toolgood.algorithm.Operand;
12+
import toolgood.algorithm.OperandType;
1113

1214
public class AlgorithmEngineTest {
1315

@@ -243,4 +245,13 @@ public void Test5555(){
243245

244246
}
245247

248+
@Test
249+
public void Year_test_withType() throws Exception {
250+
AlgorithmEngine engine = new AlgorithmEngine();
251+
engine.Parse("year(now())");
252+
Operand operand = engine.Evaluate();
253+
assertEquals(OperandType.NUMBER, operand.Type());
254+
assertEquals(Long.valueOf(DateTime.now().getYear()).longValue(), operand.LongValue());
255+
}
256+
246257
}

0 commit comments

Comments
 (0)