use of com.google.cloud.spanner.pgadapter.parsers.Parser in project pgadapter by GoogleCloudPlatform.
the class ParserTest method testBinaryParsing.
@Test
public void testBinaryParsing() {
ByteArray value = ByteArray.copyFrom(new byte[] { (byte) 0b01010101, (byte) 0b10101010 });
byte[] byteResult = { (byte) 0b01010101, (byte) 0b10101010 };
byte[] stringResult = { 'U', '\\', '2', '5', '2' };
Parser parsedValue = new BinaryParser(value);
validate(parsedValue, byteResult, stringResult, byteResult);
validateCreateBinary(byteResult, Oid.BYTEA, value);
validateCreateText(stringResult, Oid.BYTEA, value);
}
use of com.google.cloud.spanner.pgadapter.parsers.Parser in project pgadapter by GoogleCloudPlatform.
the class ParserTest method testStringParsing.
@Test
public void testStringParsing() {
String value = "This is a String.";
byte[] stringResult = { 'T', 'h', 'i', 's', ' ', 'i', 's', ' ', 'a', ' ', 'S', 't', 'r', 'i', 'n', 'g', '.' };
Parser parsedValue = new StringParser(value);
validate(parsedValue, stringResult, stringResult, stringResult);
validateCreateBinary(stringResult, Oid.VARCHAR, value);
validateCreateText(stringResult, Oid.VARCHAR, value);
}
use of com.google.cloud.spanner.pgadapter.parsers.Parser in project pgadapter by GoogleCloudPlatform.
the class ParserTest method testNegativeLongParsing.
@Test
public void testNegativeLongParsing() {
long value = -1234567890L;
byte[] byteResult = { -1, -1, -1, -1, -74, 105, -3, 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 testNegativeDoubleParsing.
@Test
public void testNegativeDoubleParsing() {
double value = -1234.56789d;
byte[] byteResult = { -64, -109, 74, 69, -124, -12, -58, -25 };
byte[] stringResult = { '-', '1', '2', '3', '4', '.', '5', '6', '7', '8', '9' };
Parser parsedValue = new DoubleParser(value);
validate(parsedValue, byteResult, stringResult, stringResult);
validateCreateBinary(byteResult, Oid.FLOAT8, value);
validateCreateText(stringResult, Oid.FLOAT8, value);
}
use of com.google.cloud.spanner.pgadapter.parsers.Parser in project pgadapter by GoogleCloudPlatform.
the class ParserTest method testPositiveDoubleParsing.
@Test
public void testPositiveDoubleParsing() {
double value = 1234.56789d;
byte[] byteResult = { 64, -109, 74, 69, -124, -12, -58, -25 };
byte[] stringResult = { '1', '2', '3', '4', '.', '5', '6', '7', '8', '9' };
Parser parsedValue = new DoubleParser(value);
validate(parsedValue, byteResult, stringResult, stringResult);
validateCreateBinary(byteResult, Oid.FLOAT8, value);
validateCreateText(stringResult, Oid.FLOAT8, value);
}
Aggregations