Exemplo n.º 1
0
        public void BlockSortDataTest003()
        {
            int markpos = 0;

            byte[] buffer = new byte[] { 41, 32, 43, 44, 45, 46, 47, 38, 39, 10, 20, 10, 20, 234, 0 };
            BlockSort.BlockSortData(buffer, buffer.Length, ref markpos);
        }
Exemplo n.º 2
0
        public void BlockSortData_Theory03(Encoding enc, string testStr)
        {
            byte[] buffer;
            int    markpos;

            PrepareTestData(enc, testStr, out buffer, out markpos);

            Assert.Throws <IndexOutOfRangeException>(
                () => BlockSort.BlockSortData(buffer, buffer.Length, ref markpos));
        }
Exemplo n.º 3
0
        public void BlockSortData_Theory01(string testStr)
        {
            UTF8Encoding enc = new UTF8Encoding(false);

            byte[] buffer  = new byte[enc.GetByteCount(testStr) + 1];
            byte[] byteStr = enc.GetBytes(testStr);
            Buffer.BlockCopy(byteStr, 0, buffer, 0, byteStr.Length);
            int markpos = byteStr.Length;

            BlockSort.BlockSortData(buffer, buffer.Length, ref markpos);
        }
Exemplo n.º 4
0
        public void BlockSortData_Theory02(Encoding enc, string testStr)
        {
            // TODO Find reason for failing tests with Big Endian multibyte
            // text encodings - except for some Chinese samples
            // (probably not enough 0x00s as these may be 4 byte unicode characters)

            byte[] buffer;
            int    markpos;

            PrepareTestData(enc, testStr, out buffer, out markpos);

            BlockSort.BlockSortData(buffer, buffer.Length, ref markpos);
        }
Exemplo n.º 5
0
        public void BlockSortDataTest005()
        {
            int markpos = 13;

            byte[] buffer = Util.ReadFileToEnd(Path.Combine(Util.RepoRoot, "artifacts", "data", "testhello.obz"));
            byte[] data   = new byte[1024];
            Buffer.BlockCopy(buffer, 0, data, 0, buffer.Length);
            BlockSort.BlockSortData(data, buffer.Length + 1, ref markpos);

            byte[] expected = new byte[] { 0x0a, 0x0d, 0x20, 0x21, 0x6f, 0x7a, 0x00, 0x20, 0x48, 0x65, 0x6c, 0x6c, 0x7a, 0x62 };
            for (int i = 0; i < expected.Length; i++)
            {
                Assert.Equal <byte>(expected[i], data[i]);
            }
        }
Exemplo n.º 6
0
        public void BlockSortValidate_Theory(string source, string expected)
        {
            byte[] sourceData   = Util.ReadFileToEnd(source);
            byte[] expectedData = Util.ReadFileToEnd(expected);
            byte[] buffer       = new byte[sourceData.Length + 1];
            Buffer.BlockCopy(sourceData, 0, buffer, 0, sourceData.Length);
            int markpos = sourceData.Length;

            BlockSort.BlockSortData(buffer, buffer.Length, ref markpos);

            for (int i = 0; i < expectedData.Length; i++)
            {
                Assert.Equal <uint>(expectedData[i], buffer[i]);
            }
        }
Exemplo n.º 7
0
        public void BlockSortDataTest002()
        {
            int markpos = 0;

            Assert.Throws <DjvuInvalidOperationException>(() => BlockSort.BlockSortData(new byte[] { 1, 2, 3, 4, 5 }, 5, ref markpos));
        }
Exemplo n.º 8
0
        public void BlockSortDataTest001()
        {
            int markpos = 0;

            Assert.Throws <DjvuArgumentOutOfRangeException>("psize", () => BlockSort.BlockSortData(new byte[1], 10, ref markpos));
        }