mirror of
https://github.com/SamyRai/tercul-backend.git
synced 2025-12-27 05:11:34 +00:00
33 lines
996 B
Go
33 lines
996 B
Go
package linguistics
|
|
|
|
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)
|
|
}
|
|
}
|