Skip to content

Commit 3a7b93b

Browse files
committed
test: add non numeric test
1 parent 76e6450 commit 3a7b93b

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

src/test/java/com/gotocompany/depot/maxcompute/converter/mapper/casted/FloatToDecimalDataTypeMapperTest.java

+22
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import com.aliyun.odps.type.TypeInfo;
66
import com.google.protobuf.Descriptors;
77
import com.gotocompany.depot.config.MaxComputeSinkConfig;
8+
import com.gotocompany.depot.exception.InvalidMessageException;
89
import org.junit.Before;
910
import org.junit.Test;
1011
import org.junit.jupiter.api.Assertions;
@@ -48,4 +49,25 @@ public void shouldMapProtoFloatValue() {
4849

4950
Assertions.assertEquals(input, result.floatValue());
5051
}
52+
53+
@Test(expected = InvalidMessageException.class)
54+
public void shouldThrowInvalidMessageWhenFloatIsPositiveInfinity() {
55+
float value = Float.POSITIVE_INFINITY;
56+
57+
decimalCastedFloatPrimitiveProtobufMappingStrategy.getProtoPayloadMapperMap().get(Descriptors.FieldDescriptor.Type.FLOAT).apply(value);
58+
}
59+
60+
@Test(expected = InvalidMessageException.class)
61+
public void shouldThrowInvalidMessageWhenFloatIsNegativeInfinity() {
62+
float value = Float.NEGATIVE_INFINITY;
63+
64+
decimalCastedFloatPrimitiveProtobufMappingStrategy.getProtoPayloadMapperMap().get(Descriptors.FieldDescriptor.Type.FLOAT).apply(value);
65+
}
66+
67+
@Test(expected = InvalidMessageException.class)
68+
public void shouldThrowInvalidMessageWhenFloatIsNaN() {
69+
float value = Float.NaN;
70+
71+
decimalCastedFloatPrimitiveProtobufMappingStrategy.getProtoPayloadMapperMap().get(Descriptors.FieldDescriptor.Type.FLOAT).apply(value);
72+
}
5173
}

0 commit comments

Comments
 (0)