aboutsummaryrefslogtreecommitdiffstats
path: root/document/src/test/java/com/yahoo/document/datatypes/RawTestCase.java
blob: 1efea2fa075a7ef70bbb0e7da062eb27222d037d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.document.datatypes;

import org.junit.Test;

import java.nio.ByteBuffer;

import static org.junit.Assert.*;

/**
 * @author baldersheim
 */
public class RawTestCase {
    @Test
    public void requireThatAssignWorks() {
        byte [] buf = {0,1,2,3};
        byte [] empty = {};
        ByteBuffer bb = ByteBuffer.wrap(buf);
        Raw a = new Raw();
        a.assign(buf);
        assertEquals(bb, a.getWrappedValue());
        a.assign(empty);
        assertNotEquals(bb, a.getWrappedValue());
        a.assign(bb);
        assertEquals(bb, a.getWrappedValue());
        a.assign(empty);
        assertNotEquals(bb, a.getWrappedValue());
        a.assign(new Raw(bb));
        assertEquals(bb, a.getWrappedValue());
    }

}