mirror of
https://github.com/UglyToad/PdfPig.git
synced 2025-10-14 10:55:04 +08:00
add very simple tests to boost coverage
This commit is contained in:
35
src/UglyToad.Pdf.Tests/Geometry/PdfPointTests.cs
Normal file
35
src/UglyToad.Pdf.Tests/Geometry/PdfPointTests.cs
Normal file
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
31
src/UglyToad.Pdf.Tests/Geometry/PdfVectorTests.cs
Normal file
31
src/UglyToad.Pdf.Tests/Geometry/PdfVectorTests.cs
Normal file
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
32
src/UglyToad.Pdf.Tests/Util/OtherEncodings.cs
Normal file
32
src/UglyToad.Pdf.Tests/Util/OtherEncodings.cs
Normal file
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user