aboutsummaryrefslogtreecommitdiff
path: root/cs-dotnet/src/tests/dictionary.cs
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2012-11-15 20:59:11 +0000
committerMike Buland <eichlan@xagasoft.com>2012-11-15 20:59:11 +0000
commit862c485d46f3f8e992a9ca9fea40fb33f0b43959 (patch)
tree118e251b2867ed41e0825a573838160357b0eed5 /cs-dotnet/src/tests/dictionary.cs
parentb9b5a5fc16e21387b3350260d2139b293bbcd2b0 (diff)
downloadlibgats-862c485d46f3f8e992a9ca9fea40fb33f0b43959.tar.gz
libgats-862c485d46f3f8e992a9ca9fea40fb33f0b43959.tar.bz2
libgats-862c485d46f3f8e992a9ca9fea40fb33f0b43959.tar.xz
libgats-862c485d46f3f8e992a9ca9fea40fb33f0b43959.zip
Dictionaries are implemented now. Everything tests out against python.
The next step is the packet stream interface.
Diffstat (limited to 'cs-dotnet/src/tests/dictionary.cs')
-rw-r--r--cs-dotnet/src/tests/dictionary.cs48
1 files changed, 48 insertions, 0 deletions
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 @@
1using System;
2using System.IO;
3using Com.Xagasoft.Gats;
4
5public class Test
6{
7 public static void Write( GatsObject o, Stream s )
8 {
9 o.Write( s );
10 Console.WriteLine("Wrote: " + o );
11 }
12
13 public static void Read( Stream s )
14 {
15 GatsObject o = GatsObject.Read( s );
16 Console.WriteLine("Read type: " + o.GetType() );
17 Console.WriteLine("Read vlaue: " + o );
18 }
19
20 public static void Main()
21 {
22 MemoryStream ms = new MemoryStream();
23 GatsDictionary d = new GatsDictionary();
24 GatsList l = new GatsList();
25 l.Add( new GatsFloat( Math.PI ) );
26 l.Add( new GatsInteger( 1337 ) );
27 l.Add( new GatsString("Hello") );
28 d.Add("list", l );
29 d.Add("int", new GatsInteger( 998877 ) );
30 d.Add("float", new GatsFloat( 87.332 ) );
31 d.Add("string", new GatsString("Yup, a string") );
32 d.Add("bool", new GatsBoolean( false ) );
33 Write( d, ms );
34 ms.Seek( 0, SeekOrigin.Begin );
35 Read( ms );
36
37 try
38 {
39 FileStream fs = new FileStream("dictionary.gats", FileMode.Open,
40 FileAccess.Read );
41 Read( fs );
42 }
43 catch( Exception e )
44 {
45 Console.WriteLine("Can't test files: " + e.Message );
46 }
47 }
48}