feat(release): beelloo v0.1
This commit is contained in:
52
internal/invoice/quantity_test.go
Normal file
52
internal/invoice/quantity_test.go
Normal file
@ -0,0 +1,52 @@
|
||||
package invoice
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestParseQuantity(t *testing.T) {
|
||||
cases := []struct {
|
||||
input string
|
||||
want Quantity
|
||||
}{
|
||||
{"1", 100},
|
||||
{"0.5", 50},
|
||||
{"2,25", 225},
|
||||
{"10.00", 1000},
|
||||
}
|
||||
for _, tc := range cases {
|
||||
got, err := ParseQuantity(tc.input)
|
||||
if err != nil {
|
||||
t.Fatalf("ParseQuantity(%q) unexpected error: %v", tc.input, err)
|
||||
}
|
||||
if got != tc.want {
|
||||
t.Fatalf("ParseQuantity(%q)=%v want %v", tc.input, got, tc.want)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestFormatQuantity(t *testing.T) {
|
||||
cases := []struct {
|
||||
input Quantity
|
||||
want string
|
||||
}{
|
||||
{100, "1"},
|
||||
{50, "0.5"},
|
||||
{225, "2.25"},
|
||||
{1010, "10.1"},
|
||||
}
|
||||
for _, tc := range cases {
|
||||
got := FormatQuantity(tc.input)
|
||||
if got != tc.want {
|
||||
t.Fatalf("FormatQuantity(%v)=%q want %q", tc.input, got, tc.want)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestLineAmountNegative(t *testing.T) {
|
||||
item := Item{
|
||||
UnitPrice: -29500,
|
||||
Quantity: 100,
|
||||
}
|
||||
if got := LineAmount(item); got != -29500 {
|
||||
t.Fatalf("LineAmount negative mismatch: %v", got)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user