Package com.asakusafw.runtime.value

Examples of com.asakusafw.runtime.value.FloatOption


        super(TypeInfoFactory.floatTypeInfo);
    }

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


        return new FloatOption();
    }

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

        return object.get();
    }

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

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

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

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

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

     * test for float values.
     * @throws Exception if failed
     */
    @Test
    public void float_values() throws Exception {
        assertRestorable(new FloatOption(0));
        assertRestorable(new FloatOption(1));
        assertRestorable(new FloatOption(-1));
        assertRestorable(new FloatOption(50));
        assertRestorable(new FloatOption(-50));
        assertRestorable(new FloatOption(Float.MAX_VALUE));
        assertRestorable(new FloatOption(Float.MIN_VALUE));
        assertRestorable(new FloatOption());
    }
View Full Code Here

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        value.modify(+0.f);
        emitter.emit(value);
        value.modify(-0.f);
        emitter.emit(value);
        value.modify(+10.5f);
        emitter.emit(value);
        value.modify(-10.5f);
        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.f));
        parser.fill(value);
        assertThat(value.get(), is(-0.f));
        parser.fill(value);
        assertThat(value.get(), is(+10.5f));
        parser.fill(value);
        assertThat(value.get(), is(-10.5f));

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

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

TOP

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

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.