aboutsummaryrefslogtreecommitdiff
path: root/cs-dotnet/src/tests
diff options
context:
space:
mode:
Diffstat (limited to 'cs-dotnet/src/tests')
-rw-r--r--cs-dotnet/src/tests/dictionary.cs48
-rw-r--r--cs-dotnet/src/tests/lists.cs5
2 files changed, 50 insertions, 3 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}
diff --git a/cs-dotnet/src/tests/lists.cs b/cs-dotnet/src/tests/lists.cs
index 8d12bf9..09ad931 100644
--- a/cs-dotnet/src/tests/lists.cs
+++ b/cs-dotnet/src/tests/lists.cs
@@ -27,10 +27,10 @@ public class Test
27 Write( l, ms ); 27 Write( l, ms );
28 ms.Seek( 0, SeekOrigin.Begin ); 28 ms.Seek( 0, SeekOrigin.Begin );
29 Read( ms ); 29 Read( ms );
30/* 30
31 try 31 try
32 { 32 {
33 FileStream fs = new FileStream("float.gats", FileMode.Open, 33 FileStream fs = new FileStream("list.gats", FileMode.Open,
34 FileAccess.Read ); 34 FileAccess.Read );
35 Read( fs ); 35 Read( fs );
36 } 36 }
@@ -38,6 +38,5 @@ public class Test
38 { 38 {
39 Console.WriteLine("Can't test files: " + e.Message ); 39 Console.WriteLine("Can't test files: " + e.Message );
40 } 40 }
41 */
42 } 41 }
43} 42}