Created
April 1, 2020 08:29
-
-
Save manakuro/587123a01e59588293a52b4b71cd1ccf to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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