diff options
| author | Shulhan <ms@kilabit.info> | 2021-03-14 22:37:59 +0700 |
|---|---|---|
| committer | Shulhan <ms@kilabit.info> | 2021-03-14 22:40:05 +0700 |
| commit | e7552ad0189f761875bc1c2ca3dd716d43a01e0d (patch) | |
| tree | fd68ec29d23fb9a807a7382088020e3b17d446fd /lib/ini | |
| parent | 882727d89c8e7f9b9761009ccdca1af8c18d0a30 (diff) | |
| download | pakakeh.go-e7552ad0189f761875bc1c2ca3dd716d43a01e0d.tar.xz | |
all: refactoring the test.Assert and test.AssertBench signature
Previously, the test.Assert and test.AssertBench functions has the
boolean parameter to print the stack trace of test in case its not equal.
Since this parameter is not mandatory and its usually always set to
"true", we remove them from function signature to simplify the call
to Assert and AssertBench.
Diffstat (limited to 'lib/ini')
| -rw-r--r-- | lib/ini/common_test.go | 2 | ||||
| -rw-r--r-- | lib/ini/ini_test.go | 34 | ||||
| -rw-r--r-- | lib/ini/ini_unmarshal_test.go | 8 | ||||
| -rw-r--r-- | lib/ini/reader_test.go | 42 | ||||
| -rw-r--r-- | lib/ini/section_test.go | 24 | ||||
| -rw-r--r-- | lib/ini/tag_struct_field_test.go | 4 | ||||
| -rw-r--r-- | lib/ini/variable_test.go | 4 |
7 files changed, 59 insertions, 59 deletions
diff --git a/lib/ini/common_test.go b/lib/ini/common_test.go index 7e5059b8..09dd33ee 100644 --- a/lib/ini/common_test.go +++ b/lib/ini/common_test.go @@ -48,6 +48,6 @@ func TestIsValueBoolTrue(t *testing.T) { got := IsValueBoolTrue(c.v) - test.Assert(t, "", c.exp, got, true) + test.Assert(t, "", c.exp, got) } } diff --git a/lib/ini/ini_test.go b/lib/ini/ini_test.go index 3b543080..16b7d4d3 100644 --- a/lib/ini/ini_test.go +++ b/lib/ini/ini_test.go @@ -56,7 +56,7 @@ func TestOpen(t *testing.T) { _, err := Open(c.inFile) if err != nil { - test.Assert(t, "error", c.expErr, err.Error(), true) + test.Assert(t, "error", c.expErr, err.Error()) continue } } @@ -90,13 +90,13 @@ func TestSave(t *testing.T) { cfg, err := Open(c.inFile) if err != nil { - test.Assert(t, "error", c.expErr, err.Error(), true) + test.Assert(t, "error", c.expErr, err.Error()) continue } err = cfg.Save(c.outFile) if err != nil { - test.Assert(t, "error", c.expErr, err.Error(), true) + test.Assert(t, "error", c.expErr, err.Error()) } } } @@ -132,7 +132,7 @@ func TestAddSection(t *testing.T) { in.addSection(c.sec) - test.Assert(t, "ini", c.expIni, in, true) + test.Assert(t, "ini", c.expIni, in) } } @@ -193,11 +193,11 @@ func TestGet(t *testing.T) { got, ok = inputIni.Get(c.sec, c.sub, c.key, "") if !ok { - test.Assert(t, "ok", c.expOk, ok, true) + test.Assert(t, "ok", c.expOk, ok) continue } - test.Assert(t, "value", c.expVal, got, true) + test.Assert(t, "value", c.expVal, got) } } @@ -234,7 +234,7 @@ func TestGetDefault(t *testing.T) { got, _ := cfg.Get(c.sec, c.sub, c.key, c.def) - test.Assert(t, "string", c.exp, got, true) + test.Assert(t, "string", c.exp, got) } } @@ -449,11 +449,11 @@ func TestGetInputIni(t *testing.T) { got, ok = inputIni.Get(c.sec, c.sub, k, "") if !ok { t.Logf("Get: %s > %s > %s", c.sec, c.sub, k) - test.Assert(t, "ok", true, ok, true) + test.Assert(t, "ok", true, ok) t.FailNow() } - test.Assert(t, "value", c.expVals[x], got, true) + test.Assert(t, "value", c.expVals[x], got) } } } @@ -500,11 +500,11 @@ func TestGetSectionDup(t *testing.T) { got, ok := cfg.Get(c.sec, c.sub, k, "") if !ok { - test.Assert(t, "ok", c.expOK[x], ok, true) + test.Assert(t, "ok", c.expOK[x], ok) continue } - test.Assert(t, k, c.expVals[x], got, true) + test.Assert(t, k, c.expVals[x], got) } } } @@ -559,11 +559,11 @@ func TestGetVarMultiEmpty(t *testing.T) { got, ok := cfg.Get(c.sec, c.sub, k, "") if !ok { - test.Assert(t, "ok", c.expOK[x], ok, true) + test.Assert(t, "ok", c.expOK[x], ok) continue } - test.Assert(t, k, c.expVals[x], got, true) + test.Assert(t, k, c.expVals[x], got) } } } @@ -615,11 +615,11 @@ func TestGetVarMultiSection(t *testing.T) { got, ok := cfg.Get(c.sec, c.sub, k, "") if !ok { - test.Assert(t, "ok", c.expOK[x], ok, true) + test.Assert(t, "ok", c.expOK[x], ok) continue } - test.Assert(t, k, c.expVals[x], got, true) + test.Assert(t, k, c.expVals[x], got) } } } @@ -651,7 +651,7 @@ xx = 4 t.Fatal(err) } - test.Assert(t, "TestMarshal_embedded", exp, string(got), true) + test.Assert(t, "TestMarshal_embedded", exp, string(got)) } func TestUnmarshal_embedded(t *testing.T) { @@ -680,5 +680,5 @@ xx = 4 t.Fatal(err) } - test.Assert(t, "TestUnmarshal_embedded", exp, got, true) + test.Assert(t, "TestUnmarshal_embedded", exp, got) } diff --git a/lib/ini/ini_unmarshal_test.go b/lib/ini/ini_unmarshal_test.go index e64d68dd..abfdaecd 100644 --- a/lib/ini/ini_unmarshal_test.go +++ b/lib/ini/ini_unmarshal_test.go @@ -119,7 +119,7 @@ time = 2021-02-28 00:12:05 PtrTime: &ptrTime, } - test.Assert(t, "Unmarshal", exp, got, true) + test.Assert(t, "Unmarshal", exp, got) } func TestIni_Unmarshal_sliceOfStruct(t *testing.T) { @@ -149,7 +149,7 @@ int = 2 }}, } - test.Assert(t, "Unmarshal slice of struct", exp, got, true) + test.Assert(t, "Unmarshal slice of struct", exp, got) } func TestIni_Unmarshal_sliceOfPrimitive(t *testing.T) { @@ -191,7 +191,7 @@ time = 2021-02-28 03:56:02 }, } - test.Assert(t, "Unmarshal slice of primitive", exp, got, true) + test.Assert(t, "Unmarshal slice of primitive", exp, got) } func TestIni_Unmarshal_sliceOfPointer(t *testing.T) { @@ -250,5 +250,5 @@ time = 2021-02-28 03:56:02 SlicePtrTime: []*time.Time{&time0, &time1}, } - test.Assert(t, "Unmarshal slice of pointer", exp, got, true) + test.Assert(t, "Unmarshal slice of pointer", exp, got) } diff --git a/lib/ini/reader_test.go b/lib/ini/reader_test.go index d79e56f8..e1d3a4e4 100644 --- a/lib/ini/reader_test.go +++ b/lib/ini/reader_test.go @@ -108,17 +108,17 @@ func TestParseSectionHeader(t *testing.T) { err := reader.parseSectionHeader() if err != nil { - test.Assert(t, "error", c.expErr, err, true) + test.Assert(t, "error", c.expErr, err) if err != io.EOF { continue } } - test.Assert(t, "mode", c.expMode, reader._var.mode, true) - test.Assert(t, "format", c.expFormat, reader._var.format, true) - test.Assert(t, "section", c.expSecName, reader._var.secName, true) - test.Assert(t, "subsection", c.expSubName, reader._var.subName, true) - test.Assert(t, "comment", c.expComment, reader._var.others, true) + test.Assert(t, "mode", c.expMode, reader._var.mode) + test.Assert(t, "format", c.expFormat, reader._var.format) + test.Assert(t, "section", c.expSecName, reader._var.secName) + test.Assert(t, "subsection", c.expSubName, reader._var.subName) + test.Assert(t, "comment", c.expComment, reader._var.others) } } @@ -163,16 +163,16 @@ func TestParseSubsection(t *testing.T) { err := reader.parseSubsection() if err != nil { - test.Assert(t, "error", c.expErr, err, true) + test.Assert(t, "error", c.expErr, err) if err != io.EOF { continue } } - test.Assert(t, "mode", c.expMode, reader._var.mode, true) - test.Assert(t, "format", c.expFormat, reader._var.format, true) - test.Assert(t, "subsection", c.expSub, reader._var.subName, true) - test.Assert(t, "comment", c.expComment, reader._var.others, true) + test.Assert(t, "mode", c.expMode, reader._var.mode) + test.Assert(t, "format", c.expFormat, reader._var.format) + test.Assert(t, "subsection", c.expSub, reader._var.subName) + test.Assert(t, "comment", c.expComment, reader._var.others) } } @@ -330,17 +330,17 @@ func TestParseVariable(t *testing.T) { err := reader.parseVariable() if err != nil { - test.Assert(t, "error", c.expErr, err, true) + test.Assert(t, "error", c.expErr, err) if err != io.EOF { continue } } - test.Assert(t, "mode", c.expMode, reader._var.mode, true) - test.Assert(t, "format", c.expFormat, reader._var.format, true) - test.Assert(t, "key", c.expKey, reader._var.key, true) - test.Assert(t, "value", c.expValue, reader._var.value, true) - test.Assert(t, "comment", c.expComment, reader._var.others, true) + test.Assert(t, "mode", c.expMode, reader._var.mode) + test.Assert(t, "format", c.expFormat, reader._var.format) + test.Assert(t, "key", c.expKey, reader._var.key) + test.Assert(t, "value", c.expValue, reader._var.value) + test.Assert(t, "comment", c.expComment, reader._var.others) } } @@ -482,14 +482,14 @@ func TestParseVarValue(t *testing.T) { err := reader.parseVarValue() if err != nil { - test.Assert(t, "error", c.expErr, err, true) + test.Assert(t, "error", c.expErr, err) if err != io.EOF { continue } } - test.Assert(t, "format", c.expFormat, reader._var.format, true) - test.Assert(t, "value", c.expValue, reader._var.value, true) - test.Assert(t, "comment", c.expComment, reader._var.others, true) + test.Assert(t, "format", c.expFormat, reader._var.format) + test.Assert(t, "value", c.expValue, reader._var.value) + test.Assert(t, "comment", c.expComment, reader._var.others) } } diff --git a/lib/ini/section_test.go b/lib/ini/section_test.go index 3f1af30b..c0de6534 100644 --- a/lib/ini/section_test.go +++ b/lib/ini/section_test.go @@ -46,7 +46,7 @@ func TestNewSection(t *testing.T) { got := newSection(c.name, c.sub) - test.Assert(t, "section", c.expSec, got, true) + test.Assert(t, "section", c.expSec, got) } } @@ -121,8 +121,8 @@ func TestSectionSet(t *testing.T) { ok := sec.set(c.k, c.v) - test.Assert(t, "ok", c.expOK, ok, true) - test.Assert(t, "section", c.expSec, sec, true) + test.Assert(t, "ok", c.expOK, ok) + test.Assert(t, "section", c.expSec, sec) } } @@ -221,7 +221,7 @@ func TestSection_add(t *testing.T) { sec.add(c.k, c.v) - test.Assert(t, "section", c.expSec, sec, true) + test.Assert(t, "section", c.expSec, sec) } } @@ -313,8 +313,8 @@ func TestSectionUnset(t *testing.T) { ok := sec.unset(c.k) - test.Assert(t, "ok", c.expOK, ok, true) - test.Assert(t, "section", c.expSec, sec, true) + test.Assert(t, "ok", c.expOK, ok) + test.Assert(t, "section", c.expSec, sec) } } @@ -400,7 +400,7 @@ func TestSectionUnsetAll(t *testing.T) { sec.unsetAll(c.k) - test.Assert(t, "section", c.expSec, sec, true) + test.Assert(t, "section", c.expSec, sec) } } @@ -511,7 +511,7 @@ func TestSection_replaceAll(t *testing.T) { sec.replaceAll(c.k, c.v) - test.Assert(t, "section", c.expSec, sec, true) + test.Assert(t, "section", c.expSec, sec) } } @@ -557,8 +557,8 @@ func TestSectionGet(t *testing.T) { got, ok := sec.get(c.k, c.def) - test.Assert(t, "ok", c.expOK, ok, true) - test.Assert(t, "value", c.expVal, got, true) + test.Assert(t, "ok", c.expOK, ok) + test.Assert(t, "value", c.expVal, got) } } @@ -609,7 +609,7 @@ func TestSectionGets(t *testing.T) { got, ok := sec.gets(c.key, c.defs) - test.Assert(t, "Gets value", c.exps, got, true) - test.Assert(t, "Gets ok", c.expOK, ok, true) + test.Assert(t, "Gets value", c.exps, got) + test.Assert(t, "Gets ok", c.expOK, ok) } } diff --git a/lib/ini/tag_struct_field_test.go b/lib/ini/tag_struct_field_test.go index 2c41ee8e..40c3a2fd 100644 --- a/lib/ini/tag_struct_field_test.go +++ b/lib/ini/tag_struct_field_test.go @@ -66,7 +66,7 @@ func TestUnpackStruct(t *testing.T) { "slice:OfStruct", } - test.Assert(t, "unpackStruct", exp, got.keys(), true) + test.Assert(t, "unpackStruct", exp, got.keys()) } func TestUnpackStruct_embedded(t *testing.T) { @@ -99,5 +99,5 @@ func TestUnpackStruct_embedded(t *testing.T) { "b::z", "c::xx", } - test.Assert(t, "unpackStruct embedded", exp, got.keys(), true) + test.Assert(t, "unpackStruct embedded", exp, got.keys()) } diff --git a/lib/ini/variable_test.go b/lib/ini/variable_test.go index 96f5c901..b53e5dc6 100644 --- a/lib/ini/variable_test.go +++ b/lib/ini/variable_test.go @@ -28,7 +28,7 @@ func TestVariableEscape(t *testing.T) { for _, c := range cases { t.Log(c.desc) got := escape(c.in) - test.Assert(t, "escape", c.exp, got, true) + test.Assert(t, "escape", c.exp, got) } } @@ -105,6 +105,6 @@ func TestVariableString(t *testing.T) { got := c.v.String() - test.Assert(t, "", c.exp, got, true) + test.Assert(t, "", c.exp, got) } } |
