Go stringified sheet cells with fmt.Sprint, so a numeric VS read with UNFORMATTED_VALUE was rendered as 2.609767878e+09. Text columns of the payments sheet now go through sheets.CellString, which never uses exponent form; bank inference uses the same helper. Both sync implementations now append VS as a text cell so Sheets keeps it a string and leading zeros survive. Existing rows are not rewritten. Python already read VS as a digit string; a regression test pins that. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
37 lines
859 B
Go
37 lines
859 B
Go
package sheets
|
|
|
|
import "testing"
|
|
|
|
func TestTextCell(t *testing.T) {
|
|
if got := TextCell("0308"); got != "'0308" {
|
|
t.Errorf(`TextCell("0308"): got %q`, got)
|
|
}
|
|
if got := TextCell(""); got != "" {
|
|
t.Errorf(`TextCell(""): got %q`, got)
|
|
}
|
|
}
|
|
|
|
func TestCellString(t *testing.T) {
|
|
cases := []struct {
|
|
name string
|
|
in any
|
|
want string
|
|
}{
|
|
{"nil", nil, ""},
|
|
{"string", "fee", "fee"},
|
|
{"string with leading zeros", "0308", "0308"},
|
|
{"small integer float", 123.0, "123"},
|
|
{"large integer float", 2609767878.0, "2609767878"},
|
|
{"eleven digit float", 26123456789.0, "26123456789"},
|
|
{"fractional float", 12.5, "12.5"},
|
|
{"bool", true, "true"},
|
|
}
|
|
for _, tc := range cases {
|
|
t.Run(tc.name, func(t *testing.T) {
|
|
if got := CellString(tc.in); got != tc.want {
|
|
t.Errorf("CellString(%v): want %q, got %q", tc.in, tc.want, got)
|
|
}
|
|
})
|
|
}
|
|
}
|