github.com/btwiuse/jiri@v0.0.0-20191125065820-53353bcfef54/cmdline/help_test.go (about) 1 // Copyright 2015 The Vanadium 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 cmdline 6 7 import "testing" 8 9 func TestGodocHeader(t *testing.T) { 10 tests := []struct { 11 Path, Short, Want string 12 }{ 13 {"", "", ""}, 14 {"path", "", "Path"}, 15 {"", "short", "Short"}, 16 {"path", "short", "Path - short"}, 17 {"path a b c", "short x y z", "Path a b c - short x y z"}, 18 // Try some cases where the short string contains characters that godoc 19 // disallows, so we fall back on just the path. 20 {"path", "bad.", "Path"}, 21 {"path", "bad;", "Path"}, 22 {"path", "bad,", "Path"}, 23 {"path", "(bad)", "Path"}, 24 } 25 for _, test := range tests { 26 if got, want := godocHeader(test.Path, test.Short), test.Want; got != want { 27 t.Errorf("(%q, %q) got %q, want %q", test.Path, test.Short, got, want) 28 } 29 } 30 }