// Copyright 2018 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 blog import ( "bytes" "testing" ) func TestLinkRewrite(t *testing.T) { tests := []struct { input string output string }{ { `For instance, the bytes package from the standard library exports the Buffer type.`, `For instance, the bytes package from the standard library exports the Buffer type.`}, { `(The gofmt command has a -r flag that provides a syntax-aware search and replace, making large-scale refactoring easier.)`, `(The gofmt command has a -r flag that provides a syntax-aware search and replace, making large-scale refactoring easier.)`, }, { `BSD license.
Terms of Service `, `BSD license.
Terms of Service `, }, { `For instance, the websocket package from the go.net sub-repository has an import path of "golang.org/x/net/websocket".`, `For instance, the websocket package from the go.net sub-repository has an import path of "golang.org/x/net/websocket".`, }, } for _, test := range tests { var buf bytes.Buffer _, err := golangOrgAbsLinkReplacer.WriteString(&buf, test.input) if err != nil { t.Errorf("unexpected error during replacing links. Got: %#v, Want: nil.\n", err) continue } if got, want := buf.String(), test.output; got != want { t.Errorf("WriteString(%q) = %q. Expected: %q", test.input, got, want) } } }