public void ReadTest001() { const int expectedLength = 4558626; string filePath = Path.Combine(Util.ArtifactsDataPath, "test042C.djvu.2048.bzz"); string testFilePath = Path.Combine(Util.ArtifactsPath, "test042C.djvu"); byte[] testBuffer = Util.ReadFileToEnd(filePath); byte[] expectedBuffer = Util.ReadFileToEnd(testFilePath); Assert.Equal(expectedBuffer.Length, expectedLength); using (MemoryStream readStream = new MemoryStream(testBuffer)) using (BzzReader reader = new BzzReader(new BSInputStream(readStream))) { byte[] result = new byte[expectedBuffer.Length]; int readBytes = reader.Read(result, 0, result.Length); Assert.Equal(readBytes, expectedLength); for (int i = 0; i < expectedLength; i++) { if (expectedBuffer[i] != result[i]) { Assert.True(false); } } } }
public void DecoderNoLearn002() { string filePath = Path.Combine(Util.ArtifactsDataPath, "test043C.json.bzz"); byte[] testBuffer = Util.ReadFileToEnd(filePath); using (MemoryStream readStream = new MemoryStream(testBuffer)) using (BzzReader reader = new BzzReader(new BSInputStream(readStream))) { byte[] result = new byte[testBuffer.Length]; int readBytes = reader.Read(result, 0, result.Length / 2); BSInputStream bsStream = reader.BaseStream as BSInputStream; Assert.NotNull(bsStream); byte ctx = 0x01; int decoded = bsStream.Coder.DecoderNoLearn(ref ctx); } }