mirror of
https://github.com/UglyToad/PdfPig.git
synced 2025-09-19 10:47:56 +08:00
test coverage and fix bugs with ascii 85 filter
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
namespace UglyToad.Pdf.Tests.Filters
|
namespace UglyToad.Pdf.Tests.Filters
|
||||||
{
|
{
|
||||||
|
using System;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using ContentStream;
|
using ContentStream;
|
||||||
using Pdf.Filters;
|
using Pdf.Filters;
|
||||||
@@ -29,6 +30,28 @@ O<DJ+*.@<*K0@<6L(Df-\0Ec5e;DffZ(EZee.Bl.9pF""AGXBPCsi + DGm >@3BB / F * &OCAfu2
|
|||||||
text);
|
text);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void ReplacesZWithEmptyBytes()
|
||||||
|
{
|
||||||
|
var bytes = Encoding.ASCII.GetBytes("9jqo^zBlbD-");
|
||||||
|
|
||||||
|
var result = filter.Decode(bytes, new PdfDictionary(), 1);
|
||||||
|
|
||||||
|
var text = Encoding.ASCII.GetString(result);
|
||||||
|
|
||||||
|
Assert.Equal("Man \0\0\0\0is d", text);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void ZInMiddleOf5CharacterSequenceThrows()
|
||||||
|
{
|
||||||
|
var bytes = Encoding.ASCII.GetBytes("qjzqo^");
|
||||||
|
|
||||||
|
Action action = () => filter.Decode(bytes, new PdfDictionary(), 0);
|
||||||
|
|
||||||
|
Assert.Throws<InvalidOperationException>(action);
|
||||||
|
}
|
||||||
|
|
||||||
private const string PdfContent = @"1 0 obj
|
private const string PdfContent = @"1 0 obj
|
||||||
<< /Length 568 >>
|
<< /Length 568 >>
|
||||||
stream
|
stream
|
||||||
@@ -95,5 +118,7 @@ Li?EZek1DKKT1F`2DD/TboKAKY](@:s.m/h%oBC'mC/$>""*cF*)G6@;Q?_DIdZpC&";
|
|||||||
|
|
||||||
Assert.Equal(PdfContent.Replace("\r\n", "\n"), text);
|
Assert.Equal(PdfContent.Replace("\r\n", "\n"), text);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,7 +1,6 @@
|
|||||||
namespace UglyToad.Pdf.Tests.Filters
|
namespace UglyToad.Pdf.Tests.Filters
|
||||||
{
|
{
|
||||||
using System;
|
using System;
|
||||||
using System.Net.NetworkInformation;
|
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using ContentStream;
|
using ContentStream;
|
||||||
using Pdf.Filters;
|
using Pdf.Filters;
|
||||||
|
@@ -65,12 +65,12 @@
|
|||||||
{
|
{
|
||||||
if (index > 0)
|
if (index > 0)
|
||||||
{
|
{
|
||||||
// Should I throw here?
|
throw new InvalidOperationException("Encountered z within a 5 character block");
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int j = 0; j < 4; j++)
|
for (int j = 0; j < 4; j++)
|
||||||
{
|
{
|
||||||
writer.Write(0);
|
writer.Write((byte)0);
|
||||||
}
|
}
|
||||||
|
|
||||||
index = 0;
|
index = 0;
|
||||||
|
Reference in New Issue
Block a user