Commit 1d748921 authored by Rob Pike's avatar Rob Pike

more casifying fixups

R=rsc
DELTA=213  (0 added, 0 deleted, 213 changed)
OCL=22878
CL=22882
parent 497bb9c0
......@@ -96,125 +96,125 @@ func atob(str string) (value bool, ok bool) {
}
type (
BoolValue struct;
IntValue struct;
Int64Value struct;
UintValue struct;
Uint64Value struct;
StringValue struct;
boolValue struct;
intValue struct;
int64Value struct;
uintValue struct;
uint64Value struct;
stringValue struct;
)
// -- Bool Value
type BoolValue struct {
type boolValue struct {
p *bool;
}
func NewBoolValue(val bool, p *bool) *BoolValue {
func newBoolValue(val bool, p *bool) *boolValue {
*p = val;
return &BoolValue{p}
return &boolValue{p}
}
func (b *BoolValue) Set(val bool) {
func (b *boolValue) set(val bool) {
*b.p = val;
}
func (b *BoolValue) Str() string {
func (b *boolValue) str() string {
return fmt.Sprintf("%v", *b.p)
}
// -- Int Value
type IntValue struct {
type intValue struct {
p *int;
}
func NewIntValue(val int, p *int) *IntValue {
func newIntValue(val int, p *int) *intValue {
*p = val;
return &IntValue{p}
return &intValue{p}
}
func (i *IntValue) Set(val int) {
func (i *intValue) set(val int) {
*i.p = val;
}
func (i *IntValue) Str() string {
func (i *intValue) str() string {
return fmt.Sprintf("%v", *i.p)
}
// -- Int64 Value
type Int64Value struct {
type int64Value struct {
p *int64;
}
func NewInt64Value(val int64, p *int64) *Int64Value {
func newInt64Value(val int64, p *int64) *int64Value {
*p = val;
return &Int64Value{p}
return &int64Value{p}
}
func (i *Int64Value) Set(val int64) {
func (i *int64Value) set(val int64) {
*i.p = val;
}
func (i *Int64Value) Str() string {
func (i *int64Value) str() string {
return fmt.Sprintf("%v", *i.p)
}
// -- Uint Value
type UintValue struct {
type uintValue struct {
p *uint;
}
func NewUintValue(val uint, p *uint) *UintValue {
func newUintValue(val uint, p *uint) *uintValue {
*p = val;
return &UintValue{p}
return &uintValue{p}
}
func (i *UintValue) Set(val uint) {
func (i *uintValue) set(val uint) {
*i.p = val
}
func (i *UintValue) Str() string {
func (i *uintValue) str() string {
return fmt.Sprintf("%v", *i.p)
}
// -- Uint64 Value
type Uint64Value struct {
// -- uint64 Value
type uint64Value struct {
p *uint64;
}
func NewUint64Value(val uint64, p *uint64) *Uint64Value {
func newUint64Value(val uint64, p *uint64) *uint64Value {
*p = val;
return &Uint64Value{p}
return &uint64Value{p}
}
func (i *Uint64Value) Set(val uint64) {
func (i *uint64Value) set(val uint64) {
*i.p = val;
}
func (i *Uint64Value) Str() string {
func (i *uint64Value) str() string {
return fmt.Sprintf("%v", *i.p)
}
// -- String Value
type StringValue struct {
// -- string Value
type stringValue struct {
p *string;
}
func NewStringValue(val string, p *string) *StringValue {
func newStringValue(val string, p *string) *stringValue {
*p = val;
return &StringValue{p}
return &stringValue{p}
}
func (s *StringValue) Set(val string) {
func (s *stringValue) set(val string) {
*s.p = val;
}
func (s *StringValue) Str() string {
func (s *stringValue) str() string {
return fmt.Sprintf("%#q", *s.p)
}
// -- Value interface
type Value interface {
Str() string;
str() string;
}
// -- Flag structure (internal)
......@@ -224,26 +224,26 @@ export type Flag struct {
value Value;
}
type Flags struct {
type allFlags struct {
actual map[string] *Flag;
formal map[string] *Flag;
first_arg int;
}
func New() *Flags {
f := new(Flags);
func New() *allFlags {
f := new(allFlags);
f.first_arg = 1; // 0 is the program name, 1 is first arg
f.actual = make(map[string] *Flag);
f.formal = make(map[string] *Flag);
return f;
}
var flags *Flags = New();
var flags *allFlags = New();
export func PrintDefaults() {
for k, f := range flags.formal {
print(" -", f.name, "=", f.value.Str(), ": ", f.usage, "\n");
print(" -", f.name, "=", f.value.str(), ": ", f.usage, "\n");
}
}
......@@ -273,7 +273,7 @@ export func NArg() int {
return sys.argc() - flags.first_arg
}
func Add(name string, value Value, usage string) {
func add(name string, value Value, usage string) {
f := new(Flag);
f.name = name;
f.usage = usage;
......@@ -288,65 +288,65 @@ func Add(name string, value Value, usage string) {
export func Bool(name string, value bool, usage string) *bool {
p := new(bool);
Add(name, NewBoolValue(value, p), usage);
add(name, newBoolValue(value, p), usage);
return p;
}
export func BoolVar(p *bool, name string, value bool, usage string) {
Add(name, NewBoolValue(value, p), usage);
add(name, newBoolValue(value, p), usage);
}
export func Int(name string, value int, usage string) *int {
p := new(int);
Add(name, NewIntValue(value, p), usage);
add(name, newIntValue(value, p), usage);
return p;
}
export func IntVar(p *int, name string, value int, usage string) {
Add(name, NewIntValue(value, p), usage);
add(name, newIntValue(value, p), usage);
}
export func Int64(name string, value int64, usage string) *int64 {
p := new(int64);
Add(name, NewInt64Value(value, p), usage);
add(name, newInt64Value(value, p), usage);
return p;
}
export func Int64Var(p *int64, name string, value int64, usage string) {
Add(name, NewInt64Value(value, p), usage);
add(name, newInt64Value(value, p), usage);
}
export func Uint(name string, value uint, usage string) *uint {
p := new(uint);
Add(name, NewUintValue(value, p), usage);
add(name, newUintValue(value, p), usage);
return p;
}
export func UintVar(p *uint, name string, value uint, usage string) {
Add(name, NewUintValue(value, p), usage);
add(name, newUintValue(value, p), usage);
}
export func Uint64(name string, value uint64, usage string) *uint64 {
p := new(uint64);
Add(name, NewUint64Value(value, p), usage);
add(name, newUint64Value(value, p), usage);
return p;
}
export func Uint64Var(p *uint64, name string, value uint64, usage string) {
Add(name, NewUint64Value(value, p), usage);
add(name, newUint64Value(value, p), usage);
}
export func String(name, value string, usage string) *string {
p := new(string);
Add(name, NewStringValue(value, p), usage);
add(name, newStringValue(value, p), usage);
return p;
}
export func StringVar(p *string, name, value string, usage string) {
Add(name, NewStringValue(value, p), usage);
add(name, newStringValue(value, p), usage);
}
func (f *Flags) ParseOne(index int) (ok bool, next int)
func (f *allFlags) ParseOne(index int) (ok bool, next int)
{
s := sys.argv(index);
f.first_arg = index; // until proven otherwise
......@@ -394,16 +394,16 @@ func (f *Flags) ParseOne(index int) (ok bool, next int)
print("flag provided but not defined: -", name, "\n");
Usage();
}
if f, ok := flag.value.(*BoolValue); ok {
if f, ok := flag.value.(*boolValue); ok {
if has_value {
k, ok := atob(value);
if !ok {
print("invalid boolean value ", value, " for flag: -", name, "\n");
Usage();
}
f.Set(k)
f.set(k)
} else {
f.Set(true)
f.set(true)
}
} else {
// It must have a value, which might be the next argument.
......@@ -417,8 +417,8 @@ func (f *Flags) ParseOne(index int) (ok bool, next int)
print("flag needs an argument: -", name, "\n");
Usage();
}
if f, ok := flag.value.(*StringValue); ok {
f.Set(value)
if f, ok := flag.value.(*stringValue); ok {
f.set(value)
} else {
// It's an integer flag. TODO(r): check for overflow?
k, ok := atoi(value);
......@@ -426,14 +426,14 @@ func (f *Flags) ParseOne(index int) (ok bool, next int)
print("invalid integer value ", value, " for flag: -", name, "\n");
Usage();
}
if f, ok := flag.value.(*IntValue); ok {
f.Set(int(k));
} else if f, ok := flag.value.(*Int64Value); ok {
f.Set(k);
} else if f, ok := flag.value.(*UintValue); ok {
f.Set(uint(k));
} else if f, ok := flag.value.(*Uint64Value); ok {
f.Set(uint64(k));
if f, ok := flag.value.(*intValue); ok {
f.set(int(k));
} else if f, ok := flag.value.(*int64Value); ok {
f.set(k);
} else if f, ok := flag.value.(*uintValue); ok {
f.set(uint(k));
} else if f, ok := flag.value.(*uint64Value); ok {
f.set(uint64(k));
}
}
}
......
......@@ -20,134 +20,134 @@ export func TestFmtInterface(t *testing.T) {
}
}
type FmtTest struct {
type fmtTest struct {
fmt string;
val interface { };
out string;
}
const B32 uint32 = 1<<32 - 1
const B64 uint64 = 1<<64 - 1
const b32 uint32 = 1<<32 - 1
const b64 uint64 = 1<<64 - 1
var array = []int{1, 2, 3, 4, 5}
var fmttests = []FmtTest{
var fmttests = []fmtTest{
// basic string
FmtTest{ "%s", "abc", "abc" },
FmtTest{ "%x", "abc", "616263" },
FmtTest{ "%x", "xyz", "78797a" },
FmtTest{ "%X", "xyz", "78797A" },
FmtTest{ "%q", "abc", `"abc"` },
fmtTest{ "%s", "abc", "abc" },
fmtTest{ "%x", "abc", "616263" },
fmtTest{ "%x", "xyz", "78797a" },
fmtTest{ "%X", "xyz", "78797A" },
fmtTest{ "%q", "abc", `"abc"` },
// basic bytes
FmtTest{ "%s", io.StringBytes("abc"), "abc" },
FmtTest{ "%x", io.StringBytes("abc"), "616263" },
FmtTest{ "% x", io.StringBytes("abc"), "61 62 63" },
FmtTest{ "%x", io.StringBytes("xyz"), "78797a" },
FmtTest{ "%X", io.StringBytes("xyz"), "78797A" },
FmtTest{ "%q", io.StringBytes("abc"), `"abc"` },
fmtTest{ "%s", io.StringBytes("abc"), "abc" },
fmtTest{ "%x", io.StringBytes("abc"), "616263" },
fmtTest{ "% x", io.StringBytes("abc"), "61 62 63" },
fmtTest{ "%x", io.StringBytes("xyz"), "78797a" },
fmtTest{ "%X", io.StringBytes("xyz"), "78797A" },
fmtTest{ "%q", io.StringBytes("abc"), `"abc"` },
// escaped strings
FmtTest{ "%#q", `abc`, "`abc`" },
FmtTest{ "%#q", `"`, "`\"`" },
FmtTest{ "1 %#q", `\n`, "1 `\\n`" },
FmtTest{ "2 %#q", "\n", `2 "\n"` },
FmtTest{ "%q", `"`, `"\""` },
FmtTest{ "%q", "\a\b\f\r\n\t\v", `"\a\b\f\r\n\t\v"` },
FmtTest{ "%q", "abc\xffdef", `"abc\xffdef"` },
FmtTest{ "%q", "\u263a", `"\u263a"` },
FmtTest{ "%q", "\U0010ffff", `"\U0010ffff"` },
fmtTest{ "%#q", `abc`, "`abc`" },
fmtTest{ "%#q", `"`, "`\"`" },
fmtTest{ "1 %#q", `\n`, "1 `\\n`" },
fmtTest{ "2 %#q", "\n", `2 "\n"` },
fmtTest{ "%q", `"`, `"\""` },
fmtTest{ "%q", "\a\b\f\r\n\t\v", `"\a\b\f\r\n\t\v"` },
fmtTest{ "%q", "abc\xffdef", `"abc\xffdef"` },
fmtTest{ "%q", "\u263a", `"\u263a"` },
fmtTest{ "%q", "\U0010ffff", `"\U0010ffff"` },
// width
FmtTest{ "%5s", "abc", " abc" },
FmtTest{ "%-5s", "abc", "abc " },
FmtTest{ "%05s", "abc", "00abc" },
fmtTest{ "%5s", "abc", " abc" },
fmtTest{ "%-5s", "abc", "abc " },
fmtTest{ "%05s", "abc", "00abc" },
// integers
FmtTest{ "%d", 12345, "12345" },
FmtTest{ "%d", -12345, "-12345" },
FmtTest{ "%10d", 12345, " 12345" },
FmtTest{ "%10d", -12345, " -12345" },
FmtTest{ "%+10d", 12345, " +12345" },
FmtTest{ "%010d", 12345, "0000012345" },
FmtTest{ "%010d", -12345, "-000012345" },
FmtTest{ "%-10d", 12345, "12345 " },
FmtTest{ "%010.3d", 1, " 001" },
FmtTest{ "%010.3d", -1, " -001" },
FmtTest{ "%+d", 12345, "+12345" },
FmtTest{ "%+d", -12345, "-12345" },
FmtTest{ "% d", 12345, " 12345" },
FmtTest{ "% d", -12345, "-12345" },
fmtTest{ "%d", 12345, "12345" },
fmtTest{ "%d", -12345, "-12345" },
fmtTest{ "%10d", 12345, " 12345" },
fmtTest{ "%10d", -12345, " -12345" },
fmtTest{ "%+10d", 12345, " +12345" },
fmtTest{ "%010d", 12345, "0000012345" },
fmtTest{ "%010d", -12345, "-000012345" },
fmtTest{ "%-10d", 12345, "12345 " },
fmtTest{ "%010.3d", 1, " 001" },
fmtTest{ "%010.3d", -1, " -001" },
fmtTest{ "%+d", 12345, "+12345" },
fmtTest{ "%+d", -12345, "-12345" },
fmtTest{ "% d", 12345, " 12345" },
fmtTest{ "% d", -12345, "-12345" },
// arrays
// TODO: when arrays work in interfaces, enable this line
// and delete the TestArrayPrinter routine below
// FmtTest{ "%v", array, "[1 2 3 4 5]" },
FmtTest{ "%v", &array, "&[1 2 3 4 5]" },
// fmtTest{ "%v", array, "[1 2 3 4 5]" },
fmtTest{ "%v", &array, "&[1 2 3 4 5]" },
// old test/fmt_test.go
FmtTest{ "%d", 1234, "1234" },
FmtTest{ "%d", -1234, "-1234" },
FmtTest{ "%d", uint(1234), "1234" },
FmtTest{ "%d", uint32(B32), "4294967295" },
FmtTest{ "%d", uint64(B64), "18446744073709551615" },
FmtTest{ "%o", 01234, "1234" },
FmtTest{ "%o", uint32(B32), "37777777777" },
FmtTest{ "%o", uint64(B64), "1777777777777777777777" },
FmtTest{ "%x", 0x1234abcd, "1234abcd" },
FmtTest{ "%x", B32-0x1234567, "fedcba98" },
FmtTest{ "%X", 0x1234abcd, "1234ABCD" },
FmtTest{ "%X", B32-0x1234567, "FEDCBA98" },
FmtTest{ "%x", B64, "ffffffffffffffff" },
FmtTest{ "%b", 7, "111" },
FmtTest{ "%b", B64, "1111111111111111111111111111111111111111111111111111111111111111" },
FmtTest{ "%e", float64(1), "1.000000e+00" },
FmtTest{ "%e", float64(1234.5678e3), "1.234568e+06" },
FmtTest{ "%e", float64(1234.5678e-8), "1.234568e-05" },
FmtTest{ "%e", float64(-7), "-7.000000e+00" },
FmtTest{ "%e", float64(-1e-9), "-1.000000e-09" },
FmtTest{ "%f", float64(1234.5678e3), "1234567.800000" },
FmtTest{ "%f", float64(1234.5678e-8), "0.000012" },
FmtTest{ "%f", float64(-7), "-7.000000" },
FmtTest{ "%f", float64(-1e-9), "-0.000000" },
FmtTest{ "%g", float64(1234.5678e3), "1.2345678e+06" },
FmtTest{ "%g", float32(1234.5678e3), "1.2345678e+06" },
FmtTest{ "%g", float64(1234.5678e-8), "1.2345678e-05" },
FmtTest{ "%g", float64(-7), "-7" },
FmtTest{ "%g", float64(-1e-9), "-1e-09", },
FmtTest{ "%g", float32(-1e-9), "-1e-09" },
FmtTest{ "%c", 'x', "x" },
FmtTest{ "%c", 0xe4, "ä" },
FmtTest{ "%c", 0x672c, "本" },
FmtTest{ "%c", '日', "日" },
FmtTest{ "%20.8d", 1234, " 00001234" },
FmtTest{ "%20.8d", -1234, " -00001234" },
FmtTest{ "%20d", 1234, " 1234" },
FmtTest{ "%-20.8d", 1234, "00001234 " },
FmtTest{ "%-20.8d", -1234, "-00001234 " },
FmtTest{ "%.20b", 7, "00000000000000000111" },
FmtTest{ "%20.5s", "qwertyuiop", " qwert" },
FmtTest{ "%.5s", "qwertyuiop", "qwert" },
FmtTest{ "%-20.5s", "qwertyuiop", "qwert " },
FmtTest{ "%20c", 'x', " x" },
FmtTest{ "%-20c", 'x', "x " },
FmtTest{ "%20.6e", 1.2345e3, " 1.234500e+03" },
FmtTest{ "%20.6e", 1.2345e-3, " 1.234500e-03" },
FmtTest{ "%20e", 1.2345e3, " 1.234500e+03" },
FmtTest{ "%20e", 1.2345e-3, " 1.234500e-03" },
FmtTest{ "%20.8e", 1.2345e3, " 1.23450000e+03" },
FmtTest{ "%20f", float64(1.23456789e3), " 1234.567890" },
FmtTest{ "%20f", float64(1.23456789e-3), " 0.001235" },
FmtTest{ "%20f", float64(12345678901.23456789), " 12345678901.234568" },
FmtTest{ "%-20f", float64(1.23456789e3), "1234.567890 " },
FmtTest{ "%20.8f", float64(1.23456789e3), " 1234.56789000" },
FmtTest{ "%20.8f", float64(1.23456789e-3), " 0.00123457" },
FmtTest{ "%g", float64(1.23456789e3), "1234.56789" },
FmtTest{ "%g", float64(1.23456789e-3), "0.00123456789" },
FmtTest{ "%g", float64(1.23456789e20), "1.23456789e+20" },
FmtTest{ "%20e", sys.Inf(1), " +Inf" },
FmtTest{ "%-20f", sys.Inf(-1), "-Inf " },
FmtTest{ "%20g", sys.NaN(), " NaN" },
fmtTest{ "%d", 1234, "1234" },
fmtTest{ "%d", -1234, "-1234" },
fmtTest{ "%d", uint(1234), "1234" },
fmtTest{ "%d", uint32(b32), "4294967295" },
fmtTest{ "%d", uint64(b64), "18446744073709551615" },
fmtTest{ "%o", 01234, "1234" },
fmtTest{ "%o", uint32(b32), "37777777777" },
fmtTest{ "%o", uint64(b64), "1777777777777777777777" },
fmtTest{ "%x", 0x1234abcd, "1234abcd" },
fmtTest{ "%x", b32-0x1234567, "fedcba98" },
fmtTest{ "%X", 0x1234abcd, "1234ABCD" },
fmtTest{ "%X", b32-0x1234567, "FEDCBA98" },
fmtTest{ "%x", b64, "ffffffffffffffff" },
fmtTest{ "%b", 7, "111" },
fmtTest{ "%b", b64, "1111111111111111111111111111111111111111111111111111111111111111" },
fmtTest{ "%e", float64(1), "1.000000e+00" },
fmtTest{ "%e", float64(1234.5678e3), "1.234568e+06" },
fmtTest{ "%e", float64(1234.5678e-8), "1.234568e-05" },
fmtTest{ "%e", float64(-7), "-7.000000e+00" },
fmtTest{ "%e", float64(-1e-9), "-1.000000e-09" },
fmtTest{ "%f", float64(1234.5678e3), "1234567.800000" },
fmtTest{ "%f", float64(1234.5678e-8), "0.000012" },
fmtTest{ "%f", float64(-7), "-7.000000" },
fmtTest{ "%f", float64(-1e-9), "-0.000000" },
fmtTest{ "%g", float64(1234.5678e3), "1.2345678e+06" },
fmtTest{ "%g", float32(1234.5678e3), "1.2345678e+06" },
fmtTest{ "%g", float64(1234.5678e-8), "1.2345678e-05" },
fmtTest{ "%g", float64(-7), "-7" },
fmtTest{ "%g", float64(-1e-9), "-1e-09", },
fmtTest{ "%g", float32(-1e-9), "-1e-09" },
fmtTest{ "%c", 'x', "x" },
fmtTest{ "%c", 0xe4, "ä" },
fmtTest{ "%c", 0x672c, "本" },
fmtTest{ "%c", '日', "日" },
fmtTest{ "%20.8d", 1234, " 00001234" },
fmtTest{ "%20.8d", -1234, " -00001234" },
fmtTest{ "%20d", 1234, " 1234" },
fmtTest{ "%-20.8d", 1234, "00001234 " },
fmtTest{ "%-20.8d", -1234, "-00001234 " },
fmtTest{ "%.20b", 7, "00000000000000000111" },
fmtTest{ "%20.5s", "qwertyuiop", " qwert" },
fmtTest{ "%.5s", "qwertyuiop", "qwert" },
fmtTest{ "%-20.5s", "qwertyuiop", "qwert " },
fmtTest{ "%20c", 'x', " x" },
fmtTest{ "%-20c", 'x', "x " },
fmtTest{ "%20.6e", 1.2345e3, " 1.234500e+03" },
fmtTest{ "%20.6e", 1.2345e-3, " 1.234500e-03" },
fmtTest{ "%20e", 1.2345e3, " 1.234500e+03" },
fmtTest{ "%20e", 1.2345e-3, " 1.234500e-03" },
fmtTest{ "%20.8e", 1.2345e3, " 1.23450000e+03" },
fmtTest{ "%20f", float64(1.23456789e3), " 1234.567890" },
fmtTest{ "%20f", float64(1.23456789e-3), " 0.001235" },
fmtTest{ "%20f", float64(12345678901.23456789), " 12345678901.234568" },
fmtTest{ "%-20f", float64(1.23456789e3), "1234.567890 " },
fmtTest{ "%20.8f", float64(1.23456789e3), " 1234.56789000" },
fmtTest{ "%20.8f", float64(1.23456789e-3), " 0.00123457" },
fmtTest{ "%g", float64(1.23456789e3), "1234.56789" },
fmtTest{ "%g", float64(1.23456789e-3), "0.00123456789" },
fmtTest{ "%g", float64(1.23456789e20), "1.23456789e+20" },
fmtTest{ "%20e", sys.Inf(1), " +Inf" },
fmtTest{ "%-20f", sys.Inf(-1), "-Inf " },
fmtTest{ "%20g", sys.NaN(), " NaN" },
}
export func TestSprintf(t *testing.T) {
......@@ -166,8 +166,8 @@ export func TestSprintf(t *testing.T) {
}
}
type FlagPrinter struct { }
func (*FlagPrinter) Format(f fmt.Formatter, c int) {
type flagPrinter struct { }
func (*flagPrinter) Format(f fmt.Formatter, c int) {
s := "%";
for i := 0; i < 128; i++ {
if f.Flag(i) {
......@@ -184,28 +184,28 @@ func (*FlagPrinter) Format(f fmt.Formatter, c int) {
io.WriteString(f, "["+s+"]");
}
type FlagTest struct {
type flagTest struct {
in string;
out string;
}
var flagtests = []FlagTest {
FlagTest{ "%a", "[%a]" },
FlagTest{ "%-a", "[%-a]" },
FlagTest{ "%+a", "[%+a]" },
FlagTest{ "%#a", "[%#a]" },
FlagTest{ "% a", "[% a]" },
FlagTest{ "%0a", "[%0a]" },
FlagTest{ "%1.2a", "[%1.2a]" },
FlagTest{ "%-1.2a", "[%-1.2a]" },
FlagTest{ "%+1.2a", "[%+1.2a]" },
FlagTest{ "%-+1.2a", "[%+-1.2a]" },
FlagTest{ "%-+1.2abc", "[%+-1.2a]bc" },
FlagTest{ "%-1.2abc", "[%-1.2a]bc" },
var flagtests = []flagTest {
flagTest{ "%a", "[%a]" },
flagTest{ "%-a", "[%-a]" },
flagTest{ "%+a", "[%+a]" },
flagTest{ "%#a", "[%#a]" },
flagTest{ "% a", "[% a]" },
flagTest{ "%0a", "[%0a]" },
flagTest{ "%1.2a", "[%1.2a]" },
flagTest{ "%-1.2a", "[%-1.2a]" },
flagTest{ "%+1.2a", "[%+1.2a]" },
flagTest{ "%-+1.2a", "[%+-1.2a]" },
flagTest{ "%-+1.2abc", "[%+-1.2a]bc" },
flagTest{ "%-1.2abc", "[%-1.2a]bc" },
}
export func TestFlagParser(t *testing.T) {
var flagprinter FlagPrinter;
var flagprinter flagPrinter;
for i := 0; i < len(flagtests); i++ {
tt := flagtests[i];
s := fmt.Sprintf(tt.in, &flagprinter);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment