Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 0 additions & 38 deletions Tests/TPPDFTests/Math/CGPoint+Math_Spec.swift

This file was deleted.

49 changes: 49 additions & 0 deletions Tests/TPPDFTests/Math/CGPointMathTests.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
//
// CGPointMathTests.swift
// TPPDF
//
// Created by Philip Niedertscheider on 11.05.2017.
// Copyright © 2016-2026 techprimate GmbH. All rights reserved.
//

import CoreGraphics
import Testing
@testable import TPPDF

struct CGPointMathTests {
@Test func addingPointsAddsBothCoordinates() {
// Arrange
let point = CGPoint(x: 10, y: 20)
let otherPoint = CGPoint(x: 30, y: 40)

// Act
let result = point + otherPoint

// Assert
#expect(result == CGPoint(x: 40, y: 60))
}

@Test func subtractingPointsSubtractsBothCoordinates() {
// Arrange
let point = CGPoint(x: 10, y: 20)
let otherPoint = CGPoint(x: 30, y: 40)

// Act
let result = point - otherPoint

// Assert
#expect(result == CGPoint(x: -20, y: -20))
}

@Test func addingScalarAddsToBothCoordinates() {
// Arrange
let point = CGPoint(x: 10, y: 20)
let value: CGFloat = 20

// Act
let result = point + value

// Assert
#expect(result == CGPoint(x: 30, y: 40))
}
}
92 changes: 0 additions & 92 deletions Tests/TPPDFTests/Metadata/PDFInfo+Equatable_Spec.swift

This file was deleted.

47 changes: 47 additions & 0 deletions Tests/TPPDFTests/Metadata/PDFInfoEquatableTests.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
//
// PDFInfoEquatableTests.swift
// TPPDF
//
// Created by Philip Niedertscheider on 27.12.2017.
// Copyright © 2016-2026 techprimate GmbH. All rights reserved.
//

import Testing
@testable import TPPDF

struct PDFInfoEquatableTests {
@Test func defaultMetadataIsEqual() {
// Arrange
let info = PDFInfo()
let otherInfo = PDFInfo()

// Act
let isEqual = info == otherInfo

// Assert
#expect(isEqual)
}

@Test(arguments: ["title", "author", "subject", "keywords", "ownerPassword", "userPassword", "allowsPrinting", "allowsCopying"])
func changingMetadataMakesItUnequal(property: String) {
// Arrange
let info = PDFInfo()
let otherInfo = PDFInfo()
switch property {
case "title": otherInfo.title = "OTHER"
case "author": otherInfo.author = "OTHER"
case "subject": otherInfo.subject = "OTHER"
case "keywords": otherInfo.keywords = ["OTHER"]
case "ownerPassword": otherInfo.ownerPassword = "OTHER"
case "userPassword": otherInfo.userPassword = "OTHER"
case "allowsPrinting": otherInfo.allowsPrinting = false
default: otherInfo.allowsCopying = false
}

// Act
let isEqual = info == otherInfo

// Assert
#expect(!isEqual)
}
}
53 changes: 53 additions & 0 deletions Tests/TPPDFTests/Metadata/PDFInfoTests.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
//
// PDFInfoTests.swift
// TPPDF
//
// Created by Philip Niedertscheider on 11.04.2017.
// Copyright © 2016-2026 techprimate GmbH. All rights reserved.
//

import CoreGraphics
import Testing
@testable import TPPDF

struct PDFInfoTests {
@Test func initializesWithDefaultMetadataAndPermissions() {
// Arrange
let expectedKeywords = ["tppdf", "pdf", "generator"]

// Act
let info = PDFInfo()

// Assert
#expect(info.title == "Title")
#expect(info.author == "Author")
#expect(info.subject == "Subject")
#expect(info.keywords == expectedKeywords)
#expect(info.ownerPassword == nil)
#expect(info.userPassword == nil)
#expect(info.allowsPrinting)
#expect(info.allowsCopying)
}

@Test func generatesMetadataWithConfiguredPasswordsAndPermissions() {
// Arrange
let info = PDFInfo()
info.ownerPassword = "1234"
info.userPassword = "ABCD"
info.allowsPrinting = false

// Act
let metadata = info.generate()

// Assert
#expect(metadata[kCGPDFContextTitle as String] as? String == "Title")
#expect(metadata[kCGPDFContextAuthor as String] as? String == "Author")
#expect(metadata[kCGPDFContextSubject as String] as? String == "Subject")
#expect(metadata[kCGPDFContextKeywords as String] as? [String] == ["tppdf", "pdf", "generator"])
#expect(metadata[kCGPDFContextAllowsPrinting as String] as? Bool == false)
#expect(metadata[kCGPDFContextAllowsCopying as String] as? Bool == true)
#expect(metadata[kCGPDFContextOwnerPassword as String] as? String == "1234")
#expect(metadata[kCGPDFContextUserPassword as String] as? String == "ABCD")
#expect((metadata[kCGPDFContextCreator as String] as? String ?? "").hasPrefix("xctest"))
}
}
78 changes: 0 additions & 78 deletions Tests/TPPDFTests/Metadata/PDFInfo_Spec.swift

This file was deleted.

31 changes: 0 additions & 31 deletions Tests/TPPDFTests/Page Format/PDFPageFormat+Layout_Spec.swift

This file was deleted.

Loading
Loading