Search in sources :

Example 1 with DoubleParser

use of com.google.cloud.spanner.pgadapter.parsers.DoubleParser 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);
}
Also used : DoubleParser(com.google.cloud.spanner.pgadapter.parsers.DoubleParser) DoubleParser(com.google.cloud.spanner.pgadapter.parsers.DoubleParser) StatementParser(com.google.cloud.spanner.pgadapter.utils.StatementParser) ArrayParser(com.google.cloud.spanner.pgadapter.parsers.ArrayParser) BooleanParser(com.google.cloud.spanner.pgadapter.parsers.BooleanParser) NumericParser(com.google.cloud.spanner.pgadapter.parsers.NumericParser) StringParser(com.google.cloud.spanner.pgadapter.parsers.StringParser) BinaryParser(com.google.cloud.spanner.pgadapter.parsers.BinaryParser) Parser(com.google.cloud.spanner.pgadapter.parsers.Parser) IntegerParser(com.google.cloud.spanner.pgadapter.parsers.IntegerParser) CopyTreeParser(com.google.cloud.spanner.pgadapter.parsers.copy.CopyTreeParser) LongParser(com.google.cloud.spanner.pgadapter.parsers.LongParser) DateParser(com.google.cloud.spanner.pgadapter.parsers.DateParser) TimestampParser(com.google.cloud.spanner.pgadapter.parsers.TimestampParser) Test(org.junit.Test)

Example 2 with DoubleParser

use of com.google.cloud.spanner.pgadapter.parsers.DoubleParser 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);
}
Also used : DoubleParser(com.google.cloud.spanner.pgadapter.parsers.DoubleParser) DoubleParser(com.google.cloud.spanner.pgadapter.parsers.DoubleParser) StatementParser(com.google.cloud.spanner.pgadapter.utils.StatementParser) ArrayParser(com.google.cloud.spanner.pgadapter.parsers.ArrayParser) BooleanParser(com.google.cloud.spanner.pgadapter.parsers.BooleanParser) NumericParser(com.google.cloud.spanner.pgadapter.parsers.NumericParser) StringParser(com.google.cloud.spanner.pgadapter.parsers.StringParser) BinaryParser(com.google.cloud.spanner.pgadapter.parsers.BinaryParser) Parser(com.google.cloud.spanner.pgadapter.parsers.Parser) IntegerParser(com.google.cloud.spanner.pgadapter.parsers.IntegerParser) CopyTreeParser(com.google.cloud.spanner.pgadapter.parsers.copy.CopyTreeParser) LongParser(com.google.cloud.spanner.pgadapter.parsers.LongParser) DateParser(com.google.cloud.spanner.pgadapter.parsers.DateParser) TimestampParser(com.google.cloud.spanner.pgadapter.parsers.TimestampParser) Test(org.junit.Test)

Aggregations

ArrayParser (com.google.cloud.spanner.pgadapter.parsers.ArrayParser)2 BinaryParser (com.google.cloud.spanner.pgadapter.parsers.BinaryParser)2 BooleanParser (com.google.cloud.spanner.pgadapter.parsers.BooleanParser)2 DateParser (com.google.cloud.spanner.pgadapter.parsers.DateParser)2 DoubleParser (com.google.cloud.spanner.pgadapter.parsers.DoubleParser)2 IntegerParser (com.google.cloud.spanner.pgadapter.parsers.IntegerParser)2 LongParser (com.google.cloud.spanner.pgadapter.parsers.LongParser)2 NumericParser (com.google.cloud.spanner.pgadapter.parsers.NumericParser)2 Parser (com.google.cloud.spanner.pgadapter.parsers.Parser)2 StringParser (com.google.cloud.spanner.pgadapter.parsers.StringParser)2 TimestampParser (com.google.cloud.spanner.pgadapter.parsers.TimestampParser)2 CopyTreeParser (com.google.cloud.spanner.pgadapter.parsers.copy.CopyTreeParser)2 StatementParser (com.google.cloud.spanner.pgadapter.utils.StatementParser)2 Test (org.junit.Test)2