diff options
| author | Paul Buetow <paul@buetow.org> | 2025-11-25 22:40:51 +0200 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2025-11-25 22:40:51 +0200 |
| commit | 488aeb5506e6b4ce34e88ea29cf01971531eb0b6 (patch) | |
| tree | b5d2df0c0de17f36f4a196abb4645e9cddf0b90d /internal/calculator/calculator_test.go | |
| parent | 19df58652909a9c58f99b268fa8c9de23a7e3eca (diff) | |
Add calculation steps to output, bump version to v0.1.0v0.1.0
Amp-Thread-ID: https://ampcode.com/threads/T-3883950c-6af3-4944-8596-7a40341c9c58
Co-authored-by: Amp <amp@ampcode.com>
Diffstat (limited to 'internal/calculator/calculator_test.go')
| -rw-r--r-- | internal/calculator/calculator_test.go | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/internal/calculator/calculator_test.go b/internal/calculator/calculator_test.go index defbd13..2724d71 100644 --- a/internal/calculator/calculator_test.go +++ b/internal/calculator/calculator_test.go @@ -49,8 +49,11 @@ func TestParseXPercentOfY(t *testing.T) { if err != nil { t.Fatalf("Parse(%q) returned error: %v", tt.input, err) } - if result != tt.expected { - t.Errorf("Parse(%q) = %q, expected %q", tt.input, result, tt.expected) + if !strings.HasPrefix(result, tt.expected) { + t.Errorf("Parse(%q) = %q, expected to start with %q", tt.input, result, tt.expected) + } + if !strings.Contains(result, "Steps:") { + t.Errorf("Parse(%q) = %q, expected to contain calculation steps", tt.input, result) } }) } @@ -95,8 +98,11 @@ func TestParseXIsWhatPercentOfY(t *testing.T) { if err != nil { t.Fatalf("Parse(%q) returned error: %v", tt.input, err) } - if result != tt.expected { - t.Errorf("Parse(%q) = %q, expected %q", tt.input, result, tt.expected) + if !strings.HasPrefix(result, tt.expected) { + t.Errorf("Parse(%q) = %q, expected to start with %q", tt.input, result, tt.expected) + } + if !strings.Contains(result, "Steps:") { + t.Errorf("Parse(%q) = %q, expected to contain calculation steps", tt.input, result) } }) } @@ -141,8 +147,11 @@ func TestParseXIsYPercentOfWhat(t *testing.T) { if err != nil { t.Fatalf("Parse(%q) returned error: %v", tt.input, err) } - if result != tt.expected { - t.Errorf("Parse(%q) = %q, expected %q", tt.input, result, tt.expected) + if !strings.HasPrefix(result, tt.expected) { + t.Errorf("Parse(%q) = %q, expected to start with %q", tt.input, result, tt.expected) + } + if !strings.Contains(result, "Steps:") { + t.Errorf("Parse(%q) = %q, expected to contain calculation steps", tt.input, result) } }) } |
