Package com.asakusafw.runtime.value

Examples of com.asakusafw.runtime.value.IntOption


        ((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


     * @throws Exception if failed
     */
    @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

     * @throws Exception if failed
     */
    @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

     * @throws Exception if failed
     */
    @Test
    public void compare() throws Exception {
        WritableRawComparableTuple a = new WritableRawComparableTuple(
                new IntOption(100),
                new IntOption(100),
                new IntOption(100));
        WritableRawComparableTuple b = new WritableRawComparableTuple(
                new IntOption(100),
                new IntOption(100),
                new IntOption(101));
        WritableRawComparableTuple c = new WritableRawComparableTuple(
                new IntOption(100),
                new IntOption(101),
                new IntOption(100));
        WritableRawComparableTuple d = new WritableRawComparableTuple(
                new IntOption(101),
                new IntOption(100),
                new IntOption(100));
        WritableRawComparableTuple e = new WritableRawComparableTuple(
                new IntOption(100),
                new IntOption(100),
                new IntOption(100));

        assertThat(cmp(a, b), is(lessThan(0)));
        assertThat(cmp(a, c), is(lessThan(0)));
        assertThat(cmp(a, d), is(lessThan(0)));
        assertThat(cmp(b, c), is(lessThan(0)));
View Full Code Here

     * test for int values.
     * @throws Exception if failed
     */
    @Test
    public void int_values() throws Exception {
        assertRestorable(new IntOption(0));
        assertRestorable(new IntOption(1));
        assertRestorable(new IntOption(-1));
        assertRestorable(new IntOption(50));
        assertRestorable(new IntOption(-50));
        assertRestorable(new IntOption(Integer.MAX_VALUE));
        assertRestorable(new IntOption(Integer.MIN_VALUE));
        assertRestorable(new IntOption());
    }
View Full Code Here

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

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

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

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

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

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

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

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

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

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

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

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

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

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

     * fundamental testing.
     * @throws Exception if failed
     */
    @Test
    public void fundamental() throws Exception {
        IntOption entity = new IntOption(100);
        InvertOrder invert = new InvertOrder(entity);
        assertThat(invert.getEntity(), sameInstance((Object) entity));
    }
View Full Code Here

     * Serialization testing.
     * @throws Exception if failed
     */
    @Test
    public void serialize() throws Exception {
        IntOption entity = new IntOption(100);
        InvertOrder invert = new InvertOrder(entity);

        byte[] serialized = ser(invert);
        InvertOrder restored = des(new InvertOrder(new IntOption()), serialized);

        assertThat(restored.getEntity(), is((Object) entity));
        assertThat(restored.getEntity(), not(sameInstance((Object) entity)));
    }
View Full Code Here

     * Comparison testing.
     * @throws Exception if failed
     */
    @Test
    public void compare() throws Exception {
        InvertOrder a = new InvertOrder(new IntOption(100));
        InvertOrder b = new InvertOrder(new IntOption(101));
        InvertOrder c = new InvertOrder(new IntOption(100));

        assertThat(cmp(a, b), is(greaterThan(0)));
        assertThat(cmp(b, a), is(lessThan(0)));
        assertThat(cmp(a, c), is(equalTo(0)));
    }
View Full Code Here

TOP

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

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.