From 862c485d46f3f8e992a9ca9fea40fb33f0b43959 Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Thu, 15 Nov 2012 20:59:11 +0000 Subject: Dictionaries are implemented now. Everything tests out against python. The next step is the packet stream interface. --- cs-dotnet/src/tests/dictionary.cs | 48 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 cs-dotnet/src/tests/dictionary.cs (limited to 'cs-dotnet/src/tests/dictionary.cs') diff --git a/cs-dotnet/src/tests/dictionary.cs b/cs-dotnet/src/tests/dictionary.cs new file mode 100644 index 0000000..a22acad --- /dev/null +++ b/cs-dotnet/src/tests/dictionary.cs @@ -0,0 +1,48 @@ +using System; +using System.IO; +using Com.Xagasoft.Gats; + +public class Test +{ + public static void Write( GatsObject o, Stream s ) + { + o.Write( s ); + Console.WriteLine("Wrote: " + o ); + } + + public static void Read( Stream s ) + { + GatsObject o = GatsObject.Read( s ); + Console.WriteLine("Read type: " + o.GetType() ); + Console.WriteLine("Read vlaue: " + o ); + } + + public static void Main() + { + MemoryStream ms = new MemoryStream(); + GatsDictionary d = new GatsDictionary(); + GatsList l = new GatsList(); + l.Add( new GatsFloat( Math.PI ) ); + l.Add( new GatsInteger( 1337 ) ); + l.Add( new GatsString("Hello") ); + d.Add("list", l ); + d.Add("int", new GatsInteger( 998877 ) ); + d.Add("float", new GatsFloat( 87.332 ) ); + d.Add("string", new GatsString("Yup, a string") ); + d.Add("bool", new GatsBoolean( false ) ); + Write( d, ms ); + ms.Seek( 0, SeekOrigin.Begin ); + Read( ms ); + + try + { + FileStream fs = new FileStream("dictionary.gats", FileMode.Open, + FileAccess.Read ); + Read( fs ); + } + catch( Exception e ) + { + Console.WriteLine("Can't test files: " + e.Message ); + } + } +} -- cgit v1.2.3