tercul-backend/internal/enrich/poetic_analyzer_test.go
Damir Mukimov fa336cacf3
wip
2025-09-01 00:43:59 +02:00

33 lines
991 B
Go

package enrich
import "testing"
func TestPoeticAnalyzer_QuatrainABAB(t *testing.T) {
poem := `In silver light we wander far, light
A gentle breeze across the sea, breeze
At quiet dusk we find a star, night
And in the dark we feel the freeze.`
// Last words: light, breeze, night, freeze -> ABAB by last 2 letters (ht, ze, ht, ze)
p := NewPoeticAnalyzer()
m, err := p.Analyse(Text{Body: poem})
if err != nil {
t.Fatalf("Analyse returned error: %v", err)
}
if m.RhymeScheme != "ABAB" {
t.Errorf("expected rhyme scheme ABAB, got %q", m.RhymeScheme)
}
if m.StanzaCount != 1 {
t.Errorf("expected 1 stanza, got %d", m.StanzaCount)
}
if m.LineCount != 4 {
t.Errorf("expected 4 lines, got %d", m.LineCount)
}
if m.Structure != "Quatrain" {
t.Errorf("expected structure Quatrain, got %q", m.Structure)
}
// Meter is heuristic; just ensure it's determined (not Unknown)
if m.MeterType == "Unknown" {
t.Errorf("expected a determined meter type, got %q", m.MeterType)
}
}