Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 0 additions & 36 deletions core/trino-main/src/test/java/io/trino/type/AbstractTestType.java
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@
import static java.lang.String.format;
import static java.util.Collections.unmodifiableSortedMap;
import static java.util.Objects.requireNonNull;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertFalse;
Expand Down Expand Up @@ -203,41 +202,6 @@ public void testBlock()
}
}

@Test
public void testRange()
{
assertThat(type.getRange())
.isEmpty();
}

@Test
public void testPreviousValue()
{
Object sampleValue = getSampleValue();
if (!type.isOrderable()) {
assertThatThrownBy(() -> type.getPreviousValue(sampleValue))
Comment thread
martint marked this conversation as resolved.
.isInstanceOf(IllegalStateException.class)
.hasMessage("Type is not orderable: " + type);
return;
}
assertThat(type.getPreviousValue(sampleValue))
.isEmpty();
}

@Test
public void testNextValue()
{
Object sampleValue = getSampleValue();
if (!type.isOrderable()) {
assertThatThrownBy(() -> type.getNextValue(sampleValue))
.isInstanceOf(IllegalStateException.class)
.hasMessage("Type is not orderable: " + type);
return;
}
assertThat(type.getNextValue(sampleValue))
.isEmpty();
}

protected Object getSampleValue()
{
return requireNonNull(Iterables.get(expectedStackValues.values(), 0), "sample value is null");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,15 @@
import io.trino.spi.block.Block;
import io.trino.spi.block.BlockBuilder;
import io.trino.spi.type.Type;
import org.junit.jupiter.api.Test;

import java.util.List;

import static io.trino.spi.type.BigintType.BIGINT;
import static io.trino.spi.type.TypeSignature.arrayType;
import static io.trino.type.InternalTypeManager.TESTING_TYPE_MANAGER;
import static io.trino.util.StructuralTestUtil.arrayBlockOf;
import static org.assertj.core.api.Assertions.assertThat;

public class TestBigintArrayType
extends AbstractTestType
Expand Down Expand Up @@ -54,4 +56,25 @@ protected Object getGreaterValue(Object value)

return blockBuilder.build();
}

@Test
public void testRange()
{
assertThat(type.getRange())
.isEmpty();
}

@Test
public void testPreviousValue()
{
assertThat(type.getPreviousValue(getSampleValue()))
.isEmpty();
}

@Test
public void testNextValue()
{
assertThat(type.getNextValue(getSampleValue()))
.isEmpty();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import io.trino.spi.block.Block;
import io.trino.spi.block.BlockBuilder;
import io.trino.spi.type.Type.Range;
import org.junit.jupiter.api.Test;

import java.util.Optional;

Expand Down Expand Up @@ -54,15 +55,15 @@ protected Object getGreaterValue(Object value)
return ((Long) value) + 1;
}

@Override
@Test
public void testRange()
{
Range range = type.getRange().orElseThrow();
assertEquals(range.getMin(), Long.MIN_VALUE);
assertEquals(range.getMax(), Long.MAX_VALUE);
}

@Override
@Test
public void testPreviousValue()
{
long minValue = Long.MIN_VALUE;
Expand All @@ -82,7 +83,7 @@ public void testPreviousValue()
.isEqualTo(Optional.of(maxValue - 1));
}

@Override
@Test
public void testNextValue()
{
long minValue = Long.MIN_VALUE;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,16 @@
import io.trino.spi.block.Block;
import io.trino.spi.block.BlockBuilder;
import io.trino.spi.type.Type;
import org.junit.jupiter.api.Test;

import java.util.Map;

import static io.trino.spi.type.BigintType.BIGINT;
import static io.trino.spi.type.VarcharType.VARCHAR;
import static io.trino.util.StructuralTestUtil.mapBlockOf;
import static io.trino.util.StructuralTestUtil.mapType;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;

public class TestBigintVarcharMapType
extends AbstractTestType
Expand All @@ -46,4 +49,27 @@ protected Object getGreaterValue(Object value)
{
throw new UnsupportedOperationException();
}

@Test
public void testRange()
{
assertThat(type.getRange())
.isEmpty();
}

@Test
public void testPreviousValue()
{
assertThatThrownBy(() -> type.getPreviousValue(getSampleValue()))
.isInstanceOf(IllegalStateException.class)
.hasMessage("Type is not orderable: " + type);
}

@Test
public void testNextValue()
{
assertThatThrownBy(() -> type.getPreviousValue(getSampleValue()))
.isInstanceOf(IllegalStateException.class)
.hasMessage("Type is not orderable: " + type);
}
}
22 changes: 22 additions & 0 deletions core/trino-main/src/test/java/io/trino/type/TestBooleanType.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

import static io.trino.block.BlockAssertions.assertBlockEquals;
import static io.trino.spi.type.BooleanType.BOOLEAN;
import static org.assertj.core.api.Assertions.assertThat;
import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertTrue;

Expand Down Expand Up @@ -87,4 +88,25 @@ protected Object getGreaterValue(Object value)
{
return true;
}

@Test
public void testRange()
{
assertThat(type.getRange())
.isEmpty();
}

@Test
public void testPreviousValue()
{
assertThat(type.getPreviousValue(getSampleValue()))
.isEmpty();
}

@Test
public void testNextValue()
{
assertThat(type.getNextValue(getSampleValue()))
.isEmpty();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,11 @@
import io.trino.spi.block.BlockBuilder;
import io.trino.spi.type.Type;
import io.trino.spi.type.VarcharType;
import org.junit.jupiter.api.Test;

import static io.trino.spi.type.VarcharType.createVarcharType;
import static java.lang.Character.MAX_CODE_POINT;
import static org.assertj.core.api.Assertions.assertThat;
import static org.testng.Assert.assertEquals;

public class TestBoundedVarcharType
Expand Down Expand Up @@ -55,11 +57,25 @@ protected Object getGreaterValue(Object value)
return Slices.utf8Slice(((Slice) value).toStringUtf8() + "_");
}

@Override
@Test
public void testRange()
{
Type.Range range = type.getRange().orElseThrow();
assertEquals(range.getMin(), Slices.utf8Slice(""));
assertEquals(range.getMax(), Slices.utf8Slice(Character.toString(MAX_CODE_POINT).repeat(((VarcharType) type).getBoundedLength())));
}

@Test
public void testPreviousValue()
{
assertThat(type.getPreviousValue(getSampleValue()))
.isEmpty();
}

@Test
public void testNextValue()
{
assertThat(type.getNextValue(getSampleValue()))
.isEmpty();
}
}
17 changes: 16 additions & 1 deletion core/trino-main/src/test/java/io/trino/type/TestCharType.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import static java.lang.Character.MIN_CODE_POINT;
import static java.lang.Character.MIN_SUPPLEMENTARY_CODE_POINT;
import static java.lang.Character.isSupplementaryCodePoint;
import static org.assertj.core.api.Assertions.assertThat;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNotNull;

Expand Down Expand Up @@ -89,11 +90,25 @@ public void testGetObjectValue()
}
}

@Override
@Test
public void testRange()
{
Type.Range range = type.getRange().orElseThrow();
assertEquals(range.getMin(), Slices.utf8Slice(Character.toString(MIN_CODE_POINT).repeat(((CharType) type).getLength())));
assertEquals(range.getMax(), Slices.utf8Slice(Character.toString(MAX_CODE_POINT).repeat(((CharType) type).getLength())));
}

@Test
public void testPreviousValue()
{
assertThat(type.getPreviousValue(getSampleValue()))
.isEmpty();
}

@Test
public void testNextValue()
{
assertThat(type.getNextValue(getSampleValue()))
.isEmpty();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,16 @@
import io.trino.spi.block.Block;
import io.trino.spi.block.BlockBuilder;
import io.trino.spi.type.Type;
import org.junit.jupiter.api.Test;

import java.util.List;

import static io.trino.spi.type.TypeSignature.arrayType;
import static io.trino.type.ColorType.COLOR;
import static io.trino.type.InternalTypeManager.TESTING_TYPE_MANAGER;
import static io.trino.util.StructuralTestUtil.arrayBlockOf;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;

public class TestColorArrayType
extends AbstractTestType
Expand All @@ -47,4 +50,27 @@ protected Object getGreaterValue(Object value)
{
throw new UnsupportedOperationException();
}

@Test
public void testRange()
{
assertThat(type.getRange())
.isEmpty();
}

@Test
public void testPreviousValue()
{
assertThatThrownBy(() -> type.getPreviousValue(getSampleValue()))
.isInstanceOf(IllegalStateException.class)
.hasMessage("Type is not orderable: " + type);
}

@Test
public void testNextValue()
{
assertThatThrownBy(() -> type.getNextValue(getSampleValue()))
.isInstanceOf(IllegalStateException.class)
.hasMessage("Type is not orderable: " + type);
}
}
27 changes: 26 additions & 1 deletion core/trino-main/src/test/java/io/trino/type/TestColorType.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
import static io.trino.operator.scalar.ColorFunctions.rgb;
import static io.trino.type.ColorType.COLOR;
import static java.lang.String.format;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.testng.Assert.assertEquals;

public class TestColorType
Expand All @@ -33,7 +35,7 @@ public TestColorType()
@Test
public void testGetObjectValue()
{
int[] valuesOfInterest = new int[]{0, 1, 15, 16, 127, 128, 255};
int[] valuesOfInterest = new int[] {0, 1, 15, 16, 127, 128, 255};
BlockBuilder builder = COLOR.createFixedSizeBlockBuilder(valuesOfInterest.length * valuesOfInterest.length * valuesOfInterest.length);
for (int r : valuesOfInterest) {
for (int g : valuesOfInterest) {
Expand Down Expand Up @@ -74,4 +76,27 @@ protected Object getGreaterValue(Object value)
{
throw new UnsupportedOperationException();
}

@Test
public void testRange()
{
assertThat(type.getRange())
.isEmpty();
}

@Test
public void testPreviousValue()
{
assertThatThrownBy(() -> type.getPreviousValue(getSampleValue()))
.isInstanceOf(IllegalStateException.class)
.hasMessage("Type is not orderable: " + type);
}

@Test
public void testNextValue()
{
assertThatThrownBy(() -> type.getNextValue(getSampleValue()))
.isInstanceOf(IllegalStateException.class)
.hasMessage("Type is not orderable: " + type);
}
}
Loading