| 1 | // Copyright 2018 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 | |
| 5 | package blogscip-go gomod golang.org/x/tools . `golang.org/x/tools/blog`/ |
| 6 | |
| 7 | import ( |
| 8 | "bytesscip-go gomod github.com/golang/go/src go1.25.0 bytes/" |
| 9 | "testingscip-go gomod github.com/golang/go/src go1.25.0 testing/" |
| 10 | ) |
| 11 | |
| 12 | func TestLinkRewritescip-go gomod golang.org/x/tools . `golang.org/x/tools/blog`/TestLinkRewrite().(t *testingscip-go gomod github.com/golang/go/src go1.25.0 testing/.Tscip-go gomod github.com/golang/go/src go1.25.0 testing/T#) { |
| 13 | tests := []struct { |
| 14 | input string |
| 15 | output string |
| 16 | }{ |
| 17 | { |
| 18 | `For instance, the <a href="https://golang.org/pkg/bytes/" target="_blank">bytes package</a> from the standard library exports the <code>Buffer</code> type.`, |
| 19 | `For instance, the <a href="/pkg/bytes/" target="_blank">bytes package</a> from the standard library exports the <code>Buffer</code> type.`}, |
| 20 | { |
| 21 | `(The <a href="https://golang.org/cmd/gofmt/" target="_blank">gofmt command</a> has a <code>-r</code> flag that provides a syntax-aware search and replace, making large-scale refactoring easier.)`, |
| 22 | `(The <a href="/cmd/gofmt/" target="_blank">gofmt command</a> has a <code>-r</code> flag that provides a syntax-aware search and replace, making large-scale refactoring easier.)`, |
| 23 | }, |
| 24 | { |
| 25 | `<a href="//golang.org/LICENSE">BSD license</a>.<br> <a href="//golang.org/doc/tos.html">Terms of Service</a> `, |
| 26 | `<a href="//golang.org/LICENSE">BSD license</a>.<br> <a href="//golang.org/doc/tos.html">Terms of Service</a> `, |
| 27 | }, |
| 28 | { |
| 29 | `For instance, the <code>websocket</code> package from the <code>go.net</code> sub-repository has an import path of <code>"golang.org/x/net/websocket"</code>.`, |
| 30 | `For instance, the <code>websocket</code> package from the <code>go.net</code> sub-repository has an import path of <code>"golang.org/x/net/websocket"</code>.`, |
| 31 | }, |
| 32 | } |
| 33 | for _, test := range tests { |
| 34 | var buf bytesscip-go gomod github.com/golang/go/src go1.25.0 bytes/.Bufferscip-go gomod github.com/golang/go/src go1.25.0 bytes/Buffer# |
| 35 | _, err := golangOrgAbsLinkReplacerscip-go gomod golang.org/x/tools . `golang.org/x/tools/blog`/golangOrgAbsLinkReplacer..WriteStringscip-go gomod github.com/golang/go/src go1.25.0 strings/Replacer#WriteString().(&buf, test.input) |
| 36 | if err != nil { |
| 37 | t.Errorfscip-go gomod github.com/golang/go/src go1.25.0 testing/common#Errorf().("unexpected error during replacing links. Got: %#v, Want: nil.\n", err) |
| 38 | continue |
| 39 | } |
| 40 | if got, want := buf.Stringscip-go gomod github.com/golang/go/src go1.25.0 bytes/Buffer#String().(), test.output; got != want { |
| 41 | t.Errorfscip-go gomod github.com/golang/go/src go1.25.0 testing/common#Errorf().("WriteString(%q) = %q. Expected: %q", test.input, got, want) |
| 42 | } |
| 43 | } |
| 44 | } |