@Override Type newElementType() { return Type.float64(); } }.test();
@Override Type newType() { return Type.float64(); } }.test();
@Override public double getFloat64() { checkType(Type.float64()); checkNotNull(); return value; }
@Override public double getDouble(int columnIndex) { checkNonNullOfType(columnIndex, Type.float64(), columnIndex); return getDoubleInternal(columnIndex); }
@Override public double getDouble(String columnName) { int columnIndex = getColumnIndex(columnName); checkNonNullOfType(columnIndex, Type.float64(), columnName); return getDoubleInternal(columnIndex); }
@Override public List<Double> getDoubleList(int columnIndex) { checkNonNullOfType(columnIndex, Type.array(Type.float64()), columnIndex); return getDoubleListInternal(columnIndex); }
@Override public double[] getDoubleArray(int columnIndex) { checkNonNullOfType(columnIndex, Type.array(Type.float64()), columnIndex); return getDoubleArrayInternal(columnIndex); }
@Override public double[] getDoubleArray(String columnName) { int columnIndex = getColumnIndex(columnName); checkNonNullOfType(columnIndex, Type.array(Type.float64()), columnName); return getDoubleArrayInternal(columnIndex); }
@Override public List<Double> getDoubleList(String columnName) { int columnIndex = getColumnIndex(columnName); checkNonNullOfType(columnIndex, Type.array(Type.float64()), columnName); return getDoubleListInternal(columnIndex); }
@Test public void nonNumberArray() { Struct row = execute( Statement.newBuilder( "SELECT [IEEE_DIVIDE(1, 0), IEEE_DIVIDE(-1, 0), IEEE_DIVIDE(0, 0)]"), Type.array(Type.float64())); assertThat(row.getDoubleList(0)).hasSize(3); assertThat(row.getDoubleList(0).get(0)).isPositiveInfinity(); assertThat(row.getDoubleList(0).get(1)).isNegativeInfinity(); assertThat(row.getDoubleList(0).get(2)).isNaN(); }
@Test public void negativeInfinity() { Struct row = execute(Statement.newBuilder("SELECT IEEE_DIVIDE(-1, 0)"), Type.float64()); assertThat(row.getDouble(0)).isNegativeInfinity(); }
@Test public void positiveInfinity() { Struct row = execute(Statement.newBuilder("SELECT IEEE_DIVIDE(1, 0)"), Type.float64()); assertThat(row.getDouble(0)).isPositiveInfinity(); }
@Test public void notANumber() { Struct row = execute(Statement.newBuilder("SELECT IEEE_DIVIDE(0, 0)"), Type.float64()); assertThat(row.getDouble(0)).isNaN(); }
@Test public void float64Wrapper() { Value v = Value.float64(Double.valueOf(1.23)); assertThat(v.getType()).isEqualTo(Type.float64()); assertThat(v.isNull()).isFalse(); assertThat(v.getFloat64()).isWithin(0.0001).of(1.23); assertThat(v.toString()).isEqualTo("1.23"); }
@Test public void float64() { Value v = Value.float64(1.23); assertThat(v.getType()).isEqualTo(Type.float64()); assertThat(v.isNull()).isFalse(); assertThat(v.getFloat64()).isWithin(0.0001).of(1.23); assertThat(v.toString()).isEqualTo("1.23"); }
@Test public void bindFloat64ArrayEmpty() { Struct row = execute( Statement.newBuilder("SELECT @v").bind("v").toFloat64Array(Arrays.<Double>asList()), Type.array(Type.float64())); assertThat(row.isNull(0)).isFalse(); assertThat(row.getDoubleList(0)).containsExactly(); }
@Test public void float64WrapperNull() { Value v = Value.float64(null); assertThat(v.getType()).isEqualTo(Type.float64()); assertThat(v.isNull()).isTrue(); assertThat(v.toString()).isEqualTo(NULL_STRING); expectedException.expect(IllegalStateException.class); expectedException.expectMessage("null value"); v.getFloat64(); }
@Test public void bindFloat64Null() { Struct row = execute(Statement.newBuilder("SELECT @v").bind("v").to((Double) null), Type.float64()); assertThat(row.isNull(0)).isTrue(); }
@Test public void bindFloat64() { Struct row = execute(Statement.newBuilder("SELECT @v").bind("v").to(2.0), Type.float64()); assertThat(row.isNull(0)).isFalse(); assertThat(row.getDouble(0)).isWithin(0.0).of(2.0); }
@Test public void bindFloat64ArrayNull() { Struct row = execute( Statement.newBuilder("SELECT @v").bind("v").toFloat64Array((double[]) null), Type.array(Type.float64())); assertThat(row.isNull(0)).isTrue(); }