added more tests for core classes

This commit is contained in:
Timo Westkämper 2011-08-09 09:10:02 +03:00
parent 7c2b0c139b
commit ecd407929f
2 changed files with 47 additions and 0 deletions

View File

@ -0,0 +1,30 @@
package com.mysema.query.util;
import static org.junit.Assert.*;
import org.junit.Test;
import com.mysema.codegen.Evaluator;
public class MultiComparatorTest {
private final Evaluator<Object[]> evaluator = new Evaluator<Object[]>() {
@Override
public Object[] evaluate(Object... args) {
return args;
}
@Override
public Class<? extends Object[]> getType() {
return Object[].class;
}
};
@Test
public void test() {
MultiComparator<Object[]> comparator = new MultiComparator<Object[]>(evaluator, new boolean[]{true, true});
assertTrue(comparator.compare(new Object[]{"a", "b"}, new Object[]{"a","c"}) < 0);
assertTrue(comparator.compare(new Object[]{"b", "a"}, new Object[]{"a","b"}) > 0);
assertTrue(comparator.compare(new Object[]{"b", "b"}, new Object[]{"b","b"}) == 0);
}
}

View File

@ -0,0 +1,17 @@
package com.mysema.util;
import static org.junit.Assert.*;
import java.util.Arrays;
import org.junit.Test;
public class ArrayUtilsTest {
@Test
public void test() {
Object[] array = ArrayUtils.combine(5, new Object[]{"a","b"}, new Object[]{"c","d","e"});
assertEquals(Arrays.asList("a","b","c","d","e"), Arrays.asList(array));
}
}