Skip to content

Commit e5affd8

Browse files
committed
Updated unit tests
1 parent 40c8910 commit e5affd8

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

Tests/SilicaTests/FontTests.swift

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,36 +8,40 @@
88

99
import XCTest
1010
@testable import Silica
11+
import FontConfig
1112

1213
final class FontTests: XCTestCase {
1314

1415
func testCreateFont() {
1516

1617
#if os(Linux)
1718
var fontNames = [
18-
("LiberationSerif", "Liberation Serif"),
19-
("LiberationSerif-Bold", "Liberation Serif")
19+
("LiberationSerif", "Liberation Serif", FontWeight.regular),
20+
("LiberationSerif-Bold", "Liberation Serif", .bold)
2021
]
2122

2223
#else
2324
var fontNames = [
24-
("TimesNewRoman", "Times New Roman"),
25-
("TimesNewRoman-Bold", "Times New Roman")
25+
("TimesNewRoman", "Times New Roman", FontWeight.regular),
26+
("TimesNewRoman-Bold", "Times New Roman", .bold)
2627
]
2728
#endif
2829

2930
#if os(macOS)
30-
fontNames += [("MicrosoftSansSerif", "Microsoft Sans Serif"),
31-
("MicrosoftSansSerif-Bold", "Microsoft Sans Serif")]
31+
fontNames += [("MicrosoftSansSerif", "Microsoft Sans Serif", .regular),
32+
("MicrosoftSansSerif-Bold", "Microsoft Sans Serif", .bold)]
3233
#endif
3334

34-
for (fontName, expectedFullName) in fontNames {
35+
for (fontName, expectedFullName, weight) in fontNames {
3536

36-
guard let font = Silica.CGFont(name: fontName)
37+
guard let font = Silica.CGFont(name: fontName),
38+
let pattern = FontConfig.Pattern(cgFont: fontName)
3739
else { XCTFail("Could not create font \(fontName)"); return }
3840

3941
XCTAssertEqual(font.name, font.name)
4042
XCTAssertEqual(expectedFullName, font.scaledFont.fullName)
43+
XCTAssertEqual(pattern.family, font.family)
44+
XCTAssertEqual(pattern.weight, weight)
4145
}
4246
}
4347
}

0 commit comments

Comments
 (0)