diff options
| author | Paul Buetow <paul@buetow.org> | 2026-04-02 17:21:11 +0300 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-04-02 17:21:11 +0300 |
| commit | 4ccb601df66a6ce6e92ee8146257adbc7d8eece7 (patch) | |
| tree | 4f204c070cc38e245237e6aa3af1dd9ebee003ef /internal/image/prompt_test.go | |
| parent | 6bd23a588bacee2e8c75f477150b7e2d345002ff (diff) | |
Release v0.9.1v0.9.1
Diffstat (limited to 'internal/image/prompt_test.go')
| -rw-r--r-- | internal/image/prompt_test.go | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/internal/image/prompt_test.go b/internal/image/prompt_test.go new file mode 100644 index 0000000..1961ce2 --- /dev/null +++ b/internal/image/prompt_test.go @@ -0,0 +1,48 @@ +package image + +import ( + "strings" + "testing" +) + +func TestPromptSubjectUsesTranslationFirst(t *testing.T) { + if got := promptSubject(" apple ", "ябълка"); got != "apple" { + t.Fatalf("promptSubject() = %q, want %q", got, "apple") + } +} + +func TestPromptSubjectFallsBackToOriginalWord(t *testing.T) { + if got := promptSubject(" ", "ябълка"); got != "ябълка" { + t.Fatalf("promptSubject() = %q, want %q", got, "ябълка") + } +} + +func TestSanitizeSceneDescriptionRemovesLabelsAndFences(t *testing.T) { + scene := "```text\nScene: A bright apple sits centered on a wooden table.\n```" + if got := sanitizeSceneDescription(scene); got != "A bright apple sits centered on a wooden table" { + t.Fatalf("sanitizeSceneDescription() = %q", got) + } +} + +func TestUsableSceneDescriptionRejectsTrivialContent(t *testing.T) { + if usableSceneDescription("A") { + t.Fatal("usableSceneDescription() unexpectedly accepted trivial scene") + } + if usableSceneDescription("A single, perfectly") { + t.Fatal("usableSceneDescription() unexpectedly accepted incomplete scene fragment") + } +} + +func TestFallbackVisualDirectionForPhrase(t *testing.T) { + got := fallbackVisualDirection("to indulge someone") + if got == "" || !usableSceneDescription(got) { + t.Fatalf("fallbackVisualDirection() returned unusable phrase direction: %q", got) + } +} + +func TestFallbackVisualDirectionForSingleWord(t *testing.T) { + got := fallbackVisualDirection("apple") + if got == "" || !strings.Contains(got, "single apple") { + t.Fatalf("fallbackVisualDirection() = %q", got) + } +} |
