mirror of
https://github.com/UglyToad/PdfPig.git
synced 2025-09-18 18:27:55 +08:00
add test for comment in dictionary from #145
check that we correctly handle the case where a comment appears inside a dictionary, this was handled by commit 3084a9. use list internally to dictionary tokenizer to avoid interface performance penalties.
This commit is contained in:
@@ -193,6 +193,39 @@ endobj
|
||||
Assert.Equal(4, mediaBox.Length);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void CommentsInsideDictionaryFromSap()
|
||||
{
|
||||
const string s = @"<<
|
||||
/Author (ABCD )
|
||||
/CreationDate (D:20150505083655)
|
||||
/Creator (Form 2014 EN)
|
||||
/Producer (SAP NetWeaver 700 )
|
||||
%SAPinfoStart TOA_DARA
|
||||
%FUNCTION=( )
|
||||
%MANDANT=( )
|
||||
%DEL_DATE=( )
|
||||
%SAP_OBJECT=( )
|
||||
%AR_OBJECT=( )
|
||||
%OBJECT_ID=( )
|
||||
%FORM_ID=( )
|
||||
%FORMARCHIV=( )
|
||||
%RESERVE=( )
|
||||
%NOTIZ=( )
|
||||
%-( )
|
||||
%-( )
|
||||
%-( )
|
||||
%SAPinfoEnd TOA_DARA
|
||||
>>";
|
||||
|
||||
var input = StringBytesTestConverter.Convert(s);
|
||||
|
||||
Assert.True(tokenizer.TryTokenize(input.First, input.Bytes, out var token));
|
||||
|
||||
var dictionary = AssertDictionaryToken(token);
|
||||
|
||||
AssertDictionaryEntry<StringToken, string>(dictionary, NameToken.Producer, "SAP NetWeaver 700 ");
|
||||
}
|
||||
|
||||
private static void AssertDictionaryEntry<TValue, TValueData>(DictionaryToken dictionary, NameToken key,
|
||||
TValueData value) where TValue : IDataToken<TValueData>
|
||||
|
@@ -60,7 +60,7 @@
|
||||
return true;
|
||||
}
|
||||
|
||||
private static Dictionary<NameToken, IToken> ConvertToDictionary(IReadOnlyList<IToken> tokens)
|
||||
private static Dictionary<NameToken, IToken> ConvertToDictionary(List<IToken> tokens)
|
||||
{
|
||||
var result = new Dictionary<NameToken, IToken>();
|
||||
|
||||
|
Reference in New Issue
Block a user