Package com.asakusafw.runtime.value

Examples of com.asakusafw.runtime.value.LongOption


        ((IntOption) tuple.get(0)).modify(100);
        ((LongOption) tuple.get(1)).modify(200L);
        ((StringOption) tuple.get(2)).modify("Hello, world!");

        assertThat(tuple.get(0), is((Object) new IntOption(100)));
        assertThat(tuple.get(1), is((Object) new LongOption(200L)));
        assertThat(tuple.get(2), is((Object) new StringOption("Hello, world!")));
    }
View Full Code Here


     */
    @Test
    public void createFromObjects() throws Exception {
        WritableRawComparableTuple tuple = new WritableRawComparableTuple(
                new IntOption(100),
                new LongOption(200L),
                new StringOption("Hello, world!"));

        assertThat(tuple.get(0), is((Object) new IntOption(100)));
        assertThat(tuple.get(1), is((Object) new LongOption(200L)));
        assertThat(tuple.get(2), is((Object) new StringOption("Hello, world!")));
    }
View Full Code Here

     */
    @Test
    public void serialize() throws Exception {
        WritableRawComparableTuple tuple = new WritableRawComparableTuple(
                new IntOption(100),
                new LongOption(200L),
                new StringOption("Hello, world!"));

        WritableRawComparableTuple restored = new WritableRawComparableTuple(
                IntOption.class,
                LongOption.class,
                StringOption.class);

        byte[] serialized = ser(tuple);
        des(restored, serialized);

        assertThat(restored.get(0), is((Object) new IntOption(100)));
        assertThat(restored.get(1), is((Object) new LongOption(200L)));
        assertThat(restored.get(2), is((Object) new StringOption("Hello, world!")));
    }
View Full Code Here

     * test for long values.
     * @throws Exception if failed
     */
    @Test
    public void long_vaules() throws Exception {
        assertRestorable(new LongOption(0));
        assertRestorable(new LongOption(1));
        assertRestorable(new LongOption(-1));
        assertRestorable(new LongOption(50));
        assertRestorable(new LongOption(-50));
        assertRestorable(new LongOption(Long.MAX_VALUE));
        assertRestorable(new LongOption(Long.MIN_VALUE));
        assertRestorable(new LongOption());
    }
View Full Code Here

    @Test
    public void long_values() throws Exception {
        CsvParser parser = create("0,1,50,-1,-50,"
                + Long.MAX_VALUE + ","
                + Long.MIN_VALUE + ", 0,0 ,");
        LongOption option = new LongOption();

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

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

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

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

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

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

        parser.fill(option);
        assertThat(option.get(), is(Long.MAX_VALUE));

        parser.fill(option);
        assertThat(option.get(), is(Long.MIN_VALUE));

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

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

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

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

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

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

        value.modify(0L);
        emitter.emit(value);
        value.modify(10L);
        emitter.emit(value);
        value.modify(-10L);
        emitter.emit(value);
        emitter.endRecord();

        value.setNull();
        emitter.emit(value);
        value.modify(Long.MAX_VALUE);
        emitter.emit(value);
        value.modify(Long.MIN_VALUE);
        emitter.emit(value);
        emitter.endRecord();

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

        RecordParser parser = parser();
        assertThat(parser.next(), is(true));
        parser.fill(value);
        assertThat(value.get(), is(0L));
        parser.fill(value);
        assertThat(value.get(), is(10L));
        parser.fill(value);
        assertThat(value.get(), is(-10L));

        assertThat(parser.next(), is(true));
        parser.fill(value);
        assertThat(value.isNull(), is(true));
        parser.fill(value);
        assertThat(value.get(), is(Long.MAX_VALUE));
        parser.fill(value);
        assertThat(value.get(), is(Long.MIN_VALUE));

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

        assertThat(union.getPosition(), is(1));
        ((StringOption) union.switchObject(2)).modify("Hello, world!");
        assertThat(union.getPosition(), is(2));

        assertThat(union.switchObject(0), is((Object) new IntOption(100)));
        assertThat(union.switchObject(1), is((Object) new LongOption(200L)));
        assertThat(union.switchObject(2), is((Object) new StringOption("Hello, world!")));
    }
View Full Code Here

     */
    @Test
    public void createFromObject() throws Exception {
        Union union = new WritableRawComparableUnion(
                new IntOption(100),
                new LongOption(200L),
                new StringOption("Hello, world!"));
        assertThat(union.switchObject(0), is((Object) new IntOption(100)));
        assertThat(union.switchObject(1), is((Object) new LongOption(200L)));
        assertThat(union.switchObject(2), is((Object) new StringOption("Hello, world!")));
    }
View Full Code Here

     */
    @Test
    public void serialize() throws Exception {
        WritableRawComparableUnion union = new WritableRawComparableUnion(
                new IntOption(100),
                new LongOption(200L),
                new StringOption("Hello, world!"),
                new StringOption());

        StringBuilder buf = new StringBuilder(100000);
        for (int i = 0, n = buf.capacity(); i < n; i++) {
            buf.append((char) ('A' + (i * 257 % 26)));
        }
        ((StringOption) union.switchObject(3)).modify(buf.toString());

        WritableRawComparableUnion r0 = new WritableRawComparableUnion(IntOption.class, LongOption.class, StringOption.class);
        union.switchObject(0);
        byte[] s0 = ser(union);
        des(r0, s0);
        assertThat(r0.getPosition(), is(0));
        assertThat(r0.getObject(), is((Object) new IntOption(100)));

        WritableRawComparableUnion r1 = new WritableRawComparableUnion(IntOption.class, LongOption.class, StringOption.class);
        union.switchObject(1);
        byte[] s1 = ser(union);
        des(r1, s1);
        assertThat(r1.getPosition(), is(1));
        assertThat(r1.getObject(), is((Object) new LongOption(200L)));

        WritableRawComparableUnion r2 = new WritableRawComparableUnion(IntOption.class, LongOption.class, StringOption.class);
        union.switchObject(2);
        byte[] s2 = ser(union);
        des(r2, s2);
View Full Code Here

TOP

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

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.