// Path: src/main/java/org/inventivetalent/nbt/stream/NBTInputStream.java
// public class NBTInputStream implements AutoCloseable {
// 
// 	public static final Charset UTF_8 = Charset.forName("UTF-8");
// 
// 	private final DataInputStream in;
// 
// 	public NBTInputStream(InputStream inputStream, boolean gzip) throws IOException {
// 		if (gzip) {
// 			this.in = new DataInputStream(new GZIPInputStream(inputStream));
// 		} else {
// 			this.in = new DataInputStream(inputStream);
// 		}
// 	}
// 
// 	public NBTInputStream(InputStream inputStream) throws IOException {
// 		this.in = new DataInputStream(inputStream);
// 	}
// 
// 	public NBTInputStream(DataInputStream dataInputStream) {
// 		this.in = dataInputStream;
// 	}
// 
// 	public static NBTInputStream optionalGzip(InputStream inputStream) throws IOException {
// 		try {
// 			return new NBTInputStream(new DataInputStream(new GZIPInputStream(inputStream)));
// 		} catch (ZipException e) {
// 			return new NBTInputStream(new DataInputStream(inputStream));
// 		}
// 	}
// 
// 	public NBTTag readNBTTag() throws IOException {
// 		return readNBTTag(0);
// 	}
// 
// 	public NBTTag readNBTTag(int depth) throws IOException {
// 		int tagType = in.readByte() & 0xFF;
// 		String tagName = "";
// 		if (tagType != TAG_END) {
// 			int length = in.readShort() & 0xFFFF;
// 			byte[] nameBytes = new byte[length];
// 			in.readFully(nameBytes);
// 			tagName = new String(nameBytes, UTF_8);
// 		}
// 
// 		return readTagContent(tagType, tagName, depth);
// 	}
// 
// 	public NBTTag readTagContent(int tagType, String tagName, int depth) throws IOException {
// 		try {
// 			NBTTag nbtTag = NBTTag.forType(tagType).getConstructor(String.class).newInstance(tagName);
// 			nbtTag.read(this, in, depth);
// 			return nbtTag;
// 		} catch (ReflectiveOperationException e) {
// 			throw new IOException("Could not instantiate NBTTag class for type " + tagType + "'" + tagName + "'", e);
// 		}
// 	}
// 
// 	@Override
// 	public void close() throws Exception {
// 		in.close();
// 	}
// }
// 
// Path: src/main/java/org/inventivetalent/nbt/stream/NBTOutputStream.java
// public class NBTOutputStream implements AutoCloseable {
// 
// 	public static final Charset UTF_8 = Charset.forName("UTF-8");
// 
// 	private final DataOutputStream out;
// 
// 	public NBTOutputStream(OutputStream outputStream, boolean gzip) throws IOException {
// 		if (gzip) {
// 			this.out = new DataOutputStream(new GZIPOutputStream(outputStream));
// 		} else {
// 			this.out = new DataOutputStream(outputStream);
// 		}
// 	}
// 
// 	public NBTOutputStream(OutputStream outputStream) throws IOException {
// 		this.out = new DataOutputStream(outputStream);
// 	}
// 
// 	public NBTOutputStream(DataOutputStream dataOutputStream) {
// 		this.out = dataOutputStream;
// 	}
// 
// 	public void writeTag(NBTTag tag) throws IOException {
// 		String name = tag.getName();
// 		byte[] nameBytes = name.getBytes(UTF_8);
// 
// 		out.writeByte(tag.getTypeId());
// 		out.writeShort(nameBytes.length);
// 		out.write(nameBytes);
// 
// 		writeTagContent(tag);
// 	}
// 
// 	public void writeTagContent(NBTTag tag) throws IOException {
// 		tag.write(this, out);
// 	}
// 
// 	@Override
// 	public void close() throws Exception {
// 		out.close();
// 	}
// }


import org.inventivetalent.nbt.*;
import org.inventivetalent.nbt.stream.NBTInputStream;
import org.inventivetalent.nbt.stream.NBTOutputStream;
import org.junit.Test;
import java.io.FileOutputStream;
import java.util.HashMap;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
package org.inventivetalent.nbt.test;




public class StreamTest {

	@Test
	public void uncompressedInputTest() throws Exception {
		try (NBTInputStream in = new NBTInputStream(StreamTest.class.getResourceAsStream("/hello_world.nbt"))) {
			NBTTag nbtTag = in.readNBTTag();
			System.out.println(nbtTag);

			assertEquals(TagID.TAG_COMPOUND, nbtTag.getTypeId());
			assertEquals("hello world", nbtTag.getName());

			CompoundTag compoundTag = (CompoundTag) nbtTag;
			assertEquals(1, compoundTag.getValue().size());
			assertTrue(compoundTag.getValue().containsKey("name"));
			assertEquals(TagID.TAG_STRING, compoundTag.getValue().get("name").getTypeId());
			assertEquals("Bananrama", compoundTag.getValue().get("name").getValue());
		}
	}

	@Test
	public void compressedInputTest() throws Exception {
// Path: src/main/java/org/inventivetalent/nbt/stream/NBTInputStream.java
// public class NBTInputStream implements AutoCloseable {
// 
// 	public static final Charset UTF_8 = Charset.forName("UTF-8");
// 
// 	private final DataInputStream in;
// 
// 	public NBTInputStream(InputStream inputStream, boolean gzip) throws IOException {
// 		if (gzip) {
// 			this.in = new DataInputStream(new GZIPInputStream(inputStream));
// 		} else {
// 			this.in = new DataInputStream(inputStream);
// 		}
// 	}
// 
// 	public NBTInputStream(InputStream inputStream) throws IOException {
// 		this.in = new DataInputStream(inputStream);
// 	}
// 
// 	public NBTInputStream(DataInputStream dataInputStream) {
// 		this.in = dataInputStream;
// 	}
// 
// 	public static NBTInputStream optionalGzip(InputStream inputStream) throws IOException {
// 		try {
// 			return new NBTInputStream(new DataInputStream(new GZIPInputStream(inputStream)));
// 		} catch (ZipException e) {
// 			return new NBTInputStream(new DataInputStream(inputStream));
// 		}
// 	}
// 
// 	public NBTTag readNBTTag() throws IOException {
// 		return readNBTTag(0);
// 	}
// 
// 	public NBTTag readNBTTag(int depth) throws IOException {
// 		int tagType = in.readByte() & 0xFF;
// 		String tagName = "";
// 		if (tagType != TAG_END) {
// 			int length = in.readShort() & 0xFFFF;
// 			byte[] nameBytes = new byte[length];
// 			in.readFully(nameBytes);
// 			tagName = new String(nameBytes, UTF_8);
// 		}
// 
// 		return readTagContent(tagType, tagName, depth);
// 	}
// 
// 	public NBTTag readTagContent(int tagType, String tagName, int depth) throws IOException {
// 		try {
// 			NBTTag nbtTag = NBTTag.forType(tagType).getConstructor(String.class).newInstance(tagName);
// 			nbtTag.read(this, in, depth);
// 			return nbtTag;
// 		} catch (ReflectiveOperationException e) {
// 			throw new IOException("Could not instantiate NBTTag class for type " + tagType + "'" + tagName + "'", e);
// 		}
// 	}
// 
// 	@Override
// 	public void close() throws Exception {
// 		in.close();
// 	}
// }
// 
// Path: src/main/java/org/inventivetalent/nbt/stream/NBTOutputStream.java
// public class NBTOutputStream implements AutoCloseable {
// 
// 	public static final Charset UTF_8 = Charset.forName("UTF-8");
// 
// 	private final DataOutputStream out;
// 
// 	public NBTOutputStream(OutputStream outputStream, boolean gzip) throws IOException {
// 		if (gzip) {
// 			this.out = new DataOutputStream(new GZIPOutputStream(outputStream));
// 		} else {
// 			this.out = new DataOutputStream(outputStream);
// 		}
// 	}
// 
// 	public NBTOutputStream(OutputStream outputStream) throws IOException {
// 		this.out = new DataOutputStream(outputStream);
// 	}
// 
// 	public NBTOutputStream(DataOutputStream dataOutputStream) {
// 		this.out = dataOutputStream;
// 	}
// 
// 	public void writeTag(NBTTag tag) throws IOException {
// 		String name = tag.getName();
// 		byte[] nameBytes = name.getBytes(UTF_8);
// 
// 		out.writeByte(tag.getTypeId());
// 		out.writeShort(nameBytes.length);
// 		out.write(nameBytes);
// 
// 		writeTagContent(tag);
// 	}
// 
// 	public void writeTagContent(NBTTag tag) throws IOException {
// 		tag.write(this, out);
// 	}
// 
// 	@Override
// 	public void close() throws Exception {
// 		out.close();
// 	}
// }


// Path: src/test/java/org/inventivetalent/nbt/test/StreamTest.java
import org.inventivetalent.nbt.*;
import org.inventivetalent.nbt.stream.NBTInputStream;
import org.inventivetalent.nbt.stream.NBTOutputStream;
import org.junit.Test;
import java.io.FileOutputStream;
import java.util.HashMap;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;

package org.inventivetalent.nbt.test;




public class StreamTest {

	@Test
	public void uncompressedInputTest() throws Exception {
		try (NBTInputStream in = new NBTInputStream(StreamTest.class.getResourceAsStream("/hello_world.nbt"))) {
			NBTTag nbtTag = in.readNBTTag();
			System.out.println(nbtTag);

			assertEquals(TagID.TAG_COMPOUND, nbtTag.getTypeId());
			assertEquals("hello world", nbtTag.getName());

			CompoundTag compoundTag = (CompoundTag) nbtTag;
			assertEquals(1, compoundTag.getValue().size());
			assertTrue(compoundTag.getValue().containsKey("name"));
			assertEquals(TagID.TAG_STRING, compoundTag.getValue().get("name").getTypeId());
			assertEquals("Bananrama", compoundTag.getValue().get("name").getValue());
		}
	}

	@Test
	public void compressedInputTest() throws Exception {
		try (NBTInputStream in = new NBTInputStream(StreamTest.class.getResourceAsStream("/bigtest.nbt"), true)) {