aboutsummaryrefslogtreecommitdiff
path: root/cs-dotnet/src/tests/dictionary.cs
diff options
context:
space:
mode:
Diffstat (limited to '')
-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}