From ede706baae45ccc6afd2b6416391a98cd925a704 Mon Sep 17 00:00:00 2001 From: Eliot Jones Date: Wed, 6 Dec 2017 00:13:33 +0000 Subject: [PATCH] add very simple tests to boost coverage --- .../Geometry/PdfPointTests.cs | 35 +++++++++++++++++++ .../Geometry/PdfVectorTests.cs | 31 ++++++++++++++++ src/UglyToad.Pdf.Tests/Util/OtherEncodings.cs | 32 +++++++++++++++++ 3 files changed, 98 insertions(+) create mode 100644 src/UglyToad.Pdf.Tests/Geometry/PdfPointTests.cs create mode 100644 src/UglyToad.Pdf.Tests/Geometry/PdfVectorTests.cs create mode 100644 src/UglyToad.Pdf.Tests/Util/OtherEncodings.cs diff --git a/src/UglyToad.Pdf.Tests/Geometry/PdfPointTests.cs b/src/UglyToad.Pdf.Tests/Geometry/PdfPointTests.cs new file mode 100644 index 00000000..c0777dcd --- /dev/null +++ b/src/UglyToad.Pdf.Tests/Geometry/PdfPointTests.cs @@ -0,0 +1,35 @@ +namespace UglyToad.Pdf.Tests.Geometry +{ + using Pdf.Geometry; + using Xunit; + + public class PdfPointTests + { + [Fact] + public void OriginIsZero() + { + var origin = PdfPoint.Origin; + + Assert.Equal(0, origin.X); + Assert.Equal(0, origin.Y); + } + + [Fact] + public void IntsSetValue() + { + var origin = new PdfPoint(256, 372); + + Assert.Equal(256, origin.X); + Assert.Equal(372, origin.Y); + } + + [Fact] + public void DoublesSetValue() + { + var origin = new PdfPoint(0.534436, 0.32552); + + Assert.Equal(0.534436m, origin.X); + Assert.Equal(0.32552m, origin.Y); + } + } +} diff --git a/src/UglyToad.Pdf.Tests/Geometry/PdfVectorTests.cs b/src/UglyToad.Pdf.Tests/Geometry/PdfVectorTests.cs new file mode 100644 index 00000000..e8a74ae4 --- /dev/null +++ b/src/UglyToad.Pdf.Tests/Geometry/PdfVectorTests.cs @@ -0,0 +1,31 @@ +namespace UglyToad.Pdf.Tests.Geometry +{ + using Pdf.Geometry; + using Xunit; + + public class PdfVectorTests + { + [Fact] + public void ConstructorSetsValues() + { + var vector = new PdfVector(5.2m, 6.9m); + + Assert.Equal(5.2m, vector.X); + Assert.Equal(6.9m, vector.Y); + } + + [Fact] + public void ScaleMultipliesLeavesOriginalUnchanged() + { + var vector = new PdfVector(5.2m, 6.9m); + + var scaled = vector.Scale(0.7m); + + Assert.Equal(5.2m, vector.X); + Assert.Equal(5.2m * 0.7m, scaled.X); + + Assert.Equal(6.9m, vector.Y); + Assert.Equal(6.9m * 0.7m, scaled.Y); + } + } +} diff --git a/src/UglyToad.Pdf.Tests/Util/OtherEncodings.cs b/src/UglyToad.Pdf.Tests/Util/OtherEncodings.cs new file mode 100644 index 00000000..edfa9f49 --- /dev/null +++ b/src/UglyToad.Pdf.Tests/Util/OtherEncodings.cs @@ -0,0 +1,32 @@ +namespace UglyToad.Pdf.Tests.Util +{ + using Pdf.Util; + using Xunit; + + public class OtherEncodingsTests + { + [Fact] + public void BytesNullReturnsNullString() + { + var result = OtherEncodings.BytesAsLatin1String(null); + + Assert.Null(result); + } + + [Fact] + public void BytesEmptyReturnsEmptyString() + { + var result = OtherEncodings.BytesAsLatin1String(new byte[0]); + + Assert.Equal(string.Empty, result); + } + + [Fact] + public void StringNullReturnsNullBytes() + { + var result = OtherEncodings.StringAsLatin1Bytes(null); + + Assert.Null(result); + } + } +}