package iace

import "testing"

// Regression: "Bodenroller" (a floor dolly the load sits on) and "Controller"
// must NOT be detected as a rotating mill roller (C009 "Walze"). Before the fix,
// the bare English keyword "roller" matched as a substring inside these German
// compounds and created a bogus Walze component for a crate-lift.
func TestParseNarrative_BodenrollerControllerNotWalze(t *testing.T) {
	cases := []string{
		"Das Kistenhubgeraet hebt Behaelter auf Bodenrollern und Transportwagen.",
		"Beladung wahlweise von Bodenroller 400x600 mm.",
		"Der SPS-Controller steuert den Hubantrieb.",
	}
	for _, text := range cases {
		res := ParseNarrative(text)
		for _, c := range res.Components {
			if c.LibraryID == "C009" {
				t.Errorf("text %q wrongly mapped to C009 (Walze) via %q", text, c.MatchedOn)
			}
		}
	}
}

// The precise German term must still create the roller component.
func TestParseNarrative_WalzeDetectsC009(t *testing.T) {
	res := ParseNarrative("Die Maschine besitzt eine angetriebene Walze zum Kalandrieren.")
	found := false
	for _, c := range res.Components {
		if c.LibraryID == "C009" {
			found = true
		}
	}
	if !found {
		t.Fatal("expected 'Walze' to detect component C009")
	}
}
