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.
16 func TestStaticIsUpToDate(t *testing.T) {
17 if runtime.GOOS == "android" {
18 t.Skip("files not available on android")
20 oldBuf, err := ioutil.ReadFile("static.go")
22 t.Errorf("error while reading static.go: %v\n", err)
25 newBuf, err := Generate()
27 t.Errorf("error while generating static.go: %v\n", err)
30 if !bytes.Equal(oldBuf, newBuf) {
31 t.Error(`static.go is stale. Run:
32 $ go generate golang.org/x/tools/godoc/static
34 to see the differences.`)
39 // TestAppendQuote ensures that AppendQuote produces a valid literal.
40 func TestAppendQuote(t *testing.T) {
41 var in, out bytes.Buffer
42 for r := rune(0); r < unicode.MaxRune; r++ {
45 appendQuote(&out, in.Bytes())
46 in2, err := strconv.Unquote(out.String())
48 t.Fatalf("AppendQuote produced invalid string literal: %v", err)
50 if got, want := in2, in.String(); got != want {
51 t.Fatal("AppendQuote modified string") // no point printing got/want: huge