feat: add terminal-scoped transaction analytics
This commit is contained in:
@@ -28,3 +28,35 @@ func TestPersianStatus(t *testing.T) {
|
||||
t.Fatalf("persianStatus() = %q", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestOptionalNonNegativeInt64(t *testing.T) {
|
||||
t.Parallel()
|
||||
tests := []struct {
|
||||
name, input string
|
||||
want *int64
|
||||
valid bool
|
||||
}{
|
||||
{name: "omitted", valid: true},
|
||||
{name: "zero", input: "0", want: int64Pointer(0), valid: true},
|
||||
{name: "positive", input: "125000", want: int64Pointer(125000), valid: true},
|
||||
{name: "negative", input: "-1"},
|
||||
{name: "not a number", input: "یک"},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
got, valid := optionalNonNegativeInt64(tt.input)
|
||||
if valid != tt.valid || !equalInt64Pointers(got, tt.want) {
|
||||
t.Fatalf("optionalNonNegativeInt64(%q) = %v,%v, want %v,%v", tt.input, got, valid, tt.want, tt.valid)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func int64Pointer(value int64) *int64 { return &value }
|
||||
|
||||
func equalInt64Pointers(left, right *int64) bool {
|
||||
if left == nil || right == nil {
|
||||
return left == right
|
||||
}
|
||||
return *left == *right
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user