Skip to content

Instantly share code, notes, and snippets.

@manakuro
Created April 1, 2020 08:29
Show Gist options
  • Save manakuro/587123a01e59588293a52b4b71cd1ccf to your computer and use it in GitHub Desktop.
Save manakuro/587123a01e59588293a52b4b71cd1ccf to your computer and use it in GitHub Desktop.
var flagtests = []struct {
in string
out string
}{
{"%a", "[%a]"},
{"%-a", "[%-a]"},
{"%+a", "[%+a]"},
{"%#a", "[%#a]"},
{"% a", "[% a]"},
{"%0a", "[%0a]"},
{"%1.2a", "[%1.2a]"},
{"%-1.2a", "[%-1.2a]"},
{"%+1.2a", "[%+1.2a]"},
{"%-+1.2a", "[%+-1.2a]"},
{"%-+1.2abc", "[%+-1.2a]bc"},
{"%-1.2abc", "[%-1.2a]bc"},
}
func TestFlagParser(t *testing.T) {
var flagprinter flagPrinter
for _, tt := range flagtests {
t.Run(tt.in, func(t *testing.T) {
s := Sprintf(tt.in, &flagprinter)
if s != tt.out {
t.Errorf("got %q, want %q", s, tt.out)
}
})
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment