X-Git-Url: https://git.josue.xyz/?a=blobdiff_plain;f=.config%2Fcoc%2Fextensions%2Fcoc-go-data%2Ftools%2Fpkg%2Fmod%2Fgolang.org%2Fx%2Ftools%40v0.0.0-20201105173854-bc9fc8d8c4bc%2Fpresent%2Flink_test.go;fp=.config%2Fcoc%2Fextensions%2Fcoc-go-data%2Ftools%2Fpkg%2Fmod%2Fgolang.org%2Fx%2Ftools%40v0.0.0-20201105173854-bc9fc8d8c4bc%2Fpresent%2Flink_test.go;h=334e72bdcc2f15bff8bd2592d14598c88e7c0480;hb=4d07c77cf4d78cab8639e13ddc3c22495e585b0b;hp=0000000000000000000000000000000000000000;hpb=b3950616b54221c40a7dab9099bda675007e5b6e;p=dotfiles%2F.git diff --git a/.config/coc/extensions/coc-go-data/tools/pkg/mod/golang.org/x/tools@v0.0.0-20201105173854-bc9fc8d8c4bc/present/link_test.go b/.config/coc/extensions/coc-go-data/tools/pkg/mod/golang.org/x/tools@v0.0.0-20201105173854-bc9fc8d8c4bc/present/link_test.go new file mode 100644 index 00000000..334e72bd --- /dev/null +++ b/.config/coc/extensions/coc-go-data/tools/pkg/mod/golang.org/x/tools@v0.0.0-20201105173854-bc9fc8d8c4bc/present/link_test.go @@ -0,0 +1,40 @@ +// Copyright 2012 The Go 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 present + +import "testing" + +func TestInlineParsing(t *testing.T) { + var tests = []struct { + in string + link string + text string + length int + }{ + {"[[http://golang.org]]", "http://golang.org", "golang.org", 21}, + {"[[http://golang.org][]]", "http://golang.org", "http://golang.org", 23}, + {"[[http://golang.org]] this is ignored", "http://golang.org", "golang.org", 21}, + {"[[http://golang.org][link]]", "http://golang.org", "link", 27}, + {"[[http://golang.org][two words]]", "http://golang.org", "two words", 32}, + {"[[http://golang.org][*link*]]", "http://golang.org", "link", 29}, + {"[[http://bad[url]]", "", "", 0}, + {"[[http://golang.org][a [[link]] ]]", "http://golang.org", "a [[link", 31}, + {"[[http:// *spaces* .com]]", "", "", 0}, + {"[[http://bad`char.com]]", "", "", 0}, + {" [[http://google.com]]", "", "", 0}, + {"[[mailto:gopher@golang.org][Gopher]]", "mailto:gopher@golang.org", "Gopher", 36}, + {"[[mailto:gopher@golang.org]]", "mailto:gopher@golang.org", "gopher@golang.org", 28}, + } + + for i, test := range tests { + link, length := parseInlineLink(test.in) + if length == 0 && test.length == 0 { + continue + } + if a := renderLink(test.link, test.text); length != test.length || link != a { + t.Errorf("#%d: parseInlineLink(%q):\ngot\t%q, %d\nwant\t%q, %d", i, test.in, link, length, a, test.length) + } + } +}