Example #1
0
        public void TestReadChars()
        {
            using (var cfile = new CFile(BuildStream("èaà\nüî"))) {
#if !NET_STANDARD
                Assert.Equal(new char[] { 'Ã', '¨', 'a' }, cfile.ReadChars(3));
                Assert.Equal(new char[] { 'Ã', ' ', '\n' }, cfile.ReadChars(3));
                Assert.Equal(new char[] { 'Ã', '¼', 'Ã', }, cfile.ReadChars(3));
                Assert.Equal(new char[] { '®' }, cfile.ReadChars(3));
#else
                Assert.Equal(new char[] { 'è', 'a', 'à' }, cfile.ReadChars(3));
                Assert.Equal(new char[] { '\n', 'ü', 'î' }, cfile.ReadChars(3));
#endif
                Assert.Equal(null, cfile.ReadChars(3));
                Assert.Equal(true, cfile.EOF);
            }

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

            using (var cfile = new CFile(BuildStream("èaà\nüî"), Encoding.UTF8)) {
                Assert.Equal(new char[] { 'è', 'a', 'à' }, cfile.ReadChars(3));
                Assert.Equal(new char[] { '\n', 'ü', 'î' }, cfile.ReadChars(3));
                Assert.Equal(null, cfile.ReadChars(3));
                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(new char[] { 'è', 'a', 'à' }, cfile.ReadChars(3));
                Assert.Equal(new char[] { '\n', 'ü', 'î' }, cfile.ReadChars(3));
                Assert.Equal(null, cfile.ReadChars(3));
                Assert.Equal(true, cfile.EOF);
            }

            using (var cfile = new CFile(BuildStream("èaà\nüî", Encoding.UTF8), Encoding.GetEncoding("windows-1252"))) {
                Assert.Equal(new char[] { 'Ã', '¨', 'a' }, cfile.ReadChars(3));
                Assert.Equal(new char[] { 'Ã', ' ', '\n' }, cfile.ReadChars(3));
                Assert.Equal(new char[] { 'Ã', '¼', 'Ã', }, cfile.ReadChars(3));
                Assert.Equal(new char[] { '®' }, cfile.ReadChars(3));
                Assert.Equal(null, cfile.ReadChars(3));
                Assert.Equal(true, cfile.EOF);
            }
#endif
        }
Example #2
0
        public void TestReadChars()
        {
            using (var cfile = new CFile(BuildStream("èaà\nüî"))) {
                CollectionAssert.AreEqual(new char[] { 'Ã', '¨', 'a' }, cfile.ReadChars(3));
                CollectionAssert.AreEqual(new char[] { 'Ã', ' ', '\n' }, cfile.ReadChars(3));
                CollectionAssert.AreEqual(new char[] { 'Ã', '¼', 'Ã', }, cfile.ReadChars(3));
                CollectionAssert.AreEqual(new char[] { '®' }, cfile.ReadChars(3));
                CollectionAssert.AreEqual(null, cfile.ReadChars(3));
                Assert.AreEqual(true, cfile.EOF);
            }

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

            using (var cfile = new CFile(BuildStream("èaà\nüî"), Encoding.UTF8)) {
                CollectionAssert.AreEqual(new char[] { 'è', 'a', 'à' }, cfile.ReadChars(3));
                CollectionAssert.AreEqual(new char[] { '\n', 'ü', 'î' }, cfile.ReadChars(3));
                CollectionAssert.AreEqual(null, cfile.ReadChars(3));
                Assert.AreEqual(true, cfile.EOF);
            }

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

            using (var cfile = new CFile(BuildStream("èaà\nüî", Encoding.UTF8), Encoding.GetEncoding("windows-1252"))) {
                CollectionAssert.AreEqual(new char[] { 'Ã', '¨', 'a' }, cfile.ReadChars(3));
                CollectionAssert.AreEqual(new char[] { 'Ã', ' ', '\n' }, cfile.ReadChars(3));
                CollectionAssert.AreEqual(new char[] { 'Ã', '¼', 'Ã', }, cfile.ReadChars(3));
                CollectionAssert.AreEqual(new char[] { '®' }, cfile.ReadChars(3));
                CollectionAssert.AreEqual(null, cfile.ReadChars(3));
                Assert.AreEqual(true, cfile.EOF);
            }
        }
Example #3
0
        public void TestReadChars()
        {
            using (var cfile = new CFile(BuildStream("èaà\nüî"))) {
                CollectionAssert.AreEqual(new char[] { 'Ã', '¨', 'a' }, cfile.ReadChars(3));
                CollectionAssert.AreEqual(new char[] { 'Ã', ' ', '\n' }, cfile.ReadChars(3));
                CollectionAssert.AreEqual(new char[] { 'Ã', '¼', 'Ã', }, cfile.ReadChars(3));
                CollectionAssert.AreEqual(new char[] { '®' }, cfile.ReadChars(3));
                CollectionAssert.AreEqual(null, cfile.ReadChars(3));
                Assert.AreEqual(true, cfile.EOF);
            }

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

            using (var cfile = new CFile(BuildStream("èaà\nüî"), Encoding.UTF8)) {
                CollectionAssert.AreEqual(new char[] { 'è', 'a', 'à' }, cfile.ReadChars(3));
                CollectionAssert.AreEqual(new char[] { '\n', 'ü', 'î' }, cfile.ReadChars(3));
                CollectionAssert.AreEqual(null, cfile.ReadChars(3));
                Assert.AreEqual(true, cfile.EOF);
            }

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

            using (var cfile = new CFile(BuildStream("èaà\nüî", Encoding.UTF8), Encoding.GetEncoding("windows-1252"))) {
                CollectionAssert.AreEqual(new char[] { 'Ã', '¨', 'a' }, cfile.ReadChars(3));
                CollectionAssert.AreEqual(new char[] { 'Ã', ' ', '\n' }, cfile.ReadChars(3));
                CollectionAssert.AreEqual(new char[] { 'Ã', '¼', 'Ã', }, cfile.ReadChars(3));
                CollectionAssert.AreEqual(new char[] { '®' }, cfile.ReadChars(3));
                CollectionAssert.AreEqual(null, cfile.ReadChars(3));
                Assert.AreEqual(true, cfile.EOF);
            }
        }