#234 handle missing first index for differences array

This commit is contained in:
Eliot Jones
2020-11-22 13:07:05 -04:00
parent fa5e37dc8c
commit ccd7d81ae3
2 changed files with 8 additions and 12 deletions

View File

@@ -10,7 +10,7 @@
{
var names = Standard14.GetNames().Count;
Assert.Equal(34, names);
Assert.Equal(38, names);
}
}
}

View File

@@ -7,7 +7,6 @@
using PdfPig.Parser.Parts;
using Tokenization.Scanner;
using Tokens;
using Util;
internal class EncodingReader : IEncodingReader
{
@@ -95,20 +94,17 @@
return differences;
}
var activeCode = differenceArray.GetNumeric(0).Int;
for (int i = 1; i < differenceArray.Data.Count; i++)
var currentIndex = -1;
foreach (var differenceEntry in differenceArray.Data)
{
var entry = differenceArray.Data[i];
if (entry is NumericToken numeric)
if (differenceEntry is NumericToken number)
{
activeCode = numeric.Int;
currentIndex = number.Int;
}
else if (entry is NameToken name)
else if (differenceEntry is NameToken name)
{
differences.Add((activeCode, name.Data));
activeCode++;
differences.Add((currentIndex, name.Data));
currentIndex++;
}
else
{