68 lines
2.1 KiB
Swift
68 lines
2.1 KiB
Swift
import MusicAssistantCore
|
|
import XCTest
|
|
|
|
final class ArabicPronunciationProcessorTests: XCTestCase {
|
|
private let processor = ArabicPronunciationProcessor()
|
|
|
|
func testDisabledProcessingLeavesLyricsUntouched() {
|
|
let lyrics = "\u{0645}\u{0651}\u{064E}\u{0631}\u{062D}\u{064E}\u{0628}\u{064B}\u{0627}"
|
|
|
|
let result = processor.process(
|
|
lyrics: lyrics,
|
|
settings: ArabicPronunciationSettings(isEnabled: false)
|
|
)
|
|
|
|
XCTAssertEqual(result.text, lyrics)
|
|
XCTAssertEqual(result.notes, [.processingDisabled])
|
|
}
|
|
|
|
func testProcessingNormalizesSuppliedDiacritics() {
|
|
let lyrics = "\u{0645}\u{0651}\u{064E}\u{0631}\u{062D}\u{064E}\u{0628}\u{064B}\u{0627}"
|
|
|
|
let result = processor.process(
|
|
lyrics: lyrics,
|
|
settings: ArabicPronunciationSettings(
|
|
isEnabled: true,
|
|
diacritizationPolicy: .pronunciationTargeted
|
|
)
|
|
)
|
|
|
|
XCTAssertEqual(
|
|
result.text,
|
|
"\u{0645}\u{064E}\u{0651}\u{0631}\u{062D}\u{064E}\u{0628}\u{064B}\u{0627}"
|
|
)
|
|
XCTAssertTrue(result.notes.isEmpty)
|
|
}
|
|
|
|
func testRemovingTanweenKeepsOtherDiacritics() {
|
|
let result = processor.process(
|
|
lyrics: "\u{0634}\u{064F}\u{0643}\u{0652}\u{0631}\u{064B}\u{0627}",
|
|
settings: ArabicPronunciationSettings(
|
|
isEnabled: true,
|
|
tanweenPolicy: .removeWhenUnwanted
|
|
)
|
|
)
|
|
|
|
XCTAssertEqual(result.text, "\u{0634}\u{064F}\u{0643}\u{0652}\u{0631}\u{0627}")
|
|
}
|
|
|
|
func testFullTashkeelDoesNotInventMissingMarks() {
|
|
let lyrics = "\u{0645}\u{0631}\u{062D}\u{0628}\u{0627}"
|
|
|
|
let result = processor.process(
|
|
lyrics: lyrics,
|
|
settings: ArabicPronunciationSettings(
|
|
isEnabled: true,
|
|
diacritizationPolicy: .fullTashkeel,
|
|
tanweenPolicy: .addWhenPronunciationRequires
|
|
)
|
|
)
|
|
|
|
XCTAssertEqual(result.text, lyrics)
|
|
XCTAssertEqual(
|
|
result.notes,
|
|
[.fullTashkeelNeedsReview, .tanweenAdditionNeedsReview]
|
|
)
|
|
}
|
|
}
|