Exemplo n.º 1
0
        public void TestReadSBytes()
        {
            using (var cfile = new CFile(BuildStream("èaà\nüî"))) {
                Assert.Equal(new sbyte[] { -61, -88, 97 }, cfile.ReadSBytes(3));
                Assert.Equal(new sbyte[] { -61, -96, 10 }, cfile.ReadSBytes(3));
                Assert.Equal(new sbyte[] { -61, -68, -61 }, cfile.ReadSBytes(3));
                Assert.Equal(new sbyte[] { -82 }, cfile.ReadSBytes(3));
                Assert.Equal(null, cfile.ReadSBytes(3));
                Assert.Equal(true, cfile.EOF);
            }

#if !NET_STANDARD
            using (var cfile = new CFile(BuildStream("èaà\nüî", Encoding.GetEncoding("windows-1252")))) {
                Assert.Equal(new sbyte[] { -24, 97, -32 }, cfile.ReadSBytes(3));
                Assert.Equal(new sbyte[] { 10, -4, -18 }, cfile.ReadSBytes(3));
                Assert.Equal(null, cfile.ReadSBytes(3));
                Assert.Equal(true, cfile.EOF);
            }
#endif

            using (var cfile = new CFile(BuildStream("èaà\nüî"), Encoding.UTF8)) {
                Assert.Equal(new sbyte[] { -61, -88, 97 }, cfile.ReadSBytes(3));
                Assert.Equal(new sbyte[] { -61, -96, 10 }, cfile.ReadSBytes(3));
                Assert.Equal(new sbyte[] { -61, -68, -61 }, cfile.ReadSBytes(3));
                Assert.Equal(new sbyte[] { -82 }, cfile.ReadSBytes(3));
                Assert.Equal(null, cfile.ReadSBytes(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 sbyte[] { -24, 97, -32 }, cfile.ReadSBytes(3));
                Assert.Equal(new sbyte[] { 10, -4, -18 }, cfile.ReadSBytes(3));
                Assert.Equal(null, cfile.ReadSBytes(3));
                Assert.Equal(true, cfile.EOF);
            }

            using (var cfile = new CFile(BuildStream("èaà\nüî", Encoding.UTF8), Encoding.GetEncoding("windows-1252"))) {
                Assert.Equal(new sbyte[] { -61, -88, 97 }, cfile.ReadSBytes(3));
                Assert.Equal(new sbyte[] { -61, -96, 10 }, cfile.ReadSBytes(3));
                Assert.Equal(new sbyte[] { -61, -68, -61 }, cfile.ReadSBytes(3));
                Assert.Equal(new sbyte[] { -82 }, cfile.ReadSBytes(3));
                Assert.Equal(null, cfile.ReadSBytes(3));
                Assert.Equal(true, cfile.EOF);
            }
#endif
        }
Exemplo n.º 2
0
        public void TestReadSBytes()
        {
            using (var cfile = new CFile(BuildStream("èaà\nüî"))) {
                CollectionAssert.AreEqual(new sbyte[] { -61, -88, 97 }, cfile.ReadSBytes(3));
                CollectionAssert.AreEqual(new sbyte[] { -61, -96, 10 }, cfile.ReadSBytes(3));
                CollectionAssert.AreEqual(new sbyte[] { -61, -68, -61 }, cfile.ReadSBytes(3));
                CollectionAssert.AreEqual(new sbyte[] { -82 }, cfile.ReadSBytes(3));
                CollectionAssert.AreEqual(null, cfile.ReadSBytes(3));
                Assert.AreEqual(true, cfile.EOF);
            }

            using (var cfile = new CFile(BuildStream("èaà\nüî", Encoding.GetEncoding("windows-1252")))) {
                CollectionAssert.AreEqual(new sbyte[] { -24, 97, -32 }, cfile.ReadSBytes(3));
                CollectionAssert.AreEqual(new sbyte[] { 10, -4, -18 }, cfile.ReadSBytes(3));
                CollectionAssert.AreEqual(null, cfile.ReadSBytes(3));
                Assert.AreEqual(true, cfile.EOF);
            }

            using (var cfile = new CFile(BuildStream("èaà\nüî"), Encoding.UTF8)) {
                CollectionAssert.AreEqual(new sbyte[] { -61, -88, 97 }, cfile.ReadSBytes(3));
                CollectionAssert.AreEqual(new sbyte[] { -61, -96, 10 }, cfile.ReadSBytes(3));
                CollectionAssert.AreEqual(new sbyte[] { -61, -68, -61 }, cfile.ReadSBytes(3));
                CollectionAssert.AreEqual(new sbyte[] { -82 }, cfile.ReadSBytes(3));
                CollectionAssert.AreEqual(null, cfile.ReadSBytes(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 sbyte[] { -24, 97, -32 }, cfile.ReadSBytes(3));
                CollectionAssert.AreEqual(new sbyte[] { 10, -4, -18 }, cfile.ReadSBytes(3));
                CollectionAssert.AreEqual(null, cfile.ReadSBytes(3));
                Assert.AreEqual(true, cfile.EOF);
            }

            using (var cfile = new CFile(BuildStream("èaà\nüî", Encoding.UTF8), Encoding.GetEncoding("windows-1252"))) {
                CollectionAssert.AreEqual(new sbyte[] { -61, -88, 97 }, cfile.ReadSBytes(3));
                CollectionAssert.AreEqual(new sbyte[] { -61, -96, 10 }, cfile.ReadSBytes(3));
                CollectionAssert.AreEqual(new sbyte[] { -61, -68, -61 }, cfile.ReadSBytes(3));
                CollectionAssert.AreEqual(new sbyte[] { -82 }, cfile.ReadSBytes(3));
                CollectionAssert.AreEqual(null, cfile.ReadSBytes(3));
                Assert.AreEqual(true, cfile.EOF);
            }
        }