@Test
public void evaluateAggregate(){

	FieldName name = FieldName.create("x");
	TypeInfo typeInfo = new SimpleTypeInfo(DataType.DATE, OpType.ORDINAL);
	List<?> values = Arrays.asList(TypeUtil.parse(DataType.DATE, "2013-01-01"), TypeUtil.parse(DataType.DATE, "2013-02-01"), TypeUtil.parse(DataType.DATE, "2013-03-01"));
	Map<FieldName, FieldValue> arguments = Collections.singletonMap(name, FieldValue.create(typeInfo, values));
	Aggregate aggregate = new Aggregate(name, Aggregate.Function.COUNT);
	assertEquals(3, evaluate(aggregate, arguments));
	aggregate.setFunction(Aggregate.Function.MIN);
	assertEquals(values.get(0), evaluate(aggregate, arguments));
	aggregate.setFunction(Aggregate.Function.MAX);
	assertEquals(values.get(2), evaluate(aggregate, arguments));
	typeInfo = new SimpleTypeInfo(DataType.DATE, OpType.ORDINAL, Lists.reverse(values));
	arguments = Collections.singletonMap(name, FieldValue.create(typeInfo, values));
	aggregate.setFunction(Aggregate.Function.MIN);
	assertEquals(values.get(2), evaluate(aggregate, arguments));
	aggregate.setFunction(Aggregate.Function.MAX);
	assertEquals(values.get(0), evaluate(aggregate, arguments));
}