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
103 changes: 0 additions & 103 deletions Tests/TPPDFTests/Pagination/Int+RomanNumerals_Spec.swift

This file was deleted.

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

import Testing
@testable import TPPDF

struct IntRomanNumeralsTests {
@Test(arguments: [
(0, ""),
(1, "I"),
(2, "II"),
(3, "III"),
(4, "IV"),
(5, "V"),
(6, "VI"),
(7, "VII"),
(8, "VIII"),
(9, "IX"),
(10, "X"),
(11, "XI"),
(12, "XII"),
(13, "XIII"),
(14, "XIV"),
(15, "XV"),
(16, "XVI"),
(17, "XVII"),
(18, "XVIII"),
(19, "XIX"),
(20, "XX"),
(21, "XXI"),
(22, "XXII"),
(23, "XXIII"),
(24, "XXIV"),
(25, "XXV"),
(26, "XXVI"),
(27, "XXVII"),
(28, "XXVIII"),
(29, "XXIX"),
(30, "XXX"),
(40, "XL"),
(41, "XLI"),
(42, "XLII"),
(43, "XLIII"),
(44, "XLIV"),
(45, "XLV"),
(46, "XLVI"),
(47, "XLVII"),
(48, "XLVIII"),
(49, "XLIX"),
(50, "L"),
(51, "LI"),
(52, "LII"),
(53, "LIII"),
(54, "LIV"),
(55, "LV"),
(56, "LVI"),
(57, "LVII"),
(58, "LVIII"),
(59, "LIX"),
(60, "LX"),
(90, "XC"),
(91, "XCI"),
(92, "XCII"),
(93, "XCIII"),
(94, "XCIV"),
(95, "XCV"),
(96, "XCVI"),
(97, "XCVII"),
(98, "XCVIII"),
(99, "XCIX"),
(100, "C"),
(200, "CC"),
(300, "CCC"),
(400, "CD"),
(500, "D"),
(600, "DC"),
(700, "DCC"),
(800, "DCCC"),
(900, "CM"),
(1000, "M"),
])
func convertsIntegersToRomanNumerals(value: Int, expectedNumeral: String) {
// Arrange
let number = value

// Act
let numeral = number.romanNumerals

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

import Testing
@testable import TPPDF

struct PDFPaginationEquatableTests {
@Test(arguments: ["container", "style", "range", "hiddenPages"])
func differingSettingsMakePaginationUnequal(property: String) {
// Arrange
let pagination = PDFPagination()
var otherPagination = PDFPagination()
switch property {
case "container": otherPagination.container = .contentLeft
case "style": otherPagination.style = .roman(template: "%@ / %@")
case "range": otherPagination.range = (start: 2, end: 5)
default: otherPagination.hiddenPages = [1, 2, 3]
}

// Act
let isEqual = pagination == otherPagination

// Assert
#expect(!isEqual)
}
}

This file was deleted.

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

import Foundation
import Testing
@testable import TPPDF

struct PDFPaginationStyleEquatableTests {
@Test func defaultStylesAreEqual() {
// Arrange
let style = PDFPaginationStyle.default
let otherStyle = PDFPaginationStyle.default

// Act
let isEqual = style == otherStyle

// Assert
#expect(isEqual)
}

@Test(arguments: [(0, 0, true), (0, 1, true), (0, 2, false), (1, 2, false)])
func romanStyleEqualityDependsOnTemplate(firstIndex: Int, secondIndex: Int, expectedEquality: Bool) {
// Arrange
let styles = [
PDFPaginationStyle.roman(template: "123"),
.roman(template: "123"),
.roman(template: "456"),
]

// Act
let isEqual = styles[firstIndex] == styles[secondIndex]

// Assert
#expect(isEqual == expectedEquality)
}

@Test(arguments: [0, 1, 2, 3], [0, 1, 2, 3])
func numberStyleEqualityDependsOnTemplateAndFormatter(firstIndex: Int, secondIndex: Int) {
// Arrange
let firstFormatter = NumberFormatter()
firstFormatter.numberStyle = .percent
let secondFormatter = NumberFormatter()
secondFormatter.numberStyle = .decimal
let styles = [
PDFPaginationStyle.customNumberFormat(template: "123", formatter: firstFormatter),
.customNumberFormat(template: "123", formatter: secondFormatter),
.customNumberFormat(template: "456", formatter: firstFormatter),
.customNumberFormat(template: "456", formatter: secondFormatter),
]

// Act
let isEqual = styles[firstIndex] == styles[secondIndex]

// Assert
#expect(isEqual == (firstIndex == secondIndex))
}

@Test func customClosureStyleIsNotEqualToItselfAndCanReturnEmptyText() {
// Arrange
let style = PDFPaginationStyle.customClosure { _, _ in "" }

// Act
let isEqual = style == style
let text = style.format(page: 1, total: 2)

// Assert
#expect(!isEqual)
#expect(text.isEmpty)
}
}
Loading
Loading