Search in sources :

Example 1 with NumericParser

use of com.google.cloud.spanner.pgadapter.parsers.NumericParser 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);
}
Also used : NumericParser(com.google.cloud.spanner.pgadapter.parsers.NumericParser) BigDecimal(java.math.BigDecimal) 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 NumericParser

use of com.google.cloud.spanner.pgadapter.parsers.NumericParser in project pgadapter by GoogleCloudPlatform.

the class ParserTest method testNumericParsingNaN.

@Test
public void testNumericParsingNaN() {
    Number value = Double.NaN;
    byte[] stringResult = { 'N', 'a', 'N' };
    NumericParser parser = new NumericParser(value);
    validate(parser, stringResult, stringResult, stringResult);
    assertThat(parser.getItem(), is(equalTo(value)));
    validateCreateText(stringResult, Oid.NUMERIC, value);
}
Also used : NumericParser(com.google.cloud.spanner.pgadapter.parsers.NumericParser) Test(org.junit.Test)

Aggregations

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