use of com.google.cloud.spanner.pgadapter.parsers.Parser in project pgadapter by GoogleCloudPlatform.
the class ParserTest method validateCreateText.
private void validateCreateText(byte[] item, int oid, Object value) {
Parser text = Parser.create(item, oid, FormatCode.TEXT);
assertParserValueEqual(text, value);
}
use of com.google.cloud.spanner.pgadapter.parsers.Parser in project pgadapter by GoogleCloudPlatform.
the class ParserTest method testNumericParsing.
@Test
public void testNumericParsing() {
BigDecimal value = new BigDecimal("1234567890.1234567890");
byte[] byteResult = ByteConverter.numeric(new BigDecimal("1234567890.1234567890"));
byte[] stringResult = { '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '.', '1', '2', '3', '4', '5', '6', '7', '8', '9', '0' };
Parser parser = new NumericParser(value);
validate(parser, byteResult, stringResult, stringResult);
assertThat(parser.getItem(), is(equalTo(value)));
validateCreateBinary(byteResult, Oid.NUMERIC, value);
validateCreateText(stringResult, Oid.NUMERIC, value);
}
use of com.google.cloud.spanner.pgadapter.parsers.Parser in project pgadapter by GoogleCloudPlatform.
the class ParserTest method testPositiveLongParsing.
@Test
public void testPositiveLongParsing() {
long value = 1234567890L;
byte[] byteResult = { 0, 0, 0, 0, 73, -106, 2, -46 };
byte[] stringResult = { '1', '2', '3', '4', '5', '6', '7', '8', '9', '0' };
Parser parsedValue = new LongParser(value);
validate(parsedValue, byteResult, stringResult, stringResult);
validateCreateBinary(byteResult, Oid.INT8, value);
validateCreateText(stringResult, Oid.INT8, value);
}
use of com.google.cloud.spanner.pgadapter.parsers.Parser in project pgadapter by GoogleCloudPlatform.
the class ParserTest method validateCreateBinary.
private void validateCreateBinary(byte[] item, int oid, Object value) {
Parser binary = Parser.create(item, oid, FormatCode.BINARY);
assertParserValueEqual(binary, value);
}
use of com.google.cloud.spanner.pgadapter.parsers.Parser in project pgadapter by GoogleCloudPlatform.
the class ParserTest method testPositiveIntegerParsing.
@Test
public void testPositiveIntegerParsing() {
int value = 1234567890;
byte[] byteResult = { 73, -106, 2, -46 };
byte[] stringResult = { '1', '2', '3', '4', '5', '6', '7', '8', '9', '0' };
Parser parsedValue = new IntegerParser(value);
validate(parsedValue, byteResult, stringResult, stringResult);
validateCreateBinary(byteResult, Oid.INT4, value);
validateCreateText(stringResult, Oid.INT4, value);
}
Aggregations