MathFont and MathTable added, both do not rely on existing SwifthMath code.
This commit is contained in:
26
Tests/SwiftMathTests/MathFontTests.swift
Normal file
26
Tests/SwiftMathTests/MathFontTests.swift
Normal file
@@ -0,0 +1,26 @@
|
||||
import XCTest
|
||||
@testable import SwiftMath
|
||||
|
||||
//
|
||||
// MathFontTests.swift
|
||||
//
|
||||
//
|
||||
// Created by Peter Tang on 12/9/2023.
|
||||
//
|
||||
|
||||
final class MathFontTests: XCTestCase {
|
||||
func testMathFontScript() throws {
|
||||
// for family in UIFont.familyNames.sorted() {
|
||||
// let names = UIFont.fontNames(forFamilyName: family)
|
||||
// print("Family: \(family) Font names: \(names)")
|
||||
// }
|
||||
let size = Int.random(in: 20 ... 40)
|
||||
MathFont.allCases.forEach {
|
||||
// print("\(#function) cgfont \($0.cgFont())")
|
||||
// print("\(#function) ctfont \($0.ctFont(withSize: CGFloat(size)))")
|
||||
XCTAssertNotNil($0.cgFont())
|
||||
XCTAssertNotNil($0.ctFont(withSize: CGFloat(size)))
|
||||
XCTAssertEqual($0.ctFont(withSize: CGFloat(size))?.fontSize, CGFloat(size), "ctFont fontSize test")
|
||||
}
|
||||
}
|
||||
}
|
||||
36
Tests/SwiftMathTests/MathTableTests.swift
Normal file
36
Tests/SwiftMathTests/MathTableTests.swift
Normal file
@@ -0,0 +1,36 @@
|
||||
import XCTest
|
||||
@testable import SwiftMath
|
||||
|
||||
//
|
||||
// MathTableTests.swift
|
||||
//
|
||||
//
|
||||
// Created by Peter Tang on 12/9/2023.
|
||||
//
|
||||
|
||||
final class MathTableTests: XCTestCase {
|
||||
func testMathFontScript() throws {
|
||||
let size = Int.random(in: 20 ... 40)
|
||||
MathFont.allCases.forEach {
|
||||
// print("\(#function) cgfont \($0.cgFont())")
|
||||
// print("\(#function) ctfont \($0.ctFont(withSize: CGFloat(size)))")
|
||||
// XCTAssertNotNil($0.cgFont())
|
||||
// XCTAssertNotNil($0.ctFont(withSize: CGFloat(size)))
|
||||
// XCTAssertEqual($0.ctFont(withSize: CGFloat(size))?.fontSize, CGFloat(size), "ctFont fontSize test")
|
||||
let ctFont = $0.ctFont(withSize: CGFloat(size))
|
||||
if let unitsPerEm = ctFont?.unitsPerEm {
|
||||
let mathTable = MathTable(withFont: $0, fontSize: CGFloat(size), unitsPerEm: unitsPerEm)
|
||||
|
||||
let values = [
|
||||
mathTable.fractionNumeratorDisplayStyleShiftUp,
|
||||
mathTable.fractionNumeratorShiftUp,
|
||||
mathTable.fractionDenominatorDisplayStyleShiftDown,
|
||||
mathTable.fractionDenominatorShiftDown,
|
||||
mathTable.fractionNumeratorDisplayStyleGapMin,
|
||||
mathTable.fractionNumeratorGapMin,
|
||||
]
|
||||
print("\(ctFont) -> \(values)")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user