1
0
Fork 0
mirror of https://github.com/laravel-ls/uri synced 2026-06-16 01:54:57 +02:00

uri: add testcases

This commit is contained in:
Koichi Shiraishi 2019-05-03 03:28:36 +09:00
parent 88ccdf9cf8
commit 3d84710c37
No known key found for this signature in database
GPG key ID: A71DFD3B4DA7A79B

71
uri_test.go Normal file
View file

@ -0,0 +1,71 @@
// Copyright 2019 The uri Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package uri_test
import (
"path/filepath"
"testing"
"github.com/google/go-cmp/cmp"
"github.com/go-language-server/uri"
)
func TestParse(t *testing.T) {
tests := []struct {
name string
uri string
want *uri.URI
}{
{
name: "Valid",
uri: "https://code.visualstudio.com/docs/extensions/overview#frag",
want: &uri.URI{
Scheme: "https",
Authority: "code.visualstudio.com",
Path: "/docs/extensions/overview",
Fragment: "frag",
},
},
}
for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) {
t.Parallel()
if diff := cmp.Diff(uri.Parse(tt.uri), tt.want); diff != "" {
t.Errorf("%s: (-got, +want)\n%s", tt.name, diff)
}
})
}
}
func TestFile(t *testing.T) {
tests := []struct {
name string
path string
want *uri.URI
}{
{
name: "Valid",
path: "/users/me/c#-projects/",
want: &uri.URI{
Scheme: uri.FileScheme,
Path: "/users/me/c#-projects/",
FsPath: filepath.FromSlash("/users/me/c#-projects/"),
},
},
}
for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) {
t.Parallel()
if diff := cmp.Diff(uri.File(tt.path), tt.want); diff != "" {
t.Errorf("%s: (-got, +want)\n%s", tt.name, diff)
}
})
}
}