コード例 #1
0
ファイル: CFileTest.cs プロジェクト: rahulyhg/SwissEphNet
        public void TestReadLineEncoded()
        {
            using (var cfile = new CFile(BuildStream("èaà\nüî"))) {
#if !NET_STANDARD
                Assert.Equal("èaà", cfile.ReadLine());
                Assert.Equal("üî", cfile.ReadLine());
#else
                Assert.Equal("èaà", cfile.ReadLine());
                Assert.Equal("üî", cfile.ReadLine());
#endif
                Assert.Equal(null, cfile.ReadLine());
                Assert.Equal(true, cfile.EOF);
            }

#if !NET_STANDARD
            using (var cfile = new CFile(BuildStream("èaà\nüî", Encoding.GetEncoding("windows-1252")))) {
                Assert.Equal("èaà", cfile.ReadLine());
                Assert.Equal("üî", cfile.ReadLine());
                Assert.Equal(null, cfile.ReadLine());
                Assert.Equal(true, cfile.EOF);
            }
#endif

            using (var cfile = new CFile(BuildStream("èaà\nüî"), Encoding.UTF8)) {
                Assert.Equal("èaà", cfile.ReadLine());
                Assert.Equal("üî", cfile.ReadLine());
                Assert.Equal(null, cfile.ReadLine());
                Assert.Equal(true, cfile.EOF);
            }

#if !NET_STANDARD
            using (var cfile = new CFile(BuildStream("èaà\nüî", Encoding.GetEncoding("windows-1252")), Encoding.GetEncoding("windows-1252"))) {
                Assert.Equal("èaà", cfile.ReadLine());
                Assert.Equal("üî", cfile.ReadLine());
                Assert.Equal(null, cfile.ReadLine());
                Assert.Equal(true, cfile.EOF);
            }

            using (var cfile = new CFile(BuildStream("èaà\nüî", Encoding.UTF8), Encoding.GetEncoding("windows-1252"))) {
                Assert.Equal("èaà", cfile.ReadLine());
                Assert.Equal("üî", cfile.ReadLine());
                Assert.Equal(null, cfile.ReadLine());
                Assert.Equal(true, cfile.EOF);
            }
#endif
        }
コード例 #2
0
        public void TestReadLineEncoded()
        {
            using (var cfile = new CFile(BuildStream("èaà\nüî"))) {
                Assert.AreEqual("èaà", cfile.ReadLine());
                Assert.AreEqual("üî", cfile.ReadLine());
                Assert.AreEqual(null, cfile.ReadLine());
                Assert.AreEqual(true, cfile.EOF);
            }

            using (var cfile = new CFile(BuildStream("èaà\nüî", Encoding.GetEncoding("windows-1252")))) {
                Assert.AreEqual("èaà", cfile.ReadLine());
                Assert.AreEqual("üî", cfile.ReadLine());
                Assert.AreEqual(null, cfile.ReadLine());
                Assert.AreEqual(true, cfile.EOF);
            }

            using (var cfile = new CFile(BuildStream("èaà\nüî"), Encoding.UTF8)) {
                Assert.AreEqual("èaà", cfile.ReadLine());
                Assert.AreEqual("üî", cfile.ReadLine());
                Assert.AreEqual(null, cfile.ReadLine());
                Assert.AreEqual(true, cfile.EOF);
            }

            using (var cfile = new CFile(BuildStream("èaà\nüî", Encoding.GetEncoding("windows-1252")), Encoding.GetEncoding("windows-1252"))) {
                Assert.AreEqual("èaà", cfile.ReadLine());
                Assert.AreEqual("üî", cfile.ReadLine());
                Assert.AreEqual(null, cfile.ReadLine());
                Assert.AreEqual(true, cfile.EOF);
            }

            using (var cfile = new CFile(BuildStream("èaà\nüî", Encoding.UTF8), Encoding.GetEncoding("windows-1252"))) {
                Assert.AreEqual("èaà", cfile.ReadLine());
                Assert.AreEqual("üî", cfile.ReadLine());
                Assert.AreEqual(null, cfile.ReadLine());
                Assert.AreEqual(true, cfile.EOF);
            }
        }
コード例 #3
0
ファイル: CFileTest.cs プロジェクト: rahulyhg/SwissEphNet
        public void TestReadLine()
        {
            using (var cfile = new CFile(BuildStream(""))) {
                Assert.Equal(null, cfile.ReadLine());
                Assert.Equal(true, cfile.EOF);
            }

            using (var cfile = new CFile(BuildStream(" "))) {
                Assert.Equal(" ", cfile.ReadLine());
                Assert.Equal(null, cfile.ReadLine());
                Assert.Equal(true, cfile.EOF);
            }

            using (var cfile = new CFile(BuildStream("1\n"))) {
                Assert.Equal("1", cfile.ReadLine());
                Assert.Equal(null, cfile.ReadLine());
                Assert.Equal(true, cfile.EOF);
            }

            using (var cfile = new CFile(BuildStream("1\n2"))) {
                Assert.Equal("1", cfile.ReadLine());
                Assert.Equal("2", cfile.ReadLine());
                Assert.Equal(null, cfile.ReadLine());
                Assert.Equal(true, cfile.EOF);
            }

            using (var cfile = new CFile(BuildStream("1\n2\r"))) {
                Assert.Equal("1", cfile.ReadLine());
                Assert.Equal("2", cfile.ReadLine());
                Assert.Equal(null, cfile.ReadLine());
                Assert.Equal(true, cfile.EOF);
            }

            using (var cfile = new CFile(BuildStream("1\n2\r3"))) {
                Assert.Equal("1", cfile.ReadLine());
                Assert.Equal("2", cfile.ReadLine());
                Assert.Equal("3", cfile.ReadLine());
                Assert.Equal(null, cfile.ReadLine());
                Assert.Equal(true, cfile.EOF);
            }

            using (var cfile = new CFile(BuildStream("1\n2\r3\n\r"))) {
                Assert.Equal("1", cfile.ReadLine());
                Assert.Equal("2", cfile.ReadLine());
                Assert.Equal("3", cfile.ReadLine());
                Assert.Equal("", cfile.ReadLine());
                Assert.Equal(null, cfile.ReadLine());
                Assert.Equal(true, cfile.EOF);
            }

            using (var cfile = new CFile(BuildStream("1\n2\r3\n\r4"))) {
                Assert.Equal("1", cfile.ReadLine());
                Assert.Equal("2", cfile.ReadLine());
                Assert.Equal("3", cfile.ReadLine());
                Assert.Equal("", cfile.ReadLine());
                Assert.Equal("4", cfile.ReadLine());
                Assert.Equal(null, cfile.ReadLine());
                Assert.Equal(true, cfile.EOF);
            }

            using (var cfile = new CFile(BuildStream("1\n2\r3\n\r4\r\n"))) {
                Assert.Equal("1", cfile.ReadLine());
                Assert.Equal("2", cfile.ReadLine());
                Assert.Equal("3", cfile.ReadLine());
                Assert.Equal("", cfile.ReadLine());
                Assert.Equal("4", cfile.ReadLine());
                Assert.Equal(null, cfile.ReadLine());
                Assert.Equal(true, cfile.EOF);
            }

            using (var cfile = new CFile(BuildStream("1\n2\r3\n\r4\r\n5"))) {
                Assert.Equal("1", cfile.ReadLine());
                Assert.Equal("2", cfile.ReadLine());
                Assert.Equal("3", cfile.ReadLine());
                Assert.Equal("", cfile.ReadLine());
                Assert.Equal("4", cfile.ReadLine());
                Assert.Equal("5", cfile.ReadLine());
                Assert.Equal(null, cfile.ReadLine());
                Assert.Equal(true, cfile.EOF);
            }

            using (var cfile = new CFile(BuildStream("1\n\n\n\r\r\r\n5"))) {
                Assert.Equal("1", cfile.ReadLine());
                Assert.Equal("", cfile.ReadLine());
                Assert.Equal("", cfile.ReadLine());
                Assert.Equal("", cfile.ReadLine());
                Assert.Equal("", cfile.ReadLine());
                Assert.Equal("", cfile.ReadLine());
                Assert.Equal("5", cfile.ReadLine());
                Assert.Equal(null, cfile.ReadLine());
                Assert.Equal(true, cfile.EOF);
            }
        }
コード例 #4
0
ファイル: CFileTest.cs プロジェクト: thenuts/SwissEphNet
        public void TestReadLineEncoded()
        {
            using (var cfile = new CFile(BuildStream("èaà\nüî"))) {
                Assert.AreEqual("èaà", cfile.ReadLine());
                Assert.AreEqual("üî", cfile.ReadLine());
                Assert.AreEqual(null, cfile.ReadLine());
                Assert.AreEqual(true, cfile.EOF);
            }

            using (var cfile = new CFile(BuildStream("èaà\nüî", Encoding.GetEncoding("windows-1252")))) {
                Assert.AreEqual("èaà", cfile.ReadLine());
                Assert.AreEqual("üî", cfile.ReadLine());
                Assert.AreEqual(null, cfile.ReadLine());
                Assert.AreEqual(true, cfile.EOF);
            }

            using (var cfile = new CFile(BuildStream("èaà\nüî"), Encoding.UTF8)) {
                Assert.AreEqual("èaà", cfile.ReadLine());
                Assert.AreEqual("üî", cfile.ReadLine());
                Assert.AreEqual(null, cfile.ReadLine());
                Assert.AreEqual(true, cfile.EOF);
            }

            using (var cfile = new CFile(BuildStream("èaà\nüî", Encoding.GetEncoding("windows-1252")), Encoding.GetEncoding("windows-1252"))) {
                Assert.AreEqual("èaà", cfile.ReadLine());
                Assert.AreEqual("üî", cfile.ReadLine());
                Assert.AreEqual(null, cfile.ReadLine());
                Assert.AreEqual(true, cfile.EOF);
            }

            using (var cfile = new CFile(BuildStream("èaà\nüî", Encoding.UTF8), Encoding.GetEncoding("windows-1252"))) {
                Assert.AreEqual("èaà", cfile.ReadLine());
                Assert.AreEqual("üî", cfile.ReadLine());
                Assert.AreEqual(null, cfile.ReadLine());
                Assert.AreEqual(true, cfile.EOF);
            }
        }
コード例 #5
0
ファイル: CFileTest.cs プロジェクト: thenuts/SwissEphNet
        public void TestReadLine()
        {
            using (var cfile = new CFile(BuildStream(""))) {
                Assert.AreEqual(null, cfile.ReadLine());
                Assert.AreEqual(true, cfile.EOF);
            }

            using (var cfile = new CFile(BuildStream(" "))) {
                Assert.AreEqual(" ", cfile.ReadLine());
                Assert.AreEqual(null, cfile.ReadLine());
                Assert.AreEqual(true, cfile.EOF);
            }

            using (var cfile = new CFile(BuildStream("1\n"))) {
                Assert.AreEqual("1", cfile.ReadLine());
                Assert.AreEqual(null, cfile.ReadLine());
                Assert.AreEqual(true, cfile.EOF);
            }

            using (var cfile = new CFile(BuildStream("1\n2"))) {
                Assert.AreEqual("1", cfile.ReadLine());
                Assert.AreEqual("2", cfile.ReadLine());
                Assert.AreEqual(null, cfile.ReadLine());
                Assert.AreEqual(true, cfile.EOF);
            }

            using (var cfile = new CFile(BuildStream("1\n2\r"))) {
                Assert.AreEqual("1", cfile.ReadLine());
                Assert.AreEqual("2", cfile.ReadLine());
                Assert.AreEqual(null, cfile.ReadLine());
                Assert.AreEqual(true, cfile.EOF);
            }

            using (var cfile = new CFile(BuildStream("1\n2\r3"))) {
                Assert.AreEqual("1", cfile.ReadLine());
                Assert.AreEqual("2", cfile.ReadLine());
                Assert.AreEqual("3", cfile.ReadLine());
                Assert.AreEqual(null, cfile.ReadLine());
                Assert.AreEqual(true, cfile.EOF);
            }

            using (var cfile = new CFile(BuildStream("1\n2\r3\n\r"))) {
                Assert.AreEqual("1", cfile.ReadLine());
                Assert.AreEqual("2", cfile.ReadLine());
                Assert.AreEqual("3", cfile.ReadLine());
                Assert.AreEqual("", cfile.ReadLine());
                Assert.AreEqual(null, cfile.ReadLine());
                Assert.AreEqual(true, cfile.EOF);
            }

            using (var cfile = new CFile(BuildStream("1\n2\r3\n\r4"))) {
                Assert.AreEqual("1", cfile.ReadLine());
                Assert.AreEqual("2", cfile.ReadLine());
                Assert.AreEqual("3", cfile.ReadLine());
                Assert.AreEqual("", cfile.ReadLine());
                Assert.AreEqual("4", cfile.ReadLine());
                Assert.AreEqual(null, cfile.ReadLine());
                Assert.AreEqual(true, cfile.EOF);
            }

            using (var cfile = new CFile(BuildStream("1\n2\r3\n\r4\r\n"))) {
                Assert.AreEqual("1", cfile.ReadLine());
                Assert.AreEqual("2", cfile.ReadLine());
                Assert.AreEqual("3", cfile.ReadLine());
                Assert.AreEqual("", cfile.ReadLine());
                Assert.AreEqual("4", cfile.ReadLine());
                Assert.AreEqual(null, cfile.ReadLine());
                Assert.AreEqual(true, cfile.EOF);
            }

            using (var cfile = new CFile(BuildStream("1\n2\r3\n\r4\r\n5"))) {
                Assert.AreEqual("1", cfile.ReadLine());
                Assert.AreEqual("2", cfile.ReadLine());
                Assert.AreEqual("3", cfile.ReadLine());
                Assert.AreEqual("", cfile.ReadLine());
                Assert.AreEqual("4", cfile.ReadLine());
                Assert.AreEqual("5", cfile.ReadLine());
                Assert.AreEqual(null, cfile.ReadLine());
                Assert.AreEqual(true, cfile.EOF);
            }

            using (var cfile = new CFile(BuildStream("1\n\n\n\r\r\r\n5"))) {
                Assert.AreEqual("1", cfile.ReadLine());
                Assert.AreEqual("", cfile.ReadLine());
                Assert.AreEqual("", cfile.ReadLine());
                Assert.AreEqual("", cfile.ReadLine());
                Assert.AreEqual("", cfile.ReadLine());
                Assert.AreEqual("", cfile.ReadLine());
                Assert.AreEqual("5", cfile.ReadLine());
                Assert.AreEqual(null, cfile.ReadLine());
                Assert.AreEqual(true, cfile.EOF);
            }
        }