예제 #1
0
        public void TestReadString()
        {
            String str = null;

            using (var cfile = new CFile(BuildStream("èaà\nüî"))) {
#if !NET_STANDARD
                str = "$$$";
                Assert.Equal(true, cfile.ReadString(ref str, 3));
                Assert.Equal("èa", str);

                str = "$$$";
                Assert.Equal(true, cfile.ReadString(ref str, 3));
                Assert.Equal("à\n", str);

                str = "$$$";
                Assert.Equal(true, cfile.ReadString(ref str, 3));
                Assert.Equal("üÃ", str);

                str = "$$$";
                Assert.Equal(false, cfile.ReadString(ref str, 3));
                Assert.Equal("®", str);
#else
                str = "$$$";
                Assert.Equal(true, cfile.ReadString(ref str, 3));
                Assert.Equal("èaà", str);

                str = "$$$";
                Assert.Equal(true, cfile.ReadString(ref str, 3));
                Assert.Equal("\nüî", str);
#endif

                str = "$$$";
                Assert.Equal(false, cfile.ReadString(ref str, 3));
                Assert.Equal(null, str);

                Assert.Equal(true, cfile.EOF);
            }

#if !NET_STANDARD
            using (var cfile = new CFile(BuildStream("èaà\nüî", Encoding.GetEncoding("windows-1252")))) {
                str = "$$$";
                Assert.Equal(true, cfile.ReadString(ref str, 3));
                Assert.Equal("èaà", str);

                str = "$$$";
                Assert.Equal(true, cfile.ReadString(ref str, 3));
                Assert.Equal("\nüî", str);

                str = "$$$";
                Assert.Equal(false, cfile.ReadString(ref str, 3));
                Assert.Equal(null, str);

                Assert.Equal(true, cfile.EOF);
            }
#endif

            using (var cfile = new CFile(BuildStream("èaà\nüî"), Encoding.UTF8)) {
                str = "$$$";
                Assert.Equal(true, cfile.ReadString(ref str, 3));
                Assert.Equal("èaà", str);

                str = "$$$";
                Assert.Equal(true, cfile.ReadString(ref str, 3));
                Assert.Equal("\nüî", str);

                str = "$$$";
                Assert.Equal(false, cfile.ReadString(ref str, 3));
                Assert.Equal(null, str);

                Assert.Equal(true, cfile.EOF);
            }

#if !NET_STANDARD
            using (var cfile = new CFile(BuildStream("èaà\nüî", Encoding.GetEncoding("windows-1252")), Encoding.GetEncoding("windows-1252"))) {
                str = "$$$";
                Assert.Equal(true, cfile.ReadString(ref str, 3));
                Assert.Equal("èaà", str);

                str = "$$$";
                Assert.Equal(true, cfile.ReadString(ref str, 3));
                Assert.Equal("\nüî", str);

                str = "$$$";
                Assert.Equal(false, cfile.ReadString(ref str, 3));
                Assert.Equal(null, str);

                Assert.Equal(true, cfile.EOF);
            }

            using (var cfile = new CFile(BuildStream("èaà\nüî", Encoding.UTF8), Encoding.GetEncoding("windows-1252"))) {
                str = "$$$";
                Assert.Equal(true, cfile.ReadString(ref str, 3));
                Assert.Equal("èa", str);

                str = "$$$";
                Assert.Equal(true, cfile.ReadString(ref str, 3));
                Assert.Equal("à\n", str);

                str = "$$$";
                Assert.Equal(true, cfile.ReadString(ref str, 3));
                Assert.Equal("üÃ", str);

                str = "$$$";
                Assert.Equal(false, cfile.ReadString(ref str, 3));
                Assert.Equal("®", str);

                str = "$$$";
                Assert.Equal(false, cfile.ReadString(ref str, 3));
                Assert.Equal(null, str);

                Assert.Equal(true, cfile.EOF);
            }
#endif
        }
예제 #2
0
        public void TestReadString()
        {
            String str = null;
            using (var cfile = new CFile(BuildStream("èaà\nüî"))) {
                str = "$$$";
                Assert.AreEqual(true, cfile.ReadString(ref str, 3));
                Assert.AreEqual("èa", str);

                str = "$$$";
                Assert.AreEqual(true, cfile.ReadString(ref str, 3));
                Assert.AreEqual("à\n", str);

                str = "$$$";
                Assert.AreEqual(true, cfile.ReadString(ref str, 3));
                Assert.AreEqual("üÃ", str);

                str = "$$$";
                Assert.AreEqual(false, cfile.ReadString(ref str, 3));
                Assert.AreEqual("®", str);

                str = "$$$";
                Assert.AreEqual(false, cfile.ReadString(ref str, 3));
                Assert.AreEqual(null, str);

                Assert.AreEqual(true, cfile.EOF);
            }

            using (var cfile = new CFile(BuildStream("èaà\nüî", Encoding.GetEncoding("windows-1252")))) {
                str = "$$$";
                Assert.AreEqual(true, cfile.ReadString(ref str, 3));
                Assert.AreEqual("èaà", str);

                str = "$$$";
                Assert.AreEqual(true, cfile.ReadString(ref str, 3));
                Assert.AreEqual("\nüî", str);

                str = "$$$";
                Assert.AreEqual(false, cfile.ReadString(ref str, 3));
                Assert.AreEqual(null, str);

                Assert.AreEqual(true, cfile.EOF);
            }

            using (var cfile = new CFile(BuildStream("èaà\nüî"), Encoding.UTF8)) {
                str = "$$$";
                Assert.AreEqual(true, cfile.ReadString(ref str, 3));
                Assert.AreEqual("èaà", str);

                str = "$$$";
                Assert.AreEqual(true, cfile.ReadString(ref str, 3));
                Assert.AreEqual("\nüî", str);

                str = "$$$";
                Assert.AreEqual(false, cfile.ReadString(ref str, 3));
                Assert.AreEqual(null, str);

                Assert.AreEqual(true, cfile.EOF);
            }

            using (var cfile = new CFile(BuildStream("èaà\nüî", Encoding.GetEncoding("windows-1252")), Encoding.GetEncoding("windows-1252"))) {
                str = "$$$";
                Assert.AreEqual(true, cfile.ReadString(ref str, 3));
                Assert.AreEqual("èaà", str);

                str = "$$$";
                Assert.AreEqual(true, cfile.ReadString(ref str, 3));
                Assert.AreEqual("\nüî", str);

                str = "$$$";
                Assert.AreEqual(false, cfile.ReadString(ref str, 3));
                Assert.AreEqual(null, str);

                Assert.AreEqual(true, cfile.EOF);
            }

            using (var cfile = new CFile(BuildStream("èaà\nüî", Encoding.UTF8), Encoding.GetEncoding("windows-1252"))) {
                str = "$$$";
                Assert.AreEqual(true, cfile.ReadString(ref str, 3));
                Assert.AreEqual("èa", str);

                str = "$$$";
                Assert.AreEqual(true, cfile.ReadString(ref str, 3));
                Assert.AreEqual("à\n", str);

                str = "$$$";
                Assert.AreEqual(true, cfile.ReadString(ref str, 3));
                Assert.AreEqual("üÃ", str);

                str = "$$$";
                Assert.AreEqual(false, cfile.ReadString(ref str, 3));
                Assert.AreEqual("®", str);

                str = "$$$";
                Assert.AreEqual(false, cfile.ReadString(ref str, 3));
                Assert.AreEqual(null, str);

                Assert.AreEqual(true, cfile.EOF);
            }
        }