package linguistics

import "testing"

func TestLanguageDetector_Detect_EN(t *testing.T) {
	d := NewLanguageDetector()
	lang, err := d.DetectLanguage(" the and is in to of that for the ")
	if err != nil {
		t.Fatalf("DetectLanguage returned error: %v", err)
	}
	if lang != "en" {
		t.Fatalf("expected language 'en', got %q", lang)
	}
}

func TestLanguageDetector_Detect_ES(t *testing.T) {
	d := NewLanguageDetector()
	lang, err := d.DetectLanguage(" el la es en de que por para el ")
	if err != nil {
		t.Fatalf("DetectLanguage returned error: %v", err)
	}
	if lang != "es" {
		t.Fatalf("expected language 'es', got %q", lang)
	}
}

func TestLanguageDetector_Detect_FR(t *testing.T) {
	d := NewLanguageDetector()
	lang, err := d.DetectLanguage(" le la est en de que pour dans le ")
	if err != nil {
		t.Fatalf("DetectLanguage returned error: %v", err)
	}
	if lang != "fr" {
		t.Fatalf("expected language 'fr', got %q", lang)
	}
}

func TestLanguageDetector_Detect_DefaultEnglish(t *testing.T) {
	d := NewLanguageDetector()
	// Balanced/unknown should default to English per implementation
	lang, err := d.DetectLanguage(" lorem ipsum dolor sit amet ")
	if err != nil {
		t.Fatalf("DetectLanguage returned error: %v", err)
	}
	if lang != "en" {
		t.Fatalf("expected default language 'en', got %q", lang)
	}
}
