40 lines
1013 B
Go
40 lines
1013 B
Go
package aiprompts
|
|
|
|
import (
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
func TestDedupeA1DescriptionBlocks(t *testing.T) {
|
|
input := `--- Title ---
|
|
Napiši ime v slovenščini
|
|
--- End Title ---
|
|
--- Description ---
|
|
<H2>{Benefit one}</H2><p>{No title}</p>
|
|
<H2>{Benefit two}</H2><p>{Include title}</p>
|
|
<H2>{Benefit one}</H2><p>{No title}</p>
|
|
<H2>{Benefit two}</H2><p>{Exclude title}</p>
|
|
<H2>{Benefit two}</H2><p>{Include title}</p>
|
|
<b>{Tehnične specifikacije}</b><ul><li>{3-10}</li></ul>
|
|
--- End Description ---
|
|
--- Meta ---
|
|
140 znakov
|
|
--- End Meta ---`
|
|
got, n := DedupeA1DescriptionBlocks(input)
|
|
if n != 2 {
|
|
t.Fatalf("removed=%d want 2", n)
|
|
}
|
|
if strings.Count(got, "<H2>") != 3 {
|
|
t.Fatalf("H2 count changed incorrectly: %s", got)
|
|
}
|
|
for _, want := range []string{"Napiši ime", "140 znakov", "Tehnične specifikacije", "Exclude title"} {
|
|
if !strings.Contains(got, want) {
|
|
t.Fatalf("lost %q", want)
|
|
}
|
|
}
|
|
again, n := DedupeA1DescriptionBlocks(got)
|
|
if n != 0 || again != got {
|
|
t.Fatal("cleanup not idempotent")
|
|
}
|
|
}
|