2018-01-10 19:49:32 +00:00
|
|
|
|
namespace UglyToad.PdfPig.Tests.Fonts.Encodings
|
2018-01-01 17:23:32 +00:00
|
|
|
|
{
|
2018-01-01 18:39:18 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.IO;
|
2020-01-04 22:56:41 +00:00
|
|
|
|
using PdfFonts.Encodings;
|
2018-01-01 17:23:32 +00:00
|
|
|
|
using Xunit;
|
|
|
|
|
|
|
|
|
|
public class GlyphListFactoryTests
|
|
|
|
|
{
|
|
|
|
|
[Fact]
|
|
|
|
|
public void CanGetAdobeGlyphList()
|
|
|
|
|
{
|
|
|
|
|
var result = GlyphListFactory.Get("glyphlist");
|
|
|
|
|
|
|
|
|
|
var h = result.NameToUnicode("H");
|
|
|
|
|
|
|
|
|
|
Assert.Equal("H", h);
|
|
|
|
|
}
|
2018-01-01 18:39:18 +00:00
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
public void MissingResourceNameThrows()
|
|
|
|
|
{
|
|
|
|
|
Action action = () => GlyphListFactory.Get("missing resource");
|
|
|
|
|
|
|
|
|
|
Assert.Throws<ArgumentException>(action);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
public void SkipsBlankLine()
|
|
|
|
|
{
|
|
|
|
|
var input = @"# comment
|
|
|
|
|
|
|
|
|
|
one;0031";
|
|
|
|
|
using (var stream = new MemoryStream(System.Text.Encoding.ASCII.GetBytes(input)))
|
|
|
|
|
{
|
|
|
|
|
var result = GlyphListFactory.Read(stream);
|
|
|
|
|
|
|
|
|
|
Assert.Equal("1", result.NameToUnicode("one"));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
public void ReadNullThrows()
|
|
|
|
|
{
|
|
|
|
|
Action action = () => GlyphListFactory.Read(null);
|
|
|
|
|
|
|
|
|
|
Assert.Throws<ArgumentNullException>(action);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
public void InvalidFormatThrows()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
var input = @"one;0031
|
|
|
|
|
twelve;";
|
|
|
|
|
using (var stream = new MemoryStream(System.Text.Encoding.ASCII.GetBytes(input)))
|
|
|
|
|
{
|
|
|
|
|
Action action = () => GlyphListFactory.Read(stream);
|
|
|
|
|
|
|
|
|
|
Assert.Throws<InvalidOperationException>(action);
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-01-01 17:23:32 +00:00
|
|
|
|
}
|
|
|
|
|
}
|