001/**
002 * Copyright (c) 2008-2014 Ardor Labs, Inc.
003 *
004 * This file is part of Ardor3D.
005 *
006 * Ardor3D is free software: you can redistribute it and/or modify it
007 * under the terms of its license which may be found in the accompanying
008 * LICENSE file or at <http://www.ardor3d.com/LICENSE>.
009 */
010
011package com.ardor3d.util;
012
013import static org.junit.Assert.assertTrue;
014
015import java.io.ByteArrayInputStream;
016
017import org.junit.Test;
018
019/**
020 * Some tests for our random access little endian data input
021 */
022public class TestLittleEndianRandomAccessDataInput {
023
024    @Test
025    public void testReadUint() throws Exception {
026        // test reading of uint vs int.
027        final byte[] data = new byte[4];
028        data[0] = (byte) 0xff;
029        data[1] = (byte) 0xff;
030        data[2] = (byte) 0xff;
031        data[3] = (byte) 0xff;
032
033        final ByteArrayInputStream bais = new ByteArrayInputStream(data);
034        final LittleEndianRandomAccessDataInput littleEndien = new LittleEndianRandomAccessDataInput(bais);
035
036        final long val = littleEndien.readUnsignedInt();
037        assertTrue(val == 4294967295L);
038
039        littleEndien.seek(0);
040        final int val2 = littleEndien.readInt();
041        assertTrue(val2 == -1);
042    }
043}