use of org.apache.calcite.linq4j.tree.Primitive in project calcite by apache.
the class PrimitiveTest method testSendSource.
/**
* Test for
* {@link Primitive#send(org.apache.calcite.linq4j.tree.Primitive.Source, org.apache.calcite.linq4j.tree.Primitive.Sink)}.
*/
@Test
public void testSendSource() {
final List<Object> list = new ArrayList<Object>();
for (Primitive primitive : Primitive.values()) {
primitive.send(new Primitive.Source() {
public boolean getBoolean() {
list.add(boolean.class);
return true;
}
public byte getByte() {
list.add(byte.class);
return 0;
}
public char getChar() {
list.add(char.class);
return 0;
}
public short getShort() {
list.add(short.class);
return 0;
}
public int getInt() {
list.add(int.class);
return 0;
}
public long getLong() {
list.add(long.class);
return 0;
}
public float getFloat() {
list.add(float.class);
return 0;
}
public double getDouble() {
list.add(double.class);
return 0;
}
public Object getObject() {
list.add(Object.class);
return 0;
}
}, new Primitive.Sink() {
public void set(boolean v) {
list.add(boolean.class);
list.add(v);
}
public void set(byte v) {
list.add(byte.class);
list.add(v);
}
public void set(char v) {
list.add(char.class);
list.add(v);
}
public void set(short v) {
list.add(short.class);
list.add(v);
}
public void set(int v) {
list.add(int.class);
list.add(v);
}
public void set(long v) {
list.add(long.class);
list.add(v);
}
public void set(float v) {
list.add(float.class);
list.add(v);
}
public void set(double v) {
list.add(double.class);
list.add(v);
}
public void set(Object v) {
list.add(Object.class);
list.add(v);
}
});
}
assertThat(list.toString(), equalTo("[boolean, boolean, true, " + "byte, byte, 0, " + "char, char, \u0000, " + "short, short, 0, " + "int, int, 0, " + "long, long, 0, " + "float, float, 0.0, " + "double, double, 0.0, " + "class java.lang.Object, class java.lang.Object, 0, " + "class java.lang.Object, class java.lang.Object, 0]"));
}
Aggregations