Skip to content

Commit 4785305

Browse files
committed
nvim: fix parseVersion return type to int64
Signed-off-by: Koichi Shiraishi <[email protected]>
1 parent 36de879 commit 4785305

File tree

1 file changed

+14
-15
lines changed

1 file changed

+14
-15
lines changed

nvim/api_test.go

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -18,35 +18,32 @@ import (
1818
)
1919

2020
type version struct {
21-
Major int
22-
Minor int
23-
Patch int
21+
Major int64
22+
Minor int64
23+
Patch int64
2424
}
2525

26-
var (
27-
channelID int64
28-
nvimVersion version
29-
)
26+
var nvimVersion version
3027

31-
func parseVersion(tb testing.TB, version string) (major, minor, patch int) {
28+
func parseVersion(tb testing.TB, version string) (major, minor, patch int64) {
3229
tb.Helper()
3330

3431
version = strings.TrimPrefix(version, "v")
3532
vpair := strings.Split(version, ".")
3633
if len(vpair) != 3 {
37-
tb.Fatal("could not parse neovim version")
34+
tb.Fatalf("could not parse neovim version: %s", version)
3835
}
3936

4037
var err error
41-
major, err = strconv.Atoi(vpair[0])
38+
major, err = strconv.ParseInt(vpair[0], 10, 0)
4239
if err != nil {
4340
tb.Fatal(err)
4441
}
45-
minor, err = strconv.Atoi(vpair[1])
42+
minor, err = strconv.ParseInt(vpair[1], 10, 0)
4643
if err != nil {
4744
tb.Fatal(err)
4845
}
49-
patch, err = strconv.Atoi(vpair[2])
46+
patch, err = strconv.ParseInt(vpair[2], 10, 0)
5047
if err != nil {
5148
tb.Fatal(err)
5249
}
@@ -72,6 +69,8 @@ func clearBuffer(tb testing.TB, v *Nvim, buffer Buffer) {
7269
}
7370
}
7471

72+
var channelID int64
73+
7574
func TestAPI(t *testing.T) {
7675
t.Parallel()
7776

@@ -96,9 +95,9 @@ func TestAPI(t *testing.T) {
9695
t.Fatalf("apiInfo[1] is not map[string]interface{} type: %T", apiInfo[1])
9796
}
9897
infoV := info["version"].(map[string]interface{})
99-
nvimVersion.Major = int(infoV["major"].(int64))
100-
nvimVersion.Minor = int(infoV["minor"].(int64))
101-
nvimVersion.Patch = int(infoV["patch"].(int64))
98+
nvimVersion.Major = infoV["major"].(int64)
99+
nvimVersion.Minor = infoV["minor"].(int64)
100+
nvimVersion.Patch = infoV["patch"].(int64)
102101

103102
t.Run("BufAttach", testBufAttach(v))
104103
t.Run("APIInfo", testAPIInfo(v))

0 commit comments

Comments
 (0)