Example #1
0
func TestFloatFlagWithoutDefaultValue(t *testing.T) {
	flag := cli.Float64Flag{Name: "help", Usage: "Prints floating help topics", OmitDefaultValue: true}
	output := flag.String()
	expected := "--help \tPrints floating help topics"

	if output != expected {
		t.Errorf("expected '%s' to equal '%s", output, expected)
	}
}
Example #2
0
func TestFloat64FlagHelpOutput(t *testing.T) {

	for _, test := range float64FlagTests {
		flag := cli.Float64Flag{Name: test.name}
		output := flag.String()

		if output != test.expected {
			t.Errorf("%s does not match %s", output, test.expected)
		}
	}
}
Example #3
0
func TestFloat64FlagWithEnvVarHelpOutput(t *testing.T) {

	os.Setenv("APP_BAZ", "99.4")
	for _, test := range float64FlagTests {
		flag := cli.Float64Flag{Name: test.name, EnvVar: "APP_BAZ"}
		output := flag.String()

		if !strings.HasSuffix(output, " [$APP_BAZ]") {
			t.Errorf("%s does not end with [$APP_BAZ]", output)
		}
	}
}