Package com.asakusafw.runtime.value

Examples of com.asakusafw.runtime.value.DoubleOption


        super(TypeInfoFactory.doubleTypeInfo);
    }

    @Override
    protected ValueOption<?> newObject() {
        return new DoubleOption();
    }
View Full Code Here


        return new DoubleOption();
    }

    @Override
    public Object getPrimitiveJavaObject(Object o) {
        DoubleOption object = (DoubleOption) o;
        if (object == null || object.isNull()) {
            return null;
        }
        return object.get();
    }
View Full Code Here

        return object.get();
    }

    @Override
    public Object getPrimitiveWritableObject(Object o) {
        DoubleOption object = (DoubleOption) o;
        if (object == null || object.isNull()) {
            return null;
        }
        return new DoubleWritable(object.get());
    }
View Full Code Here

     * floatの値を解析するテスト。
     * @throws Exception 例外が発生した場合
     */
    @Test
    public void fillDouble() throws Exception {
        DoubleOption value = new DoubleOption();
        create("float");

        assertThat(parser.next(), is(true));
        parser.fill(value);
        assertThat(value.get(), is(+0.d));
        parser.fill(value);
        assertThat(value.get(), is(-0.d));
        parser.fill(value);
        assertThat(value.get(), is(+10.5d));
        parser.fill(value);
        assertThat(value.get(), is(-10.5d));
        parser.endRecord();

        assertThat(parser.next(), is(true));
        parser.fill(value);
        assertThat(value.isNull(), is(true));
        parser.fill(value);
        assertThat(value.get(), is(Double.POSITIVE_INFINITY));
        parser.fill(value);
        assertThat(value.get(), is(Double.NEGATIVE_INFINITY));
        parser.fill(value);
        assertThat(value.get(), is(Double.NaN));
        parser.endRecord();

        assertThat(parser.next(), is(false));
    }
View Full Code Here

     * test for double values.
     * @throws Exception if failed
     */
    @Test
    public void double_values() throws Exception {
        assertRestorable(new DoubleOption(0));
        assertRestorable(new DoubleOption(1));
        assertRestorable(new DoubleOption(-1));
        assertRestorable(new DoubleOption(50));
        assertRestorable(new DoubleOption(-50));
        assertRestorable(new DoubleOption(Double.MAX_VALUE));
        assertRestorable(new DoubleOption(Double.MIN_VALUE));
        assertRestorable(new DoubleOption());
    }
View Full Code Here

    @Test
    public void double_values() throws Exception {
        CsvParser parser = create(
                "0,1,50,-1,-50,"
                + "0.5,-0.5,100.,-100., 0,0 ,");
        DoubleOption option = new DoubleOption();

        assertThat(parser.next(), is(true));

        parser.fill(option);
        assertThat(option.get(), is((double) 0));

        parser.fill(option);
        assertThat(option.get(), is((double) 1));

        parser.fill(option);
        assertThat(option.get(), is((double) 50));

        parser.fill(option);
        assertThat(option.get(), is((double) -1));

        parser.fill(option);
        assertThat(option.get(), is((double) -50));

        parser.fill(option);
        assertThat(option.get(), is(0.5));

        parser.fill(option);
        assertThat(option.get(), is(-0.5));

        parser.fill(option);
        assertThat(option.get(), is(100.));

        parser.fill(option);
        assertThat(option.get(), is(-100.));

        parser.fill(option);
        assertThat(option.get(), is((double) 0));

        parser.fill(option);
        assertThat(option.get(), is((double) 0));

        parser.fill(option);
        assertThat(option.isNull(), is(true));

        parser.endRecord();
        assertThat(parser.next(), is(false));
    }
View Full Code Here

    @Test
    public void invalid_double() throws Exception {
        CsvParser parser = create(String.valueOf("?"));
        assertThat(parser.next(), is(true));
        try {
            parser.fill(new DoubleOption());
            fail();
        } catch (CsvFormatException e) {
            assertThat(e.getStatus().getReason(), is(Reason.INVALID_CELL_FORMAT));
        }
    }
View Full Code Here

     * doubleの値を出力するテスト。
     * @throws Exception 例外が発生した場合
     */
    @Test
    public void emitDouble() throws Exception {
        DoubleOption value = new DoubleOption();

        value.modify(+0.d);
        emitter.emit(value);
        value.modify(-0.d);
        emitter.emit(value);
        value.modify(+10.5d);
        emitter.emit(value);
        value.modify(-10.5d);
        emitter.emit(value);
        emitter.endRecord();

        value.setNull();
        emitter.emit(value);
        value.modify(Float.POSITIVE_INFINITY);
        emitter.emit(value);
        value.modify(Float.NEGATIVE_INFINITY);
        emitter.emit(value);
        value.modify(Float.NaN);
        emitter.emit(value);
        emitter.endRecord();

        emitter.close();
        emitter.close();

        RecordParser parser = parser();
        assertThat(parser.next(), is(true));
        parser.fill(value);
        assertThat(value.get(), is(+0.d));
        parser.fill(value);
        assertThat(value.get(), is(-0.d));
        parser.fill(value);
        assertThat(value.get(), is(+10.5d));
        parser.fill(value);
        assertThat(value.get(), is(-10.5d));

        assertThat(parser.next(), is(true));
        parser.fill(value);
        assertThat(value.isNull(), is(true));
        parser.fill(value);
        assertThat(value.get(), is(Double.POSITIVE_INFINITY));
        parser.fill(value);
        assertThat(value.get(), is(Double.NEGATIVE_INFINITY));
        parser.fill(value);
        assertThat(value.get(), is(Double.NaN));

        assertThat(parser.next(), is(false));
    }
View Full Code Here

TOP

Related Classes of com.asakusafw.runtime.value.DoubleOption

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.