Package com.asakusafw.runtime.value

Examples of com.asakusafw.runtime.value.IntOption


     * @throws Exception テストに失敗した場合
     */
    @Test
    public void simple() throws Exception {
        VolatileLookUpTable.Builder<IntOption> builder = new VolatileLookUpTable.Builder<IntOption>();
        builder.add(key(100), new IntOption(100));

        LookUpTable<IntOption> table = builder.build();
        assertThat(sort(table.get(key(100))), is(values(100)));
        assertThat(sort(table.get(key(101))), is(values()));
    }
View Full Code Here


     * @throws Exception テストに失敗した場合
     */
    @Test
    public void duplicate() throws Exception {
        VolatileLookUpTable.Builder<IntOption> builder = new VolatileLookUpTable.Builder<IntOption>();
        builder.add(key(100), new IntOption(100));
        builder.add(key(100), new IntOption(101));
        builder.add(key(100), new IntOption(102));

        LookUpTable<IntOption> table = builder.build();
        assertThat(sort(table.get(key(100))), is(values(100, 101, 102)));
        assertThat(sort(table.get(key(101))), is(values()));
    }
View Full Code Here

    @Test
    public void reuseKeys() throws Exception {
        VolatileLookUpTable.Builder<IntOption> builder = new VolatileLookUpTable.Builder<IntOption>();
        LookUpKey key = key();

        key.add(new IntOption(100));
        builder.add(key, new IntOption(100));
        key.reset();

        key.add(new IntOption(101));
        builder.add(key, new IntOption(101));
        key.reset();

        key.add(new IntOption(102));
        builder.add(key, new IntOption(102));
        key.reset();

        LookUpTable<IntOption> table = builder.build();
        assertThat(sort(table.get(key(100))), is(values(100)));
        assertThat(sort(table.get(key(101))), is(values(101)));
View Full Code Here

    }

    private LookUpKey key(int... values) throws IOException {
        LookUpKey result = new LookUpKey();
        for (int value : values) {
            result.add(new IntOption(value));
        }
        return result;
    }
View Full Code Here

    }

    private List<IntOption> values(int...values) {
        List<IntOption> options = new ArrayList<IntOption>();
        for (int value : values) {
            options.add(new IntOption(value));
        }
        return sort(options);
    }
View Full Code Here

        ((LongOption) union.switchObject(1)).modify(200L);
        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

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

     * @throws Exception if failed
     */
    @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);
View Full Code Here

     * @throws Exception if failed
     */
    @Test
    public void compare() throws Exception {
        WritableRawComparableUnion a = new WritableRawComparableUnion(
                new IntOption(100),
                new LongOption(200L));

        WritableRawComparableUnion b = new WritableRawComparableUnion(
                new IntOption(101),
                new LongOption(201L));

        WritableRawComparableUnion c = new WritableRawComparableUnion(
                new IntOption(100),
                new LongOption(200L));

        a.switchObject(0);
        b.switchObject(0);
        c.switchObject(0);
View Full Code Here

    public void add() throws Exception {
        LookUpKey k1 = new LookUpKey();
        LookUpKey k2 = new LookUpKey(1000);
        LookUpKey k3 = new LookUpKey();

        k1.add(new IntOption(100));
        k2.add(new IntOption(100));
        k3.add(new IntOption(100));

        k1.add(new IntOption(101));
        k2.add(new IntOption(101));
        k3.add(new IntOption(101));

        k1.add(new IntOption(102));
        k2.add(new IntOption(102));

        assertThat(k1.equals(k2), is(true));
        assertThat(k1.equals(k3), is(false));
        assertThat(k1.hashCode(), is(k2.hashCode()));
    }
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.