GoPLS Viewer

Home|gopls/present/link_test.go
1// Copyright 2012 The Go Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style
3// license that can be found in the LICENSE file.
4
5package present
6
7import "testing"
8
9func TestInlineParsing(t *testing.T) {
10    var tests = []struct {
11        in     string
12        link   string
13        text   string
14        length int
15    }{
16        {"[[http://golang.org]]""http://golang.org""golang.org"21},
17        {"[[http://golang.org][]]""http://golang.org""http://golang.org"23},
18        {"[[http://golang.org]] this is ignored""http://golang.org""golang.org"21},
19        {"[[http://golang.org][link]]""http://golang.org""link"27},
20        {"[[http://golang.org][two words]]""http://golang.org""two words"32},
21        {"[[http://golang.org][*link*]]""http://golang.org""<b>link</b>"29},
22        {"[[http://bad[url]]"""""0},
23        {"[[http://golang.org][a [[link]] ]]""http://golang.org""a [[link"31},
24        {"[[http:// *spaces* .com]]"""""0},
25        {"[[http://bad`char.com]]"""""0},
26        {" [[http://google.com]]"""""0},
27        {"[[mailto:gopher@golang.org][Gopher]]""mailto:gopher@golang.org""Gopher"36},
28        {"[[mailto:gopher@golang.org]]""mailto:gopher@golang.org""gopher@golang.org"28},
29    }
30
31    for itest := range tests {
32        linklength := parseInlineLink(test.in)
33        if length == 0 && test.length == 0 {
34            continue
35        }
36        if a := renderLink(test.linktest.text); length != test.length || link != a {
37            t.Errorf("#%d: parseInlineLink(%q):\ngot\t%q, %d\nwant\t%q, %d"itest.inlinklengthatest.length)
38        }
39    }
40}
41
MembersX
TestInlineParsing.RangeStmt_1199.BlockStmt.link
TestInlineParsing.RangeStmt_1199.BlockStmt.length
TestInlineParsing.RangeStmt_1199.BlockStmt.a
TestInlineParsing
TestInlineParsing.t
TestInlineParsing.RangeStmt_1199.i
TestInlineParsing.RangeStmt_1199.test
Members
X