diff options
| author | Mike Buland <eichlan@xagasoft.com> | 2012-11-15 20:59:11 +0000 |
|---|---|---|
| committer | Mike Buland <eichlan@xagasoft.com> | 2012-11-15 20:59:11 +0000 |
| commit | 862c485d46f3f8e992a9ca9fea40fb33f0b43959 (patch) | |
| tree | 118e251b2867ed41e0825a573838160357b0eed5 /cs-dotnet/src/tests | |
| parent | b9b5a5fc16e21387b3350260d2139b293bbcd2b0 (diff) | |
| download | libgats-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')
| -rw-r--r-- | cs-dotnet/src/tests/dictionary.cs | 48 | ||||
| -rw-r--r-- | cs-dotnet/src/tests/lists.cs | 5 |
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 @@ | |||
| 1 | using System; | ||
| 2 | using System.IO; | ||
| 3 | using Com.Xagasoft.Gats; | ||
| 4 | |||
| 5 | public 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 | } |
