update
This commit is contained in:
1 parent
3bfeb6b61e
commit
7537a41955
30 files changed
+1441
-85
No files matched your search
@@ -0,0 +1,39 @@
|
||||
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")
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user