예제 #1
0
        private void AssertReaderWriterPrescision(FileInfo file, double[] floats)
        {
            void assertReader(IIonReader reader)
            {
                foreach (var f in floats)
                {
                    Assert.AreEqual(IonType.Float, reader.MoveNext());
                    ReaderTestCommon.AssertFloatEqual(f, reader.DoubleValue());
                }

                Assert.AreEqual(IonType.None, reader.MoveNext());
            }

            void writerFunc(IIonWriter writer)
            {
                foreach (var f in floats)
                {
                    writer.WriteFloat(f);
                }

                writer.Finish();
            }

            var r = ReaderFromFile(file, InputStyle.FileStream);

            assertReader(r);

            AssertReaderWriter(assertReader, writerFunc);
        }
예제 #2
0
        public void FloatWithTerminatingEof()
        {
            var file = DirStructure.IonTestFile("good/floatWithTerminatingEof.ion");
            var r    = ReaderFromFile(file, InputStyle.FileStream);

            Assert.AreEqual(IonType.Float, r.MoveNext());
            ReaderTestCommon.AssertFloatEqual(12.3, r.DoubleValue());

            Assert.AreEqual(IonType.None, r.MoveNext());
        }
예제 #3
0
        public void FloatDblMin()
        {
            var file   = DirStructure.IonTestFile("good/floatDblMin.ion");
            var floats = new[]
            {
                2.2250738585072012e-308,
                0.00022250738585072012e-304,
                2.225073858507201200000e-308,
                2.2250738585072012e-00308,
                2.2250738585072012997800001e-308
            };

            void assertReader(IIonReader reader)
            {
                foreach (var f in floats)
                {
                    Assert.AreEqual(IonType.Float, reader.MoveNext());
                    ReaderTestCommon.AssertFloatEqual(f, reader.DoubleValue());
                }

                Assert.AreEqual(IonType.None, reader.MoveNext());
            }

            void writerFunc(IIonWriter writer)
            {
                foreach (var f in floats)
                {
                    writer.WriteFloat(f);
                }

                writer.Finish();
            }

            var r = ReaderFromFile(file, InputStyle.FileStream);

            assertReader(r);

            AssertReaderWriter(assertReader, writerFunc);
        }