use of com.google.cloud.spanner.pgadapter.parsers.Parser in project pgadapter by GoogleCloudPlatform.
the class ParserTest method testNegativeIntegerParsing.
@Test
public void testNegativeIntegerParsing() {
int value = -1234567890;
byte[] byteResult = { -74, 105, -3, 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);
}
use of com.google.cloud.spanner.pgadapter.parsers.Parser in project pgadapter by GoogleCloudPlatform.
the class ParserTest method testFalseBooleanParsing.
@Test
public void testFalseBooleanParsing() {
boolean value = false;
byte[] byteResult = { 0 };
byte[] stringResult = { 'f' };
byte[] spannerResult = { 'f', 'a', 'l', 's', 'e' };
Parser parsedValue = new BooleanParser(value);
validate(parsedValue, byteResult, stringResult, spannerResult);
validateCreateBinary(byteResult, Oid.BIT, value);
validateCreateText(stringResult, Oid.BIT, value);
}
use of com.google.cloud.spanner.pgadapter.parsers.Parser in project pgadapter by GoogleCloudPlatform.
the class ParserTest method testTrueBooleanParsing.
@Test
public void testTrueBooleanParsing() {
boolean value = true;
byte[] byteResult = { 1 };
byte[] stringResult = { 't' };
byte[] spannerResult = { 't', 'r', 'u', 'e' };
Parser parsedValue = new BooleanParser(value);
validate(parsedValue, byteResult, stringResult, spannerResult);
validateCreateBinary(byteResult, Oid.BIT, value);
validateCreateText(stringResult, Oid.BIT, value);
}
use of com.google.cloud.spanner.pgadapter.parsers.Parser in project pgadapter by GoogleCloudPlatform.
the class ParserTest method testTimestampParsingBytePart.
@Test
public void testTimestampParsingBytePart() {
Timestamp value = Timestamp.ofTimeMicroseconds(904910400000000L);
byte[] byteResult = { -1, -1, -38, 1, -93, -70, 48, 0 };
Parser parsedValue = new TimestampParser(value);
assertThat(parsedValue.parse(DataFormat.POSTGRESQL_BINARY), is(equalTo(byteResult)));
validateCreateBinary(byteResult, Oid.TIMESTAMP, value);
}
use of com.google.cloud.spanner.pgadapter.parsers.Parser in project pgadapter by GoogleCloudPlatform.
the class ParserTest method testDateParsing.
@Test
public void testDateParsing() {
// Google founding date :)
Date value = Date.fromYearMonthDay(1998, 9, 4);
byte[] byteResult = { -1, -1, -2, 28 };
byte[] stringResult = { '1', '9', '9', '8', '-', '0', '9', '-', '0', '4' };
Parser parsedValue = new DateParser(value);
validate(parsedValue, byteResult, stringResult, stringResult);
validateCreateBinary(byteResult, Oid.DATE, value);
validateCreateText(stringResult, Oid.DATE, value);
}
Aggregations