Add asunit tests for generated streamables

git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@6198 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Charlie Groves
2010-10-15 00:42:12 +00:00
parent 9e5d4b95fa
commit 377fafae1e
7 changed files with 465 additions and 0 deletions
@@ -0,0 +1,59 @@
//
// $Id$
//
// Narya library - tools for developing networked games
// Copyright (C) 2002-2010 Three Rings Design, Inc., All Rights Reserved
// http://www.threerings.net/code/narya/
//
// This library is free software; you can redistribute it and/or modify it
// under the terms of the GNU Lesser General Public License as published
// by the Free Software Foundation; either version 2.1 of the License, or
// (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
package com.threerings.io {
import com.threerings.util.StringUtil;
import com.threerings.util.Name;
import flash.utils.ByteArray;
import com.threerings.io.ObjectOutputStream;
import com.threerings.io.ObjectInputStream;
import com.threerings.presents.peer.data.ClientInfo;
import asunit.framework.TestCase;
public class StreamableTest extends TestCase
{
public function testStreamingToSelf ():void
{
var sub:ASStreamableSubset = ASStreamableSubset.createWithJavaDefaults();
var written:ByteArray = new ByteArray();
var output:ObjectOutputStream = new ObjectOutputStream(written);
output.writeObject(sub);
written.position = 0;
var input:ObjectInputStream = new ObjectInputStream(written);
var read:ASStreamableSubset = input.readObject(ASStreamableSubset);
assertTrue(sub.equals(read));
}
public function testStreamingFromJava () :void
{
var sub:ASStreamableSubset = ASStreamableSubset.createWithJavaDefaults();
var javaData:ByteArray = StringUtil.unhexlate(
"ffff0024636f6d2e746872656572696e67732e696f2e415353747265616d61626c65537562736574" +
"01000200000003000000000000000440a0000040180000000000000007080100036f6e6500010000" +
"000301000101000000030102030100000003000000010000000200000003000000");
var input:ObjectInputStream = new ObjectInputStream(javaData);
var read :ASStreamableSubset = input.readObject(ASStreamableSubset);
assertTrue(sub.equals(read));
}
}
}