add test coverage for invalid document from #33

This commit is contained in:
Eliot Jones
2019-06-08 16:58:20 +01:00
parent 2b486dccab
commit f3c8220ec4
4 changed files with 37 additions and 0 deletions

View File

@@ -16,5 +16,17 @@
return Path.Combine(documentFolder, name); return Path.Combine(documentFolder, name);
} }
public static string GetSpecificTestDocumentPath(string name, bool isPdf = true)
{
var documentFolder = Path.GetFullPath(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "..", "..", "..", "Integration", "SpecificTestDocuments"));
if (!name.EndsWith(".pdf") && isPdf)
{
name += ".pdf";
}
return Path.Combine(documentFolder, name);
}
} }
} }

View File

@@ -0,0 +1,23 @@
namespace UglyToad.PdfPig.Tests.Integration
{
using Xunit;
public class InvalidObjectLoopTests
{
[Fact]
public void CanOpenDocumentAndGetPage()
{
var path = IntegrationHelpers.GetSpecificTestDocumentPath("invalid-xref-loop.pdf");
using (var document = PdfDocument.Open(path))
{
for (var i = 1; i <= document.NumberOfPages; i++)
{
var page = document.GetPage(i);
Assert.NotNull(page.Content);
}
}
}
}
}

View File

@@ -13,6 +13,7 @@
<None Remove="Fonts\Type1\*.pfa" /> <None Remove="Fonts\Type1\*.pfa" />
<None Remove="Fonts\Type1\*.pfb" /> <None Remove="Fonts\Type1\*.pfb" />
<None Remove="Integration\Documents\*" /> <None Remove="Integration\Documents\*" />
<None Remove="Integration\SpecificTestDocuments\*" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
@@ -72,6 +73,7 @@
<Content Include="Fonts\Type1\CMBX12.pfa" /> <Content Include="Fonts\Type1\CMBX12.pfa" />
<Content Include="Fonts\Type1\CMCSC10.pfa" /> <Content Include="Fonts\Type1\CMCSC10.pfa" />
<Content Include="Fonts\Type1\Raleway-Black.pfb" /> <Content Include="Fonts\Type1\Raleway-Black.pfb" />
<Content Include="Integration\SpecificTestDocuments\invalid-xref-loop.pdf" />
<Content Include="Parser\SimpleGoogleDocPageContent.txt"> <Content Include="Parser\SimpleGoogleDocPageContent.txt">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content> </Content>