⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 littleendianstreamtest.java

📁 java 调用windows的api
💻 JAVA
字号:
/*
 * LittleEndianStreamTest.java -
 *
 * This file is part of the Jawin Project: http://jawinproject.sourceforge.net/
 * 
 * Please consult the LICENSE file in the project root directory,
 * or at the project site before using this software.
 */

/* $Id: LittleEndianStreamTest.java,v 1.1 2004/06/14 19:24:56 arosii_moa Exp $ */

package org.jawin.io;

import java.io.ByteArrayInputStream;

import junit.framework.TestCase;

/**
 * Testcases for different boundary values on the LittleEndianStreams.
 *
 * @version     $Revision: 1.1 $
 * @author      Morten Andersen, arosii_moa (at) users.sourceforge.net
 */
public class LittleEndianStreamTest extends TestCase {

	public void testUnsignedSigned() throws Exception {
		NakedByteStream nbs = new NakedByteStream();
		LittleEndianOutputStream leos = new LittleEndianOutputStream(nbs);
		leos.writeByte(255);
		leos.writeByte(255);
		leos.writeShort(65535);
		leos.writeShort(65535);
		
		LittleEndianInputStream leis = new LittleEndianInputStream(new ByteArrayInputStream(nbs.getInternalBuffer(), 0, nbs.size()));
		assertEquals(255, leis.readUnsignedByte());
		assertEquals((byte)255, leis.readByte()); // signed (byte)255 = -1
		assertEquals(65535, leis.readUnsignedShort());
		assertEquals((short)65535, leis.readShort()); // signed (short)65535 = -1
		
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -