package Test;

import CTL.*;
import CTL.Streams.*;
import CTL.Types.*;
import ReflWrap.*;

import java.io.*;
import junit.framework.*;

/** Test case for the Tree data structure */
public class TTree extends TestCase
{
	public void testMe ()
	{
		try
		{
			Env.newLogger("test");

			Tree moo = new Tree("foo");
			moo.root().append("bar0");
			moo.root().append("bar1");
			moo.sibl("bar0").append("moo0");
			moo.sibl("bar0").append("moo1");
			moo.sibl("bar1").append("moo2");

			PipedOutputStream pout = new PipedOutputStream();
			PipedInputDream pin = new PipedInputDream(pout);
			OOStream out = new OOStream(pout);
			OIStream in = new OIStream(pin);

			out.serialWrite(moo);
			out.writeInt(1337);
			out.flush();
			Tree moo2 = (Tree)in.serialRead(new TypeTree("CTL.Tree<CTL.Sibling<java.lang.String>>"));
			int foo = in.readInt();

			/*System.out.println(moo);
			System.out.println(moo2);
			System.out.println(foo+ " == 1337");*/

			assertTrue(moo.equals(moo2));
			assertTrue(foo==1337);
		}
		catch (Exception e)
		{
			RUtil.except(e);
		}
	}

	public static void main (String[] args)
	{
		TTree moo = new TTree();
		moo.testMe();
	}
}
