import Testing @testable import SprachmittlerText @Suite("Language detection") struct LanguageDetectorTests { private let detector = NaturalLanguageDetector() @Test func detectsGerman() throws { let detection = try #require( detector.detect( "Die schnelle Katze springt über den faulen Hund. Das ist ein deutscher Satz mit genügend Wörtern." ) ) #expect(detection.code == "de") #expect(detection.confidence > 0.5) } @Test func detectsEnglish() throws { let detection = try #require( detector.detect( "The quick brown fox jumps over the lazy dog. This is an English paragraph with enough words." ) ) #expect(detection.code == "en") #expect(detection.confidence > 0.5) } @Test func emptyTextHasNoDetection() { #expect(detector.detect(" ") == nil) #expect(detector.detect("") == nil) } }