From f1e413e914b9f03607194757848bab1ed4f401a3 Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Thu, 15 Nov 2012 17:41:14 +0000 Subject: Accidentally included a dll, oops. Also, gats null, and gats float work correctly now and are tested against the python implementation. --- cs-dotnet/src/tests/floats.cs | 39 +++++++++++++++++++++++++++++++++++++++ cs-dotnet/src/tests/ints.cs | 3 +++ 2 files changed, 42 insertions(+) create mode 100644 cs-dotnet/src/tests/floats.cs (limited to 'cs-dotnet/src/tests') diff --git a/cs-dotnet/src/tests/floats.cs b/cs-dotnet/src/tests/floats.cs new file mode 100644 index 0000000..b64402c --- /dev/null +++ b/cs-dotnet/src/tests/floats.cs @@ -0,0 +1,39 @@ +using System; +using System.IO; +using Com.Xagasoft.Gats; + +public class Test +{ + public static void Write( double d, Stream s ) + { + GatsFloat gf = new GatsFloat( d ); + gf.Write( s ); + Console.WriteLine("Wrote: " + d ); + } + + 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(); + Write( Math.PI, ms ); + ms.Seek( 0, SeekOrigin.Begin ); + Read( ms ); + + try + { + FileStream fs = new FileStream("float.gats", FileMode.Open, + FileAccess.Read ); + Read( fs ); + } + catch( Exception e ) + { + Console.WriteLine("Can't test files: " + e.Message ); + } + } +} diff --git a/cs-dotnet/src/tests/ints.cs b/cs-dotnet/src/tests/ints.cs index 7099995..766b667 100644 --- a/cs-dotnet/src/tests/ints.cs +++ b/cs-dotnet/src/tests/ints.cs @@ -1,4 +1,5 @@ using System; +using System.Globalization; using System.IO; using Com.Xagasoft.Gats; @@ -11,5 +12,7 @@ class Ints GatsObject obj = GatsObject.Read( file ); Console.WriteLine("Read type: " + obj.GetType() ); Console.WriteLine("Read int: " + ((GatsInteger)obj).Value ); + + Console.WriteLine("Float? " + double.Parse("0x1.62e42fefa39efp+2") ); } } -- cgit v1.2.3