From 546b6b1724f0d700bc16950bc41b6a243d20b89a Mon Sep 17 00:00:00 2001 From: John Guo Date: Thu, 10 Mar 2022 11:36:40 +0800 Subject: [PATCH] t.Assert(err, nil) -> t.AssertNil(err) --- .../garray/garray_z_unit_normal_any_test.go | 14 ++-- .../garray/garray_z_unit_normal_int_test.go | 16 ++-- .../garray/garray_z_unit_normal_str_test.go | 16 ++-- .../garray/garray_z_unit_sorted_any_test.go | 16 ++-- .../garray/garray_z_unit_sorted_int_test.go | 16 ++-- .../garray/garray_z_unit_sorted_str_test.go | 16 ++-- container/glist/glist_z_unit_test.go | 12 +-- .../gmap/gmap_z_unit_hash_any_any_test.go | 12 +-- .../gmap/gmap_z_unit_hash_int_any_test.go | 8 +- .../gmap/gmap_z_unit_hash_int_int_test.go | 8 +- .../gmap/gmap_z_unit_hash_int_str_test.go | 8 +- .../gmap/gmap_z_unit_hash_str_any_test.go | 12 +-- .../gmap/gmap_z_unit_hash_str_int_test.go | 12 +-- .../gmap/gmap_z_unit_hash_str_str_test.go | 12 +-- container/gmap/gmap_z_unit_list_map_test.go | 12 +-- container/gmap/gmap_z_unit_tree_map_test.go | 12 +-- container/gset/gset_z_unit_any_test.go | 6 +- container/gset/gset_z_unit_int_test.go | 6 +- container/gset/gset_z_unit_str_test.go | 6 +- container/gtype/gtype_z_unit_bool_test.go | 16 ++-- container/gtype/gtype_z_unit_byte_test.go | 4 +- container/gtype/gtype_z_unit_bytes_test.go | 4 +- container/gtype/gtype_z_unit_float32_test.go | 4 +- container/gtype/gtype_z_unit_float64_test.go | 4 +- container/gtype/gtype_z_unit_int32_test.go | 4 +- container/gtype/gtype_z_unit_int64_test.go | 4 +- container/gtype/gtype_z_unit_int_test.go | 4 +- .../gtype/gtype_z_unit_interface_test.go | 4 +- container/gtype/gtype_z_unit_string_test.go | 4 +- container/gtype/gtype_z_unit_uint32_test.go | 4 +- container/gtype/gtype_z_unit_uint64_test.go | 4 +- container/gtype/gtype_z_unit_uint_test.go | 4 +- container/gvar/gvar_z_unit_basic_test.go | 8 +- container/gvar/gvar_z_unit_json_test.go | 8 +- container/gvar/gvar_z_unit_struct_test.go | 4 +- crypto/gaes/gaes_z_unit_test.go | 24 +++--- crypto/gmd5/gmd5_z_unit_test.go | 2 +- crypto/gsha1/gsha1_z_unit_test.go | 2 +- database/gdb/gdb_z_mysql_feature_with_test.go | 60 +++++++------- database/gdb/gdb_z_mysql_model_test.go | 6 +- database/gredis/gredis_z_unit_conn_test.go | 4 +- database/gredis/gredis_z_unit_test.go | 74 ++++++++--------- encoding/gbase64/gbase64_z_unit_test.go | 4 +- .../gcompress/gcompress_z_unit_gzip_test.go | 4 +- .../gcompress/gcompress_z_unit_zip_test.go | 32 ++++---- encoding/ghtml/ghtml_z_unit_test.go | 6 +- encoding/gini/gini_z_unit_test.go | 2 +- .../gjson/gjson_z_unit_feature_json_test.go | 10 +-- .../gjson/gjson_z_unit_feature_load_test.go | 34 ++++---- .../gjson/gjson_z_unit_feature_new_test.go | 2 +- .../gjson/gjson_z_unit_feature_set_test.go | 12 +-- .../gjson/gjson_z_unit_feature_struct_test.go | 24 +++--- .../gjson/gjson_z_unit_implements_test.go | 14 ++-- encoding/gjson/gjson_z_unit_test.go | 82 +++++++++---------- encoding/gxml/gxml_z_unit_test.go | 4 +- encoding/gyaml/gyaml_z_unit_test.go | 8 +- errors/gerror/gerror_z_unit_test.go | 2 +- frame/gins/gins_z_unit_config_test.go | 26 +++--- frame/gins/gins_z_unit_database_test.go | 6 +- frame/gins/gins_z_unit_redis_test.go | 12 +-- frame/gins/gins_z_unit_view_test.go | 30 +++---- i18n/gi18n/gi18n_z_unit_test.go | 8 +- net/gclient/gclient_z_unit_test.go | 18 ++-- net/ghttp/ghttp_z_unit_feature_config_test.go | 4 +- ...tp_z_unit_feature_middleware_basic_test.go | 4 +- ...ttp_z_unit_feature_middleware_cors_test.go | 16 ++-- .../ghttp_z_unit_feature_router_basic_test.go | 22 ++--- ...z_unit_feature_router_domain_basic_test.go | 48 +++++------ ..._feature_router_domain_object_rest_test.go | 6 +- ...p_z_unit_feature_router_group_rest_test.go | 8 +- ...z_unit_feature_router_object_rest1_test.go | 4 +- .../ghttp_z_unit_feature_session_test.go | 2 +- .../ghttp_z_unit_feature_template_test.go | 18 ++-- .../ghttp_z_unit_feature_websocket_test.go | 6 +- net/gtcp/gtcp_z_unit_conn_pkg_test.go | 32 ++++---- net/gtcp/gtcp_z_unit_pool_pkg_test.go | 32 ++++---- net/gtcp/gtcp_z_unit_pool_test.go | 12 +-- net/gudp/gudp_z_unit_test.go | 14 ++-- os/gcfg/gcfg_z_unit_basic_test.go | 8 +- os/gcmd/gcmd_z_unit_parser_test.go | 4 +- os/genv/genv_z_unit_test.go | 16 ++-- os/gfile/gfile_z_unit_contents_test.go | 22 ++--- os/gfile/gfile_z_unit_copy_test.go | 2 +- os/gfile/gfile_z_unit_scan_test.go | 14 ++-- os/gfile/gfile_z_unit_search_test.go | 4 +- os/gfile/gfile_z_unit_test.go | 30 +++---- os/gfile/gfile_z_unit_time_test.go | 4 +- os/gfpool/gfpool_z_unit_test.go | 52 ++++++------ os/gfsnotify/gfsnotify_z_unit_test.go | 18 ++-- os/glog/glog_z_unit_config_test.go | 6 +- os/glog/glog_z_unit_logger_chaining_test.go | 26 +++--- os/glog/glog_z_unit_logger_rotate_test.go | 14 ++-- os/glog/glog_z_unit_test.go | 2 +- os/gres/gres_z_unit_test.go | 22 ++--- ...ion_z_unit_storage_redis_hashtable_test.go | 2 +- .../gsession_z_unit_storage_redis_test.go | 4 +- os/gspath/gspath_z_unit_test.go | 6 +- os/gtime/gtime_z_unit_feature_sql_test.go | 4 +- os/gtime/gtime_z_unit_test.go | 16 ++-- os/gview/gview_z_unit_config_test.go | 12 +-- os/gview/gview_z_unit_feature_encode_test.go | 4 +- os/gview/gview_z_unit_i18n_test.go | 12 +-- os/gview/gview_z_unit_test.go | 38 ++++----- text/gregex/gregex_z_unit_test.go | 16 ++-- text/gstr/gstr_z_unit_parse_test.go | 22 ++--- util/gconv/gconv_z_unit_all_test.go | 2 +- util/gconv/gconv_z_unit_custom_type_test.go | 2 +- util/gconv/gconv_z_unit_map_test.go | 4 +- util/gconv/gconv_z_unit_maptomap_test.go | 8 +- util/gconv/gconv_z_unit_scan_test.go | 6 +- util/gconv/gconv_z_unit_slice_test.go | 2 +- ...nv_z_unit_struct_marshal_unmarshal_test.go | 4 +- util/gconv/gconv_z_unit_struct_test.go | 66 +++++++-------- util/gconv/gconv_z_unit_structs_test.go | 14 ++-- .../gvalid_z_unit_feature_checkmap_test.go | 2 +- .../gvalid_z_unit_feature_checkstruct_test.go | 14 ++-- .../gvalid_z_unit_feature_custom_rule_test.go | 8 +- .../gvalid/gvalid_z_unit_feature_rule_test.go | 2 +- 118 files changed, 779 insertions(+), 779 deletions(-) diff --git a/container/garray/garray_z_unit_normal_any_test.go b/container/garray/garray_z_unit_normal_any_test.go index d1e132174..7532fbe86 100644 --- a/container/garray/garray_z_unit_normal_any_test.go +++ b/container/garray/garray_z_unit_normal_any_test.go @@ -576,7 +576,7 @@ func TestArray_Json(t *testing.T) { var a3 garray.Array err := json.UnmarshalUseNumber(b2, &a3) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(a3.Slice(), s1) }) // value. @@ -595,7 +595,7 @@ func TestArray_Json(t *testing.T) { var a3 garray.Array err := json.UnmarshalUseNumber(b2, &a3) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(a3.Slice(), s1) }) // pointer @@ -609,11 +609,11 @@ func TestArray_Json(t *testing.T) { "Scores": []int{99, 100, 98}, } b, err := json.Marshal(data) - t.Assert(err, nil) + t.AssertNil(err) user := new(User) err = json.UnmarshalUseNumber(b, user) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(user.Name, data["Name"]) t.Assert(user.Scores, data["Scores"]) }) @@ -628,11 +628,11 @@ func TestArray_Json(t *testing.T) { "Scores": []int{99, 100, 98}, } b, err := json.Marshal(data) - t.Assert(err, nil) + t.AssertNil(err) user := new(User) err = json.UnmarshalUseNumber(b, user) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(user.Name, data["Name"]) t.Assert(user.Scores, data["Scores"]) }) @@ -720,7 +720,7 @@ func TestArray_UnmarshalValue(t *testing.T) { "name": "john", "array": g.Slice{1, 2, 3}, }, &v) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(v.Name, "john") t.Assert(v.Array.Slice(), g.Slice{1, 2, 3}) }) diff --git a/container/garray/garray_z_unit_normal_int_test.go b/container/garray/garray_z_unit_normal_int_test.go index e8e3b79b3..545cbfc74 100644 --- a/container/garray/garray_z_unit_normal_int_test.go +++ b/container/garray/garray_z_unit_normal_int_test.go @@ -619,7 +619,7 @@ func TestIntArray_Json(t *testing.T) { var a3 garray.IntArray err := json.UnmarshalUseNumber(b2, &a3) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(a3.Slice(), s1) }) // array value @@ -637,7 +637,7 @@ func TestIntArray_Json(t *testing.T) { var a3 garray.IntArray err := json.UnmarshalUseNumber(b2, &a3) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(a3.Slice(), s1) }) // array pointer @@ -651,11 +651,11 @@ func TestIntArray_Json(t *testing.T) { "Scores": []int{99, 100, 98}, } b, err := json.Marshal(data) - t.Assert(err, nil) + t.AssertNil(err) user := new(User) err = json.UnmarshalUseNumber(b, user) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(user.Name, data["Name"]) t.Assert(user.Scores, data["Scores"]) }) @@ -670,11 +670,11 @@ func TestIntArray_Json(t *testing.T) { "Scores": []int{99, 100, 98}, } b, err := json.Marshal(data) - t.Assert(err, nil) + t.AssertNil(err) user := new(User) err = json.UnmarshalUseNumber(b, user) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(user.Name, data["Name"]) t.Assert(user.Scores, data["Scores"]) }) @@ -752,7 +752,7 @@ func TestIntArray_UnmarshalValue(t *testing.T) { "name": "john", "array": []byte(`[1,2,3]`), }, &v) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(v.Name, "john") t.Assert(v.Array.Slice(), g.Slice{1, 2, 3}) }) @@ -763,7 +763,7 @@ func TestIntArray_UnmarshalValue(t *testing.T) { // "name": "john", // "array": g.Slice{1, 2, 3}, // }, &v) - // t.Assert(err, nil) + // t.AssertNil(err) // t.Assert(v.Name, "john") // t.Assert(v.Array.Slice(), g.Slice{1, 2, 3}) // }) diff --git a/container/garray/garray_z_unit_normal_str_test.go b/container/garray/garray_z_unit_normal_str_test.go index d5d8bcf6e..26130cce4 100644 --- a/container/garray/garray_z_unit_normal_str_test.go +++ b/container/garray/garray_z_unit_normal_str_test.go @@ -619,7 +619,7 @@ func TestStrArray_Json(t *testing.T) { var a3 garray.StrArray err := json.UnmarshalUseNumber(b2, &a3) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(a3.Slice(), s1) }) // array value @@ -637,7 +637,7 @@ func TestStrArray_Json(t *testing.T) { var a3 garray.StrArray err := json.UnmarshalUseNumber(b2, &a3) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(a3.Slice(), s1) }) // array pointer @@ -651,11 +651,11 @@ func TestStrArray_Json(t *testing.T) { "Scores": []string{"A+", "A", "A"}, } b, err := json.Marshal(data) - t.Assert(err, nil) + t.AssertNil(err) user := new(User) err = json.UnmarshalUseNumber(b, user) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(user.Name, data["Name"]) t.Assert(user.Scores, data["Scores"]) }) @@ -670,11 +670,11 @@ func TestStrArray_Json(t *testing.T) { "Scores": []string{"A+", "A", "A"}, } b, err := json.Marshal(data) - t.Assert(err, nil) + t.AssertNil(err) user := new(User) err = json.UnmarshalUseNumber(b, user) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(user.Name, data["Name"]) t.Assert(user.Scores, data["Scores"]) }) @@ -751,7 +751,7 @@ func TestStrArray_UnmarshalValue(t *testing.T) { "name": "john", "array": []byte(`["1","2","3"]`), }, &v) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(v.Name, "john") t.Assert(v.Array.Slice(), g.SliceStr{"1", "2", "3"}) }) @@ -762,7 +762,7 @@ func TestStrArray_UnmarshalValue(t *testing.T) { "name": "john", "array": g.SliceStr{"1", "2", "3"}, }, &v) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(v.Name, "john") t.Assert(v.Array.Slice(), g.SliceStr{"1", "2", "3"}) }) diff --git a/container/garray/garray_z_unit_sorted_any_test.go b/container/garray/garray_z_unit_sorted_any_test.go index 1513aa342..d7dad282e 100644 --- a/container/garray/garray_z_unit_sorted_any_test.go +++ b/container/garray/garray_z_unit_sorted_any_test.go @@ -661,7 +661,7 @@ func TestSortedArray_Json(t *testing.T) { var a3 garray.SortedArray err := json.UnmarshalUseNumber(b2, &a3) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(a3.Slice(), s1) t.Assert(a3.Interfaces(), s1) }) @@ -681,7 +681,7 @@ func TestSortedArray_Json(t *testing.T) { var a3 garray.SortedArray err := json.UnmarshalUseNumber(b2, &a3) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(a3.Slice(), s1) t.Assert(a3.Interfaces(), s1) }) @@ -696,11 +696,11 @@ func TestSortedArray_Json(t *testing.T) { "Scores": []int{99, 100, 98}, } b, err := json.Marshal(data) - t.Assert(err, nil) + t.AssertNil(err) user := new(User) err = json.UnmarshalUseNumber(b, user) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(user.Name, data["Name"]) t.AssertNE(user.Scores, nil) t.Assert(user.Scores.Len(), 3) @@ -732,11 +732,11 @@ func TestSortedArray_Json(t *testing.T) { "Scores": []int{99, 100, 98}, } b, err := json.Marshal(data) - t.Assert(err, nil) + t.AssertNil(err) user := new(User) err = json.UnmarshalUseNumber(b, user) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(user.Name, data["Name"]) t.AssertNE(user.Scores, nil) t.Assert(user.Scores.Len(), 3) @@ -830,7 +830,7 @@ func TestSortedArray_UnmarshalValue(t *testing.T) { "name": "john", "array": []byte(`[2,3,1]`), }, &v) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(v.Name, "john") t.Assert(v.Array.Slice(), g.Slice{1, 2, 3}) }) @@ -841,7 +841,7 @@ func TestSortedArray_UnmarshalValue(t *testing.T) { "name": "john", "array": g.Slice{2, 3, 1}, }, &v) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(v.Name, "john") t.Assert(v.Array.Slice(), g.Slice{1, 2, 3}) }) diff --git a/container/garray/garray_z_unit_sorted_int_test.go b/container/garray/garray_z_unit_sorted_int_test.go index c653340c6..73a33968e 100644 --- a/container/garray/garray_z_unit_sorted_int_test.go +++ b/container/garray/garray_z_unit_sorted_int_test.go @@ -561,7 +561,7 @@ func TestSortedIntArray_Json(t *testing.T) { var a3 garray.SortedIntArray err := json.UnmarshalUseNumber(b2, &a3) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(a3.Slice(), s1) }) // array value @@ -580,7 +580,7 @@ func TestSortedIntArray_Json(t *testing.T) { var a3 garray.SortedIntArray err := json.UnmarshalUseNumber(b2, &a3) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(a3.Slice(), s1) }) // array pointer @@ -594,11 +594,11 @@ func TestSortedIntArray_Json(t *testing.T) { "Scores": []int{99, 100, 98}, } b, err := json.Marshal(data) - t.Assert(err, nil) + t.AssertNil(err) user := new(User) err = json.UnmarshalUseNumber(b, user) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(user.Name, data["Name"]) t.Assert(user.Scores, []int{98, 99, 100}) }) @@ -613,11 +613,11 @@ func TestSortedIntArray_Json(t *testing.T) { "Scores": []int{99, 100, 98}, } b, err := json.Marshal(data) - t.Assert(err, nil) + t.AssertNil(err) user := new(User) err = json.UnmarshalUseNumber(b, user) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(user.Name, data["Name"]) t.Assert(user.Scores, []int{98, 99, 100}) }) @@ -695,7 +695,7 @@ func TestSortedIntArray_UnmarshalValue(t *testing.T) { "name": "john", "array": []byte(`[2,3,1]`), }, &v) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(v.Name, "john") t.Assert(v.Array.Slice(), g.Slice{1, 2, 3}) }) @@ -706,7 +706,7 @@ func TestSortedIntArray_UnmarshalValue(t *testing.T) { "name": "john", "array": g.Slice{2, 3, 1}, }, &v) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(v.Name, "john") t.Assert(v.Array.Slice(), g.Slice{1, 2, 3}) }) diff --git a/container/garray/garray_z_unit_sorted_str_test.go b/container/garray/garray_z_unit_sorted_str_test.go index 7625064a1..e93c1a59d 100644 --- a/container/garray/garray_z_unit_sorted_str_test.go +++ b/container/garray/garray_z_unit_sorted_str_test.go @@ -583,7 +583,7 @@ func TestSortedStrArray_Json(t *testing.T) { var a3 garray.SortedStrArray err := json.UnmarshalUseNumber(b2, &a3) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(a3.Slice(), s1) t.Assert(a3.Interfaces(), s1) }) @@ -604,7 +604,7 @@ func TestSortedStrArray_Json(t *testing.T) { var a3 garray.SortedStrArray err := json.UnmarshalUseNumber(b2, &a3) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(a3.Slice(), s1) t.Assert(a3.Interfaces(), s1) }) @@ -619,11 +619,11 @@ func TestSortedStrArray_Json(t *testing.T) { "Scores": []string{"A+", "A", "A"}, } b, err := json.Marshal(data) - t.Assert(err, nil) + t.AssertNil(err) user := new(User) err = json.UnmarshalUseNumber(b, user) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(user.Name, data["Name"]) t.Assert(user.Scores, []string{"A", "A", "A+"}) }) @@ -638,11 +638,11 @@ func TestSortedStrArray_Json(t *testing.T) { "Scores": []string{"A+", "A", "A"}, } b, err := json.Marshal(data) - t.Assert(err, nil) + t.AssertNil(err) user := new(User) err = json.UnmarshalUseNumber(b, user) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(user.Name, data["Name"]) t.Assert(user.Scores, []string{"A", "A", "A+"}) }) @@ -719,7 +719,7 @@ func TestSortedStrArray_UnmarshalValue(t *testing.T) { "name": "john", "array": []byte(`["1","3","2"]`), }, &v) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(v.Name, "john") t.Assert(v.Array.Slice(), g.SliceStr{"1", "2", "3"}) }) @@ -730,7 +730,7 @@ func TestSortedStrArray_UnmarshalValue(t *testing.T) { "name": "john", "array": g.SliceStr{"1", "3", "2"}, }, &v) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(v.Name, "john") t.Assert(v.Array.Slice(), g.SliceStr{"1", "2", "3"}) }) diff --git a/container/glist/glist_z_unit_test.go b/container/glist/glist_z_unit_test.go index edd1f7c4b..a381030fe 100644 --- a/container/glist/glist_z_unit_test.go +++ b/container/glist/glist_z_unit_test.go @@ -709,20 +709,20 @@ func TestList_Json(t *testing.T) { a := []interface{}{"a", "b", "c"} l := New() b, err := json.Marshal(a) - t.Assert(err, nil) + t.AssertNil(err) err = json.UnmarshalUseNumber(b, l) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(l.FrontAll(), a) }) gtest.C(t, func(t *gtest.T) { var l List a := []interface{}{"a", "b", "c"} b, err := json.Marshal(a) - t.Assert(err, nil) + t.AssertNil(err) err = json.UnmarshalUseNumber(b, &l) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(l.FrontAll(), a) }) } @@ -739,7 +739,7 @@ func TestList_UnmarshalValue(t *testing.T) { "name": "john", "list": []byte(`[1,2,3]`), }, &tlist) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(tlist.Name, "john") t.Assert(tlist.List.FrontAll(), []interface{}{1, 2, 3}) }) @@ -750,7 +750,7 @@ func TestList_UnmarshalValue(t *testing.T) { "name": "john", "list": []interface{}{1, 2, 3}, }, &tlist) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(tlist.Name, "john") t.Assert(tlist.List.FrontAll(), []interface{}{1, 2, 3}) }) diff --git a/container/gmap/gmap_z_unit_hash_any_any_test.go b/container/gmap/gmap_z_unit_hash_any_any_test.go index 7de3be37e..e30a7180e 100644 --- a/container/gmap/gmap_z_unit_hash_any_any_test.go +++ b/container/gmap/gmap_z_unit_hash_any_any_test.go @@ -253,11 +253,11 @@ func Test_AnyAnyMap_Json(t *testing.T) { "k2": "v2", } b, err := json.Marshal(gconv.Map(data)) - t.Assert(err, nil) + t.AssertNil(err) m := gmap.New() err = json.UnmarshalUseNumber(b, m) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(m.Get("k1"), data["k1"]) t.Assert(m.Get("k2"), data["k2"]) }) @@ -267,11 +267,11 @@ func Test_AnyAnyMap_Json(t *testing.T) { "k2": "v2", } b, err := json.Marshal(gconv.Map(data)) - t.Assert(err, nil) + t.AssertNil(err) var m gmap.Map err = json.UnmarshalUseNumber(b, &m) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(m.Get("k1"), data["k1"]) t.Assert(m.Get("k2"), data["k2"]) }) @@ -342,7 +342,7 @@ func TestAnyAnyMap_UnmarshalValue(t *testing.T) { "name": "john", "map": []byte(`{"k1":"v1","k2":"v2"}`), }, &v) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(v.Name, "john") t.Assert(v.Map.Size(), 2) t.Assert(v.Map.Get("k1"), "v1") @@ -358,7 +358,7 @@ func TestAnyAnyMap_UnmarshalValue(t *testing.T) { "k2": "v2", }, }, &v) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(v.Name, "john") t.Assert(v.Map.Size(), 2) t.Assert(v.Map.Get("k1"), "v1") diff --git a/container/gmap/gmap_z_unit_hash_int_any_test.go b/container/gmap/gmap_z_unit_hash_int_any_test.go index 13c65d2b3..480115e3b 100644 --- a/container/gmap/gmap_z_unit_hash_int_any_test.go +++ b/container/gmap/gmap_z_unit_hash_int_any_test.go @@ -242,11 +242,11 @@ func Test_IntAnyMap_Json(t *testing.T) { 2: "v2", } b, err := json.Marshal(data) - t.Assert(err, nil) + t.AssertNil(err) m := gmap.NewIntAnyMap() err = json.UnmarshalUseNumber(b, m) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(m.Get(1), data[1]) t.Assert(m.Get(2), data[2]) }) @@ -317,7 +317,7 @@ func TestIntAnyMap_UnmarshalValue(t *testing.T) { "name": "john", "map": []byte(`{"1":"v1","2":"v2"}`), }, &v) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(v.Name, "john") t.Assert(v.Map.Size(), 2) t.Assert(v.Map.Get(1), "v1") @@ -333,7 +333,7 @@ func TestIntAnyMap_UnmarshalValue(t *testing.T) { 2: "v2", }, }, &v) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(v.Name, "john") t.Assert(v.Map.Size(), 2) t.Assert(v.Map.Get(1), "v1") diff --git a/container/gmap/gmap_z_unit_hash_int_int_test.go b/container/gmap/gmap_z_unit_hash_int_int_test.go index d42c7f86f..f8b7dca51 100644 --- a/container/gmap/gmap_z_unit_hash_int_int_test.go +++ b/container/gmap/gmap_z_unit_hash_int_int_test.go @@ -248,11 +248,11 @@ func Test_IntIntMap_Json(t *testing.T) { 2: 20, } b, err := json.Marshal(data) - t.Assert(err, nil) + t.AssertNil(err) m := gmap.NewIntIntMap() err = json.UnmarshalUseNumber(b, m) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(m.Get(1), data[1]) t.Assert(m.Get(2), data[2]) }) @@ -323,7 +323,7 @@ func TestIntIntMap_UnmarshalValue(t *testing.T) { "name": "john", "map": []byte(`{"1":1,"2":2}`), }, &v) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(v.Name, "john") t.Assert(v.Map.Size(), 2) t.Assert(v.Map.Get(1), "1") @@ -339,7 +339,7 @@ func TestIntIntMap_UnmarshalValue(t *testing.T) { 2: 2, }, }, &v) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(v.Name, "john") t.Assert(v.Map.Size(), 2) t.Assert(v.Map.Get(1), "1") diff --git a/container/gmap/gmap_z_unit_hash_int_str_test.go b/container/gmap/gmap_z_unit_hash_int_str_test.go index 046e2f466..b389f0fab 100644 --- a/container/gmap/gmap_z_unit_hash_int_str_test.go +++ b/container/gmap/gmap_z_unit_hash_int_str_test.go @@ -246,11 +246,11 @@ func Test_IntStrMap_Json(t *testing.T) { 2: "v2", } b, err := json.Marshal(data) - t.Assert(err, nil) + t.AssertNil(err) m := gmap.NewIntStrMap() err = json.UnmarshalUseNumber(b, m) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(m.Get(1), data[1]) t.Assert(m.Get(2), data[2]) }) @@ -321,7 +321,7 @@ func TestIntStrMap_UnmarshalValue(t *testing.T) { "name": "john", "map": []byte(`{"1":"v1","2":"v2"}`), }, &v) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(v.Name, "john") t.Assert(v.Map.Size(), 2) t.Assert(v.Map.Get(1), "v1") @@ -337,7 +337,7 @@ func TestIntStrMap_UnmarshalValue(t *testing.T) { 2: "v2", }, }, &v) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(v.Name, "john") t.Assert(v.Map.Size(), 2) t.Assert(v.Map.Get(1), "v1") diff --git a/container/gmap/gmap_z_unit_hash_str_any_test.go b/container/gmap/gmap_z_unit_hash_str_any_test.go index 3dd044478..3bca41980 100644 --- a/container/gmap/gmap_z_unit_hash_str_any_test.go +++ b/container/gmap/gmap_z_unit_hash_str_any_test.go @@ -240,11 +240,11 @@ func Test_StrAnyMap_Json(t *testing.T) { "k2": "v2", } b, err := json.Marshal(data) - t.Assert(err, nil) + t.AssertNil(err) m := gmap.NewStrAnyMap() err = json.UnmarshalUseNumber(b, m) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(m.Get("k1"), data["k1"]) t.Assert(m.Get("k2"), data["k2"]) }) @@ -254,11 +254,11 @@ func Test_StrAnyMap_Json(t *testing.T) { "k2": "v2", } b, err := json.Marshal(data) - t.Assert(err, nil) + t.AssertNil(err) var m gmap.StrAnyMap err = json.UnmarshalUseNumber(b, &m) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(m.Get("k1"), data["k1"]) t.Assert(m.Get("k2"), data["k2"]) }) @@ -329,7 +329,7 @@ func TestStrAnyMap_UnmarshalValue(t *testing.T) { "name": "john", "map": []byte(`{"k1":"v1","k2":"v2"}`), }, &v) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(v.Name, "john") t.Assert(v.Map.Size(), 2) t.Assert(v.Map.Get("k1"), "v1") @@ -345,7 +345,7 @@ func TestStrAnyMap_UnmarshalValue(t *testing.T) { "k2": "v2", }, }, &v) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(v.Name, "john") t.Assert(v.Map.Size(), 2) t.Assert(v.Map.Get("k1"), "v1") diff --git a/container/gmap/gmap_z_unit_hash_str_int_test.go b/container/gmap/gmap_z_unit_hash_str_int_test.go index 431e4fa13..42706b185 100644 --- a/container/gmap/gmap_z_unit_hash_str_int_test.go +++ b/container/gmap/gmap_z_unit_hash_str_int_test.go @@ -244,11 +244,11 @@ func Test_StrIntMap_Json(t *testing.T) { "k2": 2, } b, err := json.Marshal(data) - t.Assert(err, nil) + t.AssertNil(err) m := gmap.NewStrIntMap() err = json.UnmarshalUseNumber(b, m) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(m.Get("k1"), data["k1"]) t.Assert(m.Get("k2"), data["k2"]) }) @@ -258,11 +258,11 @@ func Test_StrIntMap_Json(t *testing.T) { "k2": 2, } b, err := json.Marshal(data) - t.Assert(err, nil) + t.AssertNil(err) var m gmap.StrIntMap err = json.UnmarshalUseNumber(b, &m) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(m.Get("k1"), data["k1"]) t.Assert(m.Get("k2"), data["k2"]) }) @@ -333,7 +333,7 @@ func TestStrIntMap_UnmarshalValue(t *testing.T) { "name": "john", "map": []byte(`{"k1":1,"k2":2}`), }, &v) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(v.Name, "john") t.Assert(v.Map.Size(), 2) t.Assert(v.Map.Get("k1"), 1) @@ -349,7 +349,7 @@ func TestStrIntMap_UnmarshalValue(t *testing.T) { "k2": 2, }, }, &v) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(v.Name, "john") t.Assert(v.Map.Size(), 2) t.Assert(v.Map.Get("k1"), 1) diff --git a/container/gmap/gmap_z_unit_hash_str_str_test.go b/container/gmap/gmap_z_unit_hash_str_str_test.go index 2cfe9b4aa..ed8f385e0 100644 --- a/container/gmap/gmap_z_unit_hash_str_str_test.go +++ b/container/gmap/gmap_z_unit_hash_str_str_test.go @@ -241,11 +241,11 @@ func Test_StrStrMap_Json(t *testing.T) { "k2": "v2", } b, err := json.Marshal(data) - t.Assert(err, nil) + t.AssertNil(err) m := gmap.NewStrStrMap() err = json.UnmarshalUseNumber(b, m) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(m.Get("k1"), data["k1"]) t.Assert(m.Get("k2"), data["k2"]) }) @@ -255,11 +255,11 @@ func Test_StrStrMap_Json(t *testing.T) { "k2": "v2", } b, err := json.Marshal(data) - t.Assert(err, nil) + t.AssertNil(err) var m gmap.StrStrMap err = json.UnmarshalUseNumber(b, &m) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(m.Get("k1"), data["k1"]) t.Assert(m.Get("k2"), data["k2"]) }) @@ -330,7 +330,7 @@ func TestStrStrMap_UnmarshalValue(t *testing.T) { "name": "john", "map": []byte(`{"k1":"v1","k2":"v2"}`), }, &v) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(v.Name, "john") t.Assert(v.Map.Size(), 2) t.Assert(v.Map.Get("k1"), "v1") @@ -346,7 +346,7 @@ func TestStrStrMap_UnmarshalValue(t *testing.T) { "k2": "v2", }, }, &v) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(v.Name, "john") t.Assert(v.Map.Size(), 2) t.Assert(v.Map.Get("k1"), "v1") diff --git a/container/gmap/gmap_z_unit_list_map_test.go b/container/gmap/gmap_z_unit_list_map_test.go index 34851f693..424c83b5a 100644 --- a/container/gmap/gmap_z_unit_list_map_test.go +++ b/container/gmap/gmap_z_unit_list_map_test.go @@ -201,11 +201,11 @@ func Test_ListMap_Json(t *testing.T) { "k2": "v2", } b, err := json.Marshal(gconv.Map(data)) - t.Assert(err, nil) + t.AssertNil(err) m := gmap.NewListMap() err = json.UnmarshalUseNumber(b, m) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(m.Get("k1"), data["k1"]) t.Assert(m.Get("k2"), data["k2"]) }) @@ -216,11 +216,11 @@ func Test_ListMap_Json(t *testing.T) { "k2": "v2", } b, err := json.Marshal(gconv.Map(data)) - t.Assert(err, nil) + t.AssertNil(err) var m gmap.ListMap err = json.UnmarshalUseNumber(b, &m) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(m.Get("k1"), data["k1"]) t.Assert(m.Get("k2"), data["k2"]) }) @@ -312,7 +312,7 @@ func TestListMap_UnmarshalValue(t *testing.T) { "name": "john", "map": []byte(`{"1":"v1","2":"v2"}`), }, &v) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(v.Name, "john") t.Assert(v.Map.Size(), 2) t.Assert(v.Map.Get("1"), "v1") @@ -328,7 +328,7 @@ func TestListMap_UnmarshalValue(t *testing.T) { 2: "v2", }, }, &v) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(v.Name, "john") t.Assert(v.Map.Size(), 2) t.Assert(v.Map.Get("1"), "v1") diff --git a/container/gmap/gmap_z_unit_tree_map_test.go b/container/gmap/gmap_z_unit_tree_map_test.go index b541d127d..fd3341e46 100644 --- a/container/gmap/gmap_z_unit_tree_map_test.go +++ b/container/gmap/gmap_z_unit_tree_map_test.go @@ -185,11 +185,11 @@ func Test_TreeMap_Json(t *testing.T) { "k2": "v2", } b, err := json.Marshal(gconv.Map(data)) - t.Assert(err, nil) + t.AssertNil(err) m := gmap.NewTreeMap(gutil.ComparatorString) err = json.UnmarshalUseNumber(b, m) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(m.Get("k1"), data["k1"]) t.Assert(m.Get("k2"), data["k2"]) }) @@ -199,11 +199,11 @@ func Test_TreeMap_Json(t *testing.T) { "k2": "v2", } b, err := json.Marshal(gconv.Map(data)) - t.Assert(err, nil) + t.AssertNil(err) var m gmap.TreeMap err = json.UnmarshalUseNumber(b, &m) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(m.Get("k1"), data["k1"]) t.Assert(m.Get("k2"), data["k2"]) }) @@ -221,7 +221,7 @@ func TestTreeMap_UnmarshalValue(t *testing.T) { "name": "john", "map": []byte(`{"k1":"v1","k2":"v2"}`), }, &v) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(v.Name, "john") t.Assert(v.Map.Size(), 2) t.Assert(v.Map.Get("k1"), "v1") @@ -237,7 +237,7 @@ func TestTreeMap_UnmarshalValue(t *testing.T) { "k2": "v2", }, }, &v) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(v.Name, "john") t.Assert(v.Map.Size(), 2) t.Assert(v.Map.Get("k1"), "v1") diff --git a/container/gset/gset_z_unit_any_test.go b/container/gset/gset_z_unit_any_test.go index be0c56383..f6e4835a3 100644 --- a/container/gset/gset_z_unit_any_test.go +++ b/container/gset/gset_z_unit_any_test.go @@ -336,7 +336,7 @@ func TestSet_Json(t *testing.T) { var a3 gset.Set err := json.UnmarshalUseNumber(b2, &a3) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(a3.Contains("a"), true) t.Assert(a3.Contains("b"), true) t.Assert(a3.Contains("c"), true) @@ -438,7 +438,7 @@ func TestSet_UnmarshalValue(t *testing.T) { "name": "john", "set": []byte(`["k1","k2","k3"]`), }, &v) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(v.Name, "john") t.Assert(v.Set.Size(), 3) t.Assert(v.Set.Contains("k1"), true) @@ -453,7 +453,7 @@ func TestSet_UnmarshalValue(t *testing.T) { "name": "john", "set": g.Slice{"k1", "k2", "k3"}, }, &v) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(v.Name, "john") t.Assert(v.Set.Size(), 3) t.Assert(v.Set.Contains("k1"), true) diff --git a/container/gset/gset_z_unit_int_test.go b/container/gset/gset_z_unit_int_test.go index 5f7068c75..8a7086a50 100644 --- a/container/gset/gset_z_unit_int_test.go +++ b/container/gset/gset_z_unit_int_test.go @@ -368,7 +368,7 @@ func TestIntSet_Json(t *testing.T) { var a3 gset.IntSet err := json.UnmarshalUseNumber(b2, &a3) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(a2.Contains(1), true) t.Assert(a2.Contains(2), true) t.Assert(a2.Contains(3), true) @@ -402,7 +402,7 @@ func TestIntSet_UnmarshalValue(t *testing.T) { "name": "john", "set": []byte(`[1,2,3]`), }, &v) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(v.Name, "john") t.Assert(v.Set.Size(), 3) t.Assert(v.Set.Contains(1), true) @@ -417,7 +417,7 @@ func TestIntSet_UnmarshalValue(t *testing.T) { "name": "john", "set": g.Slice{1, 2, 3}, }, &v) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(v.Name, "john") t.Assert(v.Set.Size(), 3) t.Assert(v.Set.Contains(1), true) diff --git a/container/gset/gset_z_unit_str_test.go b/container/gset/gset_z_unit_str_test.go index eae7cd15a..ed41308da 100644 --- a/container/gset/gset_z_unit_str_test.go +++ b/container/gset/gset_z_unit_str_test.go @@ -414,7 +414,7 @@ func TestStrSet_Json(t *testing.T) { var a3 gset.StrSet err := json.UnmarshalUseNumber(b2, &a3) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(a3.Contains("a"), true) t.Assert(a3.Contains("b"), true) t.Assert(a3.Contains("c"), true) @@ -453,7 +453,7 @@ func TestStrSet_UnmarshalValue(t *testing.T) { "name": "john", "set": []byte(`["1","2","3"]`), }, &v) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(v.Name, "john") t.Assert(v.Set.Size(), 3) t.Assert(v.Set.Contains("1"), true) @@ -468,7 +468,7 @@ func TestStrSet_UnmarshalValue(t *testing.T) { "name": "john", "set": g.SliceStr{"1", "2", "3"}, }, &v) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(v.Name, "john") t.Assert(v.Set.Size(), 3) t.Assert(v.Set.Contains("1"), true) diff --git a/container/gtype/gtype_z_unit_bool_test.go b/container/gtype/gtype_z_unit_bool_test.go index 47c31c387..e44c6b456 100644 --- a/container/gtype/gtype_z_unit_bool_test.go +++ b/container/gtype/gtype_z_unit_bool_test.go @@ -56,16 +56,16 @@ func Test_Bool_JSON(t *testing.T) { var err error i := gtype.NewBool() err = json.UnmarshalUseNumber([]byte("true"), &i) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(i.Val(), true) err = json.UnmarshalUseNumber([]byte("false"), &i) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(i.Val(), false) err = json.UnmarshalUseNumber([]byte("1"), &i) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(i.Val(), true) err = json.UnmarshalUseNumber([]byte("0"), &i) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(i.Val(), false) }) @@ -79,7 +79,7 @@ func Test_Bool_JSON(t *testing.T) { i2 := gtype.NewBool() err := json.UnmarshalUseNumber(b2, &i2) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(i2.Val(), i.Val()) }) gtest.C(t, func(t *gtest.T) { @@ -92,7 +92,7 @@ func Test_Bool_JSON(t *testing.T) { i2 := gtype.NewBool() err := json.UnmarshalUseNumber(b2, &i2) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(i2.Val(), i.Val()) }) } @@ -108,7 +108,7 @@ func Test_Bool_UnmarshalValue(t *testing.T) { "name": "john", "var": "true", }, &v) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(v.Name, "john") t.Assert(v.Var.Val(), true) }) @@ -118,7 +118,7 @@ func Test_Bool_UnmarshalValue(t *testing.T) { "name": "john", "var": "false", }, &v) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(v.Name, "john") t.Assert(v.Var.Val(), false) }) diff --git a/container/gtype/gtype_z_unit_byte_test.go b/container/gtype/gtype_z_unit_byte_test.go index b035ff0a1..d3b87ec49 100644 --- a/container/gtype/gtype_z_unit_byte_test.go +++ b/container/gtype/gtype_z_unit_byte_test.go @@ -54,7 +54,7 @@ func Test_Byte_JSON(t *testing.T) { var err error i := gtype.NewByte() err = json.UnmarshalUseNumber([]byte("49"), &i) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(i.Val(), "49") }) } @@ -70,7 +70,7 @@ func Test_Byte_UnmarshalValue(t *testing.T) { "name": "john", "var": "2", }, &v) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(v.Name, "john") t.Assert(v.Var.Val(), "2") }) diff --git a/container/gtype/gtype_z_unit_bytes_test.go b/container/gtype/gtype_z_unit_bytes_test.go index f6da7ab13..d919c47bf 100644 --- a/container/gtype/gtype_z_unit_bytes_test.go +++ b/container/gtype/gtype_z_unit_bytes_test.go @@ -40,7 +40,7 @@ func Test_Bytes_JSON(t *testing.T) { i2 := gtype.NewBytes() err := json.UnmarshalUseNumber(b2, &i2) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(i2.Val(), b) }) } @@ -56,7 +56,7 @@ func Test_Bytes_UnmarshalValue(t *testing.T) { "name": "john", "var": "123", }, &v) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(v.Name, "john") t.Assert(v.Var.Val(), "123") }) diff --git a/container/gtype/gtype_z_unit_float32_test.go b/container/gtype/gtype_z_unit_float32_test.go index c0a081a6e..e3e6cd667 100644 --- a/container/gtype/gtype_z_unit_float32_test.go +++ b/container/gtype/gtype_z_unit_float32_test.go @@ -42,7 +42,7 @@ func Test_Float32_JSON(t *testing.T) { i2 := gtype.NewFloat32() err := json.UnmarshalUseNumber(b2, &i2) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(i2.Val(), v) }) } @@ -58,7 +58,7 @@ func Test_Float32_UnmarshalValue(t *testing.T) { "name": "john", "var": "123.456", }, &v) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(v.Name, "john") t.Assert(v.Var.Val(), "123.456") }) diff --git a/container/gtype/gtype_z_unit_float64_test.go b/container/gtype/gtype_z_unit_float64_test.go index b5bf088f8..02339cefd 100644 --- a/container/gtype/gtype_z_unit_float64_test.go +++ b/container/gtype/gtype_z_unit_float64_test.go @@ -40,7 +40,7 @@ func Test_Float64_JSON(t *testing.T) { i2 := gtype.NewFloat64() err := json.UnmarshalUseNumber(b2, &i2) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(i2.Val(), v) }) } @@ -56,7 +56,7 @@ func Test_Float64_UnmarshalValue(t *testing.T) { "name": "john", "var": "123.456", }, &v) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(v.Name, "john") t.Assert(v.Var.Val(), "123.456") }) diff --git a/container/gtype/gtype_z_unit_int32_test.go b/container/gtype/gtype_z_unit_int32_test.go index 3a13c5801..996f4d087 100644 --- a/container/gtype/gtype_z_unit_int32_test.go +++ b/container/gtype/gtype_z_unit_int32_test.go @@ -53,7 +53,7 @@ func Test_Int32_JSON(t *testing.T) { i2 := gtype.NewInt32() err := json.UnmarshalUseNumber(b2, &i2) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(i2.Val(), v) }) } @@ -69,7 +69,7 @@ func Test_Int32_UnmarshalValue(t *testing.T) { "name": "john", "var": "123", }, &v) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(v.Name, "john") t.Assert(v.Var.Val(), "123") }) diff --git a/container/gtype/gtype_z_unit_int64_test.go b/container/gtype/gtype_z_unit_int64_test.go index 1c3966b5d..f3c74bced 100644 --- a/container/gtype/gtype_z_unit_int64_test.go +++ b/container/gtype/gtype_z_unit_int64_test.go @@ -52,7 +52,7 @@ func Test_Int64_JSON(t *testing.T) { i2 := gtype.NewInt64() err := json.UnmarshalUseNumber(b2, &i2) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(i2.Val(), i) }) } @@ -68,7 +68,7 @@ func Test_Int64_UnmarshalValue(t *testing.T) { "name": "john", "var": "123", }, &v) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(v.Name, "john") t.Assert(v.Var.Val(), "123") }) diff --git a/container/gtype/gtype_z_unit_int_test.go b/container/gtype/gtype_z_unit_int_test.go index 30c31d9f0..39114eb59 100644 --- a/container/gtype/gtype_z_unit_int_test.go +++ b/container/gtype/gtype_z_unit_int_test.go @@ -52,7 +52,7 @@ func Test_Int_JSON(t *testing.T) { i2 := gtype.NewInt() err := json.UnmarshalUseNumber(b2, &i2) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(i2.Val(), v) }) } @@ -68,7 +68,7 @@ func Test_Int_UnmarshalValue(t *testing.T) { "name": "john", "var": "123", }, &v) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(v.Name, "john") t.Assert(v.Var.Val(), "123") }) diff --git a/container/gtype/gtype_z_unit_interface_test.go b/container/gtype/gtype_z_unit_interface_test.go index c65a92601..828edf36a 100644 --- a/container/gtype/gtype_z_unit_interface_test.go +++ b/container/gtype/gtype_z_unit_interface_test.go @@ -42,7 +42,7 @@ func Test_Interface_JSON(t *testing.T) { i2 := gtype.New() err := json.UnmarshalUseNumber(b2, &i2) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(i2.Val(), s) }) } @@ -58,7 +58,7 @@ func Test_Interface_UnmarshalValue(t *testing.T) { "name": "john", "var": "123", }, &v) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(v.Name, "john") t.Assert(v.Var.Val(), "123") }) diff --git a/container/gtype/gtype_z_unit_string_test.go b/container/gtype/gtype_z_unit_string_test.go index c43830126..319adf509 100644 --- a/container/gtype/gtype_z_unit_string_test.go +++ b/container/gtype/gtype_z_unit_string_test.go @@ -40,7 +40,7 @@ func Test_String_JSON(t *testing.T) { i2 := gtype.NewString() err := json.UnmarshalUseNumber(b2, &i2) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(i2.Val(), s) }) } @@ -56,7 +56,7 @@ func Test_String_UnmarshalValue(t *testing.T) { "name": "john", "var": "123", }, &v) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(v.Name, "john") t.Assert(v.Var.Val(), "123") }) diff --git a/container/gtype/gtype_z_unit_uint32_test.go b/container/gtype/gtype_z_unit_uint32_test.go index 3b0a75005..6e00fc7d8 100644 --- a/container/gtype/gtype_z_unit_uint32_test.go +++ b/container/gtype/gtype_z_unit_uint32_test.go @@ -52,7 +52,7 @@ func Test_Uint32_JSON(t *testing.T) { i2 := gtype.NewUint32() err := json.UnmarshalUseNumber(b2, &i2) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(i2.Val(), i) }) } @@ -68,7 +68,7 @@ func Test_Uint32_UnmarshalValue(t *testing.T) { "name": "john", "var": "123", }, &v) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(v.Name, "john") t.Assert(v.Var.Val(), "123") }) diff --git a/container/gtype/gtype_z_unit_uint64_test.go b/container/gtype/gtype_z_unit_uint64_test.go index f2285aa3d..5fe206051 100644 --- a/container/gtype/gtype_z_unit_uint64_test.go +++ b/container/gtype/gtype_z_unit_uint64_test.go @@ -56,7 +56,7 @@ func Test_Uint64_JSON(t *testing.T) { i2 := gtype.NewUint64() err := json.UnmarshalUseNumber(b2, &i2) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(i2.Val(), i) }) } @@ -72,7 +72,7 @@ func Test_Uint64_UnmarshalValue(t *testing.T) { "name": "john", "var": "123", }, &v) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(v.Name, "john") t.Assert(v.Var.Val(), "123") }) diff --git a/container/gtype/gtype_z_unit_uint_test.go b/container/gtype/gtype_z_unit_uint_test.go index 4521e6d6f..56d564d72 100644 --- a/container/gtype/gtype_z_unit_uint_test.go +++ b/container/gtype/gtype_z_unit_uint_test.go @@ -51,7 +51,7 @@ func Test_Uint_JSON(t *testing.T) { i2 := gtype.NewUint() err := json.UnmarshalUseNumber(b2, &i2) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(i2.Val(), i) }) } @@ -67,7 +67,7 @@ func Test_Uint_UnmarshalValue(t *testing.T) { "name": "john", "var": "123", }, &v) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(v.Name, "john") t.Assert(v.Var.Val(), "123") }) diff --git a/container/gvar/gvar_z_unit_basic_test.go b/container/gvar/gvar_z_unit_basic_test.go index a9592b81f..b6109448e 100644 --- a/container/gvar/gvar_z_unit_basic_test.go +++ b/container/gvar/gvar_z_unit_basic_test.go @@ -253,7 +253,7 @@ func Test_UnmarshalJson(t *testing.T) { "name": "john", "var": "v", }, &v) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(v.Name, "john") t.Assert(v.Var.String(), "v") }) @@ -267,7 +267,7 @@ func Test_UnmarshalJson(t *testing.T) { "name": "john", "var": "v", }, &v) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(v.Name, "john") t.Assert(v.Var.String(), "v") }) @@ -284,7 +284,7 @@ func Test_UnmarshalValue(t *testing.T) { "name": "john", "var": "v", }, &v) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(v.Name, "john") t.Assert(v.Var.String(), "v") }) @@ -298,7 +298,7 @@ func Test_UnmarshalValue(t *testing.T) { "name": "john", "var": "v", }, &v) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(v.Name, "john") t.Assert(v.Var.String(), "v") }) diff --git a/container/gvar/gvar_z_unit_json_test.go b/container/gvar/gvar_z_unit_json_test.go index d5df2f8ef..29ea08006 100644 --- a/container/gvar/gvar_z_unit_json_test.go +++ b/container/gvar/gvar_z_unit_json_test.go @@ -40,10 +40,10 @@ func TestVar_Json(t *testing.T) { s := "i love gf" v := gvar.New(nil) b, err := json.Marshal(s) - t.Assert(err, nil) + t.AssertNil(err) err = json.UnmarshalUseNumber(b, v) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(v.String(), s) }) @@ -51,10 +51,10 @@ func TestVar_Json(t *testing.T) { var v gvar.Var s := "i love gf" b, err := json.Marshal(s) - t.Assert(err, nil) + t.AssertNil(err) err = json.UnmarshalUseNumber(b, &v) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(v.String(), s) }) } diff --git a/container/gvar/gvar_z_unit_struct_test.go b/container/gvar/gvar_z_unit_struct_test.go index f397acadb..7b9e12b49 100644 --- a/container/gvar/gvar_z_unit_struct_test.go +++ b/container/gvar/gvar_z_unit_struct_test.go @@ -55,7 +55,7 @@ func TestVar_Var_Attribute_Struct(t *testing.T) { "uid": gvar.New(1), "name": gvar.New("john"), }, user) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(user.Uid, 1) t.Assert(user.Name, "john") }) @@ -70,7 +70,7 @@ func TestVar_Var_Attribute_Struct(t *testing.T) { "uid": gvar.New(1), "name": gvar.New("john"), }, &user) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(user.Uid, 1) t.Assert(user.Name, "john") }) diff --git a/crypto/gaes/gaes_z_unit_test.go b/crypto/gaes/gaes_z_unit_test.go index 75ca55b3c..052b39731 100644 --- a/crypto/gaes/gaes_z_unit_test.go +++ b/crypto/gaes/gaes_z_unit_test.go @@ -41,19 +41,19 @@ var ( func TestEncrypt(t *testing.T) { gtest.C(t, func(t *gtest.T) { data, err := gaes.Encrypt(content, key_16) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(data, []byte(content_16)) data, err = gaes.Encrypt(content, key_24) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(data, []byte(content_24)) data, err = gaes.Encrypt(content, key_32) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(data, []byte(content_32)) data, err = gaes.Encrypt(content, key_16, iv) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(data, []byte(content_16_iv)) data, err = gaes.Encrypt(content, key_32, iv) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(data, []byte(content_32_iv)) }) } @@ -61,23 +61,23 @@ func TestEncrypt(t *testing.T) { func TestDecrypt(t *testing.T) { gtest.C(t, func(t *gtest.T) { decrypt, err := gaes.Decrypt([]byte(content_16), key_16) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(decrypt, content) decrypt, err = gaes.Decrypt([]byte(content_24), key_24) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(decrypt, content) decrypt, err = gaes.Decrypt([]byte(content_32), key_32) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(decrypt, content) decrypt, err = gaes.Decrypt([]byte(content_16_iv), key_16, iv) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(decrypt, content) decrypt, err = gaes.Decrypt([]byte(content_32_iv), key_32, iv) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(decrypt, content) decrypt, err = gaes.Decrypt([]byte(content_32_iv), keys, iv) @@ -134,7 +134,7 @@ func TestEncryptCFB(t *testing.T) { gtest.C(t, func(t *gtest.T) { var padding int = 0 data, err := gaes.EncryptCFB(content, key_16, &padding, iv) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(padding, padding_size) t.Assert(data, []byte(content_16_cfb)) }) @@ -143,7 +143,7 @@ func TestEncryptCFB(t *testing.T) { func TestDecryptCFB(t *testing.T) { gtest.C(t, func(t *gtest.T) { decrypt, err := gaes.DecryptCFB([]byte(content_16_cfb), key_16, padding_size, iv) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(decrypt, content) }) } diff --git a/crypto/gmd5/gmd5_z_unit_test.go b/crypto/gmd5/gmd5_z_unit_test.go index 697371250..95292a19c 100644 --- a/crypto/gmd5/gmd5_z_unit_test.go +++ b/crypto/gmd5/gmd5_z_unit_test.go @@ -65,7 +65,7 @@ func TestEncryptFile(t *testing.T) { file, err := os.Create(path) defer os.Remove(path) defer file.Close() - t.Assert(err, nil) + t.AssertNil(err) _, _ = file.Write([]byte("Hello Go Frame")) encryptFile, _ := gmd5.EncryptFile(path) t.AssertEQ(encryptFile, result) diff --git a/crypto/gsha1/gsha1_z_unit_test.go b/crypto/gsha1/gsha1_z_unit_test.go index 881cf3516..ea90cf725 100644 --- a/crypto/gsha1/gsha1_z_unit_test.go +++ b/crypto/gsha1/gsha1_z_unit_test.go @@ -48,7 +48,7 @@ func TestEncryptFile(t *testing.T) { file, err := os.Create(path) defer os.Remove(path) defer file.Close() - t.Assert(err, nil) + t.AssertNil(err) _, _ = file.Write([]byte("Hello Go Frame")) encryptFile, _ := gsha1.EncryptFile(path) t.AssertEQ(encryptFile, result) diff --git a/database/gdb/gdb_z_mysql_feature_with_test.go b/database/gdb/gdb_z_mysql_feature_with_test.go index 243e83d76..3175cb2d9 100644 --- a/database/gdb/gdb_z_mysql_feature_with_test.go +++ b/database/gdb/gdb_z_mysql_feature_with_test.go @@ -353,20 +353,20 @@ PRIMARY KEY (id) "id": i, "name": fmt.Sprintf(`name_%d`, i), }) - gtest.Assert(err, nil) + gtest.AssertNil(err) // Detail. _, err = db.Insert(ctx, tableUserDetail, g.Map{ "uid": i, "address": fmt.Sprintf(`address_%d`, i), }) - gtest.Assert(err, nil) + gtest.AssertNil(err) // Scores. for j := 1; j <= 5; j++ { _, err = db.Insert(ctx, tableUserScores, g.Map{ "uid": i, "score": j, }) - gtest.Assert(err, nil) + gtest.AssertNil(err) } } @@ -553,20 +553,20 @@ PRIMARY KEY (id) "id": i, "name": fmt.Sprintf(`name_%d`, i), }) - gtest.Assert(err, nil) + gtest.AssertNil(err) // Detail. _, err = db.Insert(ctx, tableUserDetail, g.Map{ "uid": i, "address": fmt.Sprintf(`address_%d`, i), }) - gtest.Assert(err, nil) + gtest.AssertNil(err) // Scores. for j := 1; j <= 5; j++ { _, err = db.Insert(ctx, tableUserScores, g.Map{ "uid": i, "score": j, }) - gtest.Assert(err, nil) + gtest.AssertNil(err) } } gtest.C(t, func(t *gtest.T) { @@ -668,20 +668,20 @@ PRIMARY KEY (id) "id": i, "name": fmt.Sprintf(`name_%d`, i), }) - gtest.Assert(err, nil) + gtest.AssertNil(err) // Detail. _, err = db.Insert(ctx, tableUserDetail, g.Map{ "uid": i, "address": fmt.Sprintf(`address_%d`, i), }) - gtest.Assert(err, nil) + gtest.AssertNil(err) // Scores. for j := 1; j <= 5; j++ { _, err = db.Insert(ctx, tableUserScores, g.Map{ "uid": i, "score": j, }) - gtest.Assert(err, nil) + gtest.AssertNil(err) } } gtest.C(t, func(t *gtest.T) { @@ -809,20 +809,20 @@ PRIMARY KEY (id) "id": i, "name": fmt.Sprintf(`name_%d`, i), }) - gtest.Assert(err, nil) + gtest.AssertNil(err) // Detail. _, err = db.Insert(ctx, tableUserDetail, g.Map{ "uid": i, "address": fmt.Sprintf(`address_%d`, i), }) - gtest.Assert(err, nil) + gtest.AssertNil(err) // Scores. for j := 1; j <= 5; j++ { _, err = db.Insert(ctx, tableUserScores, g.Map{ "uid": i, "score": j, }) - gtest.Assert(err, nil) + gtest.AssertNil(err) } } @@ -945,20 +945,20 @@ PRIMARY KEY (id) "id": i, "name": fmt.Sprintf(`name_%d`, i), }) - gtest.Assert(err, nil) + gtest.AssertNil(err) // Detail. _, err = db.Insert(ctx, tableUserDetail, g.Map{ "uid": i, "address": fmt.Sprintf(`address_%d`, i), }) - gtest.Assert(err, nil) + gtest.AssertNil(err) // Scores. for j := 1; j <= 5; j++ { _, err = db.Insert(ctx, tableUserScores, g.Map{ "uid": i, "score": j, }) - gtest.Assert(err, nil) + gtest.AssertNil(err) } } gtest.C(t, func(t *gtest.T) { @@ -1065,20 +1065,20 @@ PRIMARY KEY (id) "id": i, "name": fmt.Sprintf(`name_%d`, i), }) - gtest.Assert(err, nil) + gtest.AssertNil(err) // Detail. _, err = db.Insert(ctx, tableUserDetail, g.Map{ "uid": i, "address": fmt.Sprintf(`address_%d`, i), }) - gtest.Assert(err, nil) + gtest.AssertNil(err) // Scores. for j := 1; j <= 5; j++ { _, err = db.Insert(ctx, tableUserScores, g.Map{ "uid": i, "score": j, }) - gtest.Assert(err, nil) + gtest.AssertNil(err) } } db.SetDebug(true) @@ -1184,20 +1184,20 @@ PRIMARY KEY (id) "id": i, "name": fmt.Sprintf(`name_%d`, i), }) - gtest.Assert(err, nil) + gtest.AssertNil(err) // Detail. _, err = db.Insert(ctx, tableUserDetail, g.Map{ "uid": i, "address": fmt.Sprintf(`address_%d`, i), }) - gtest.Assert(err, nil) + gtest.AssertNil(err) // Scores. for j := 1; j <= 5; j++ { _, err = db.Insert(ctx, tableUserScores, g.Map{ "uid": i, "score": j, }) - gtest.Assert(err, nil) + gtest.AssertNil(err) } } gtest.C(t, func(t *gtest.T) { @@ -1299,20 +1299,20 @@ PRIMARY KEY (id) "id": i, "name": fmt.Sprintf(`name_%d`, i), }) - gtest.Assert(err, nil) + gtest.AssertNil(err) // Detail. _, err = db.Insert(ctx, tableUserDetail, g.Map{ "uid": i, "address": fmt.Sprintf(`address_%d`, i), }) - gtest.Assert(err, nil) + gtest.AssertNil(err) // Scores. for j := 1; j <= 5; j++ { _, err = db.Insert(ctx, tableUserScores, g.Map{ "uid": i, "score": j, }) - gtest.Assert(err, nil) + gtest.AssertNil(err) } } @@ -1439,20 +1439,20 @@ PRIMARY KEY (id) "id": i, "name": fmt.Sprintf(`name_%d`, i), }) - gtest.Assert(err, nil) + gtest.AssertNil(err) // Detail. _, err = db.Insert(ctx, tableUserDetail, g.Map{ "uid": i, "address": fmt.Sprintf(`address_%d`, i), }) - gtest.Assert(err, nil) + gtest.AssertNil(err) // Scores. for j := 1; j <= 5; j++ { _, err = db.Insert(ctx, tableUserScores, g.Map{ "uid": i, "score": j, }) - gtest.Assert(err, nil) + gtest.AssertNil(err) } } @@ -1585,20 +1585,20 @@ PRIMARY KEY (id) "id": i, "name": fmt.Sprintf(`name_%d`, i), }) - gtest.Assert(err, nil) + gtest.AssertNil(err) // Detail. _, err = db.Insert(ctx, tableUserDetail, g.Map{ "uid": i, "address": fmt.Sprintf(`address_%d`, i), }) - gtest.Assert(err, nil) + gtest.AssertNil(err) // Scores. for j := 1; j <= 5; j++ { _, err = db.Insert(ctx, tableUserScores, g.Map{ "uid": i, "score": j, }) - gtest.Assert(err, nil) + gtest.AssertNil(err) } } diff --git a/database/gdb/gdb_z_mysql_model_test.go b/database/gdb/gdb_z_mysql_model_test.go index f9f87dcd1..4b941e223 100644 --- a/database/gdb/gdb_z_mysql_model_test.go +++ b/database/gdb/gdb_z_mysql_model_test.go @@ -2067,7 +2067,7 @@ func Test_Model_OmitEmpty(t *testing.T) { "id": 1, "name": "", }).Save() - t.Assert(err, nil) + t.AssertNil(err) }) } @@ -2096,14 +2096,14 @@ func Test_Model_OmitNil(t *testing.T) { "id": 1, "name": "", }).Save() - t.Assert(err, nil) + t.AssertNil(err) }) gtest.C(t, func(t *gtest.T) { _, err := db.Model(table).OmitNilWhere().Data(g.Map{ "id": 1, "name": "", }).Save() - t.Assert(err, nil) + t.AssertNil(err) }) } diff --git a/database/gredis/gredis_z_unit_conn_test.go b/database/gredis/gredis_z_unit_conn_test.go index f3f6b1bd0..d77c2ce1f 100644 --- a/database/gredis/gredis_z_unit_conn_test.go +++ b/database/gredis/gredis_z_unit_conn_test.go @@ -30,11 +30,11 @@ func TestConn_DoWithTimeout(t *testing.T) { defer conn.Close(ctx) _, err = conn.Do(ctx, "set", "test", "123") - t.Assert(err, nil) + t.AssertNil(err) defer conn.Do(ctx, "del", "test") r, err := conn.Do(ctx, "get", "test") - t.Assert(err, nil) + t.AssertNil(err) t.Assert(r.String(), "123") }) } diff --git a/database/gredis/gredis_z_unit_test.go b/database/gredis/gredis_z_unit_test.go index dfa5daa68..2671fbc97 100644 --- a/database/gredis/gredis_z_unit_test.go +++ b/database/gredis/gredis_z_unit_test.go @@ -46,16 +46,16 @@ func Test_Do(t *testing.T) { defer redis.Close(ctx) _, err = redis.Do(ctx, "SET", "k", "v") - t.Assert(err, nil) + t.AssertNil(err) r, err := redis.Do(ctx, "GET", "k") - t.Assert(err, nil) + t.AssertNil(err) t.Assert(r, []byte("v")) _, err = redis.Do(ctx, "DEL", "k") - t.Assert(err, nil) + t.AssertNil(err) r, err = redis.Do(ctx, "GET", "k") - t.Assert(err, nil) + t.AssertNil(err) t.Assert(r, nil) }) } @@ -74,16 +74,16 @@ func Test_Conn(t *testing.T) { key := gconv.String(gtime.TimestampNano()) value := []byte("v") r, err := conn.Do(ctx, "SET", key, value) - t.Assert(err, nil) + t.AssertNil(err) r, err = conn.Do(ctx, "GET", key) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(r, value) _, err = conn.Do(ctx, "DEL", key) - t.Assert(err, nil) + t.AssertNil(err) r, err = conn.Do(ctx, "GET", key) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(r, nil) }) } @@ -102,16 +102,16 @@ func Test_Instance(t *testing.T) { defer conn.Close(ctx) _, err = conn.Do(ctx, "SET", "k", "v") - t.Assert(err, nil) + t.AssertNil(err) r, err := conn.Do(ctx, "GET", "k") - t.Assert(err, nil) + t.AssertNil(err) t.Assert(r, []byte("v")) _, err = conn.Do(ctx, "DEL", "k") - t.Assert(err, nil) + t.AssertNil(err) r, err = conn.Do(ctx, "GET", "k") - t.Assert(err, nil) + t.AssertNil(err) t.Assert(r, nil) }) } @@ -153,10 +153,10 @@ func Test_Error(t *testing.T) { defer redis.Close(ctx) _, err = redis.Do(ctx, "SET", "k", "v") - t.Assert(err, nil) + t.AssertNil(err) v, err := redis.Do(ctx, "GET", "k") - t.Assert(err, nil) + t.AssertNil(err) t.Assert(v.String(), "v") conn, err := redis.Conn(ctx) @@ -197,17 +197,17 @@ func Test_Bool(t *testing.T) { }() _, err = redis.Do(ctx, "SET", "key-true", true) - t.Assert(err, nil) + t.AssertNil(err) _, err = redis.Do(ctx, "SET", "key-false", false) - t.Assert(err, nil) + t.AssertNil(err) r, err := redis.Do(ctx, "GET", "key-true") - t.Assert(err, nil) + t.AssertNil(err) t.Assert(r.Bool(), true) r, err = redis.Do(ctx, "GET", "key-false") - t.Assert(err, nil) + t.AssertNil(err) t.Assert(r.Bool(), false) }) } @@ -223,10 +223,10 @@ func Test_Int(t *testing.T) { defer redis.Do(ctx, "DEL", key) _, err = redis.Do(ctx, "SET", key, 1) - t.Assert(err, nil) + t.AssertNil(err) r, err := redis.Do(ctx, "GET", key) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(r.Int(), 1) }) } @@ -242,10 +242,10 @@ func Test_HSet(t *testing.T) { defer redis.Do(ctx, "DEL", key) _, err = redis.Do(ctx, "HSET", key, "name", "john") - t.Assert(err, nil) + t.AssertNil(err) r, err := redis.Do(ctx, "HGETALL", key) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(r.Strings(), g.ArrayStr{"name", "john"}) }) } @@ -262,12 +262,12 @@ func Test_HGetAll1(t *testing.T) { defer redis.Do(ctx, "DEL", key) _, err = redis.Do(ctx, "HSET", key, "id", 100) - t.Assert(err, nil) + t.AssertNil(err) _, err = redis.Do(ctx, "HSET", key, "name", "john") - t.Assert(err, nil) + t.AssertNil(err) r, err := redis.Do(ctx, "HGETALL", key) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(r.Map(), g.MapStrAny{ "id": 100, "name": "john", @@ -287,12 +287,12 @@ func Test_HGetAll2(t *testing.T) { defer redis.Do(ctx, "DEL", key) _, err = redis.Do(ctx, "HSET", key, "id", 100) - t.Assert(err, nil) + t.AssertNil(err) _, err = redis.Do(ctx, "HSET", key, "name", "john") - t.Assert(err, nil) + t.AssertNil(err) result, err := redis.Do(ctx, "HGETALL", key) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(gconv.Uint(result.MapStrVar()["id"]), 100) t.Assert(result.MapStrVar()["id"].Uint(), 100) @@ -317,9 +317,9 @@ func Test_HMSet(t *testing.T) { defer redis.Do(ctx, "DEL", key) _, err = redis.Do(ctx, "HMSET", append(g.Slice{key}, gutil.MapToSlice(data)...)...) - t.Assert(err, nil) + t.AssertNil(err) v, err := redis.Do(ctx, "HMGET", key, "name") - t.Assert(err, nil) + t.AssertNil(err) t.Assert(v.Slice(), g.Slice{data["name"]}) }) // struct @@ -344,9 +344,9 @@ func Test_HMSet(t *testing.T) { defer redis.Do(ctx, "DEL", key) _, err = redis.Do(ctx, "HMSET", append(g.Slice{key}, gutil.StructToSlice(data)...)...) - t.Assert(err, nil) + t.AssertNil(err) v, err := redis.Do(ctx, "HMGET", key, "name") - t.Assert(err, nil) + t.AssertNil(err) t.Assert(v.Slice(), g.Slice{data.Name}) }) } @@ -374,10 +374,10 @@ func Test_Auto_Marshal(t *testing.T) { } _, err = redis.Do(ctx, "SET", key, user) - t.Assert(err, nil) + t.AssertNil(err) r, err := redis.Do(ctx, "GET", key) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(r.Map(), g.MapStrAny{ "Id": user.Id, "Name": user.Name, @@ -418,14 +418,14 @@ func Test_Auto_MarshalSlice(t *testing.T) { ) _, err = redis.Do(ctx, "SET", key, users1) - t.Assert(err, nil) + t.AssertNil(err) result, err = redis.Do(ctx, "GET", key) - t.Assert(err, nil) + t.AssertNil(err) var users2 []User err = result.Structs(&users2) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(users2, users1) }) } diff --git a/encoding/gbase64/gbase64_z_unit_test.go b/encoding/gbase64/gbase64_z_unit_test.go index d77921e63..4e02ceada 100644 --- a/encoding/gbase64/gbase64_z_unit_test.go +++ b/encoding/gbase64/gbase64_z_unit_test.go @@ -70,12 +70,12 @@ func Test_File(t *testing.T) { expect := "dGVzdA==" gtest.C(t, func(t *gtest.T) { b, err := gbase64.EncodeFile(path) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(string(b), expect) }) gtest.C(t, func(t *gtest.T) { s, err := gbase64.EncodeFileToString(path) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(s, expect) }) } diff --git a/encoding/gcompress/gcompress_z_unit_gzip_test.go b/encoding/gcompress/gcompress_z_unit_gzip_test.go index a5836c3b1..4bc86a615 100644 --- a/encoding/gcompress/gcompress_z_unit_gzip_test.go +++ b/encoding/gcompress/gcompress_z_unit_gzip_test.go @@ -50,13 +50,13 @@ func Test_Gzip_UnGzip_File(t *testing.T) { // Compress. gtest.C(t, func(t *gtest.T) { err := gcompress.GzipFile(srcPath, dstPath1, 9) - t.Assert(err, nil) + t.AssertNil(err) defer gfile.Remove(dstPath1) t.Assert(gfile.Exists(dstPath1), true) // Decompress. err = gcompress.UnGzipFile(dstPath1, dstPath2) - t.Assert(err, nil) + t.AssertNil(err) defer gfile.Remove(dstPath2) t.Assert(gfile.Exists(dstPath2), true) diff --git a/encoding/gcompress/gcompress_z_unit_zip_test.go b/encoding/gcompress/gcompress_z_unit_zip_test.go index 45a40715f..b44069d4b 100644 --- a/encoding/gcompress/gcompress_z_unit_zip_test.go +++ b/encoding/gcompress/gcompress_z_unit_zip_test.go @@ -52,7 +52,7 @@ func Test_ZipPath(t *testing.T) { t.Assert(gfile.Exists(dstPath), false) err := gcompress.ZipPath(srcPath1+","+srcPath2, dstPath) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(gfile.Exists(dstPath), true) defer gfile.Remove(dstPath) @@ -60,7 +60,7 @@ func Test_ZipPath(t *testing.T) { tempDirPath := gfile.Temp(gtime.TimestampNanoStr()) t.Assert(gfile.Mkdir(tempDirPath), nil) err = gcompress.UnZipFile(dstPath, tempDirPath) - t.Assert(err, nil) + t.AssertNil(err) defer gfile.Remove(tempDirPath) t.Assert( @@ -85,7 +85,7 @@ func Test_ZipPath(t *testing.T) { t.Assert(gfile.Exists(dstPath), false) err := gcompress.ZipPath(srcPath1+","+srcPath2, dstPath) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(gfile.Exists(dstPath), true) defer gfile.Remove(dstPath) @@ -93,7 +93,7 @@ func Test_ZipPath(t *testing.T) { tempDirPath := gfile.Temp(gtime.TimestampNanoStr()) t.Assert(gfile.Mkdir(tempDirPath), nil) err = gcompress.UnZipFile(dstPath, tempDirPath) - t.Assert(err, nil) + t.AssertNil(err) defer gfile.Remove(tempDirPath) t.Assert( @@ -113,20 +113,20 @@ func Test_ZipPath(t *testing.T) { pwd := gfile.Pwd() err := gfile.Chdir(srcPath) defer gfile.Chdir(pwd) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(gfile.Exists(dstPath), false) err = gcompress.ZipPath(srcPath, dstPath) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(gfile.Exists(dstPath), true) defer gfile.Remove(dstPath) tempDirPath := gfile.Temp(gtime.TimestampNanoStr()) err = gfile.Mkdir(tempDirPath) - t.Assert(err, nil) + t.AssertNil(err) err = gcompress.UnZipFile(dstPath, tempDirPath) - t.Assert(err, nil) + t.AssertNil(err) defer gfile.Remove(tempDirPath) t.Assert( @@ -149,22 +149,22 @@ func Test_ZipPath(t *testing.T) { pwd := gfile.Pwd() err := gfile.Chdir(srcPath) defer gfile.Chdir(pwd) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(gfile.Exists(dstPath), false) err = gcompress.ZipPath(srcPath1+", "+srcPath2, dstPath) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(gfile.Exists(dstPath), true) defer gfile.Remove(dstPath) tempDirPath := gfile.Temp(gtime.TimestampNanoStr()) err = gfile.Mkdir(tempDirPath) - t.Assert(err, nil) + t.AssertNil(err) zipContent := gfile.GetBytes(dstPath) t.AssertGT(len(zipContent), 0) err = gcompress.UnZipContent(zipContent, tempDirPath) - t.Assert(err, nil) + t.AssertNil(err) defer gfile.Remove(tempDirPath) t.Assert( @@ -188,22 +188,22 @@ func Test_ZipPathWriter(t *testing.T) { pwd := gfile.Pwd() err := gfile.Chdir(srcPath) defer gfile.Chdir(pwd) - t.Assert(err, nil) + t.AssertNil(err) writer := bytes.NewBuffer(nil) t.Assert(writer.Len(), 0) err = gcompress.ZipPathWriter(srcPath1+", "+srcPath2, writer) - t.Assert(err, nil) + t.AssertNil(err) t.AssertGT(writer.Len(), 0) tempDirPath := gfile.Temp(gtime.TimestampNanoStr()) err = gfile.Mkdir(tempDirPath) - t.Assert(err, nil) + t.AssertNil(err) zipContent := writer.Bytes() t.AssertGT(len(zipContent), 0) err = gcompress.UnZipContent(zipContent, tempDirPath) - t.Assert(err, nil) + t.AssertNil(err) defer gfile.Remove(tempDirPath) t.Assert( diff --git a/encoding/ghtml/ghtml_z_unit_test.go b/encoding/ghtml/ghtml_z_unit_test.go index 0c70e2a85..8ac444753 100644 --- a/encoding/ghtml/ghtml_z_unit_test.go +++ b/encoding/ghtml/ghtml_z_unit_test.go @@ -47,7 +47,7 @@ func Test_SpecialCharsMapOrStruct_Map(t *testing.T) { "Content": "
C
", } err := ghtml.SpecialCharsMapOrStruct(a) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(a["Title"], `<h1>T</h1>`) t.Assert(a["Content"], `<div>C</div>`) }) @@ -57,7 +57,7 @@ func Test_SpecialCharsMapOrStruct_Map(t *testing.T) { "Content": "
C
", } err := ghtml.SpecialCharsMapOrStruct(a) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(a["Title"], `<h1>T</h1>`) t.Assert(a["Content"], `<div>C</div>`) }) @@ -74,7 +74,7 @@ func Test_SpecialCharsMapOrStruct_Struct(t *testing.T) { Content: "
C
", } err := ghtml.SpecialCharsMapOrStruct(a) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(a.Title, `<h1>T</h1>`) t.Assert(a.Content, `<div>C</div>`) }) diff --git a/encoding/gini/gini_z_unit_test.go b/encoding/gini/gini_z_unit_test.go index 2a3239bce..e3001f7f3 100644 --- a/encoding/gini/gini_z_unit_test.go +++ b/encoding/gini/gini_z_unit_test.go @@ -97,7 +97,7 @@ func TestToJson(t *testing.T) { } iniMap, err := gini.Decode([]byte(iniContent)) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(iniMap["addr"].(map[string]interface{})["ip"], json.Get("addr.ip").String()) t.Assert(iniMap["addr"].(map[string]interface{})["port"], json.Get("addr.port").String()) diff --git a/encoding/gjson/gjson_z_unit_feature_json_test.go b/encoding/gjson/gjson_z_unit_feature_json_test.go index a7d1f89ad..5e3cd3024 100644 --- a/encoding/gjson/gjson_z_unit_feature_json_test.go +++ b/encoding/gjson/gjson_z_unit_feature_json_test.go @@ -36,7 +36,7 @@ func Test_ToJson(t *testing.T) { jsonContent := `{"dataSetId":2001,"fieldInfos":{"duration":{"id":80079,"value":"59"},"om_level":{"id":2409,"value":"4"}},"id":"g0936lt1u0f","modifyFieldInfos":{"om_level":{"id":2409,"new":"4","old":""}},"timeStamp":1584599734}` var info MediaRequestModifyInfo err := gjson.DecodeTo(jsonContent, &info) - t.Assert(err, nil) + t.AssertNil(err) content := gjson.New(info).MustToJsonString() t.Assert(gstr.Contains(content, `"feed_id":""`), true) t.Assert(gstr.Contains(content, `"fieldInfos":{`), true) @@ -56,14 +56,14 @@ func Test_MapAttributeConvert(t *testing.T) { ` gtest.C(t, func(t *gtest.T) { j, err := gjson.LoadContent(data) - gtest.Assert(err, nil) + gtest.AssertNil(err) tx := struct { Title map[string]interface{} }{} err = j.Var().Scan(&tx) - gtest.Assert(err, nil) + gtest.AssertNil(err) t.Assert(tx.Title, g.Map{ "l1": "标签1", "l2": "标签2", }) @@ -76,14 +76,14 @@ func Test_MapAttributeConvert(t *testing.T) { gtest.C(t, func(t *gtest.T) { j, err := gjson.LoadContent(data) - gtest.Assert(err, nil) + gtest.AssertNil(err) tx := struct { Title map[string]string }{} err = j.Var().Scan(&tx) - gtest.Assert(err, nil) + gtest.AssertNil(err) t.Assert(tx.Title, g.Map{ "l1": "标签1", "l2": "标签2", }) diff --git a/encoding/gjson/gjson_z_unit_feature_load_test.go b/encoding/gjson/gjson_z_unit_feature_load_test.go index c4ae26bff..4517989a4 100644 --- a/encoding/gjson/gjson_z_unit_feature_load_test.go +++ b/encoding/gjson/gjson_z_unit_feature_load_test.go @@ -20,7 +20,7 @@ func Test_Load_JSON1(t *testing.T) { // JSON gtest.C(t, func(t *gtest.T) { j, err := gjson.LoadContent(data) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(j.Get("n").String(), "123456789") t.Assert(j.Get("m").Map(), g.Map{"k": "v"}) t.Assert(j.Get("m.k").String(), "v") @@ -39,7 +39,7 @@ func Test_Load_JSON1(t *testing.T) { gfile.PutBytes(path, data) defer gfile.Remove(path) j, err := gjson.Load(path, true) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(j.Get("n").String(), "123456789") t.Assert(j.Get("m").Map(), g.Map{"k": "v"}) t.Assert(j.Get("m.k").String(), "v") @@ -52,7 +52,7 @@ func Test_Load_JSON2(t *testing.T) { data := []byte(`{"n":123456789000000000000, "m":{"k":"v"}, "a":[1,2,3]}`) gtest.C(t, func(t *gtest.T) { j, err := gjson.LoadContent(data) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(j.Get("n").String(), "123456789000000000000") t.Assert(j.Get("m").Map(), g.Map{"k": "v"}) t.Assert(j.Get("m.k").String(), "v") @@ -66,7 +66,7 @@ func Test_Load_XML(t *testing.T) { // XML gtest.C(t, func(t *gtest.T) { j, err := gjson.LoadContent(data) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(j.Get("doc.n").String(), "123456789") t.Assert(j.Get("doc.m").Map(), g.Map{"k": "v"}) t.Assert(j.Get("doc.m.k").String(), "v") @@ -76,7 +76,7 @@ func Test_Load_XML(t *testing.T) { // XML gtest.C(t, func(t *gtest.T) { j, err := gjson.LoadXml(data, true) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(j.Get("doc.n").String(), "123456789") t.Assert(j.Get("doc.m").Map(), g.Map{"k": "v"}) t.Assert(j.Get("doc.m.k").String(), "v") @@ -95,7 +95,7 @@ func Test_Load_XML(t *testing.T) { gfile.PutBytes(path, data) defer gfile.Remove(path) j, err := gjson.Load(path) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(j.Get("doc.n").String(), "123456789") t.Assert(j.Get("doc.m").Map(), g.Map{"k": "v"}) t.Assert(j.Get("doc.m.k").String(), "v") @@ -116,7 +116,7 @@ func Test_Load_XML(t *testing.T) { ` j, err := gjson.LoadContent(xml) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(j.Get("Output.ipageIndex"), "2") t.Assert(j.Get("Output.itotalRecords"), "GF框架") }) @@ -135,7 +135,7 @@ m: // YAML gtest.C(t, func(t *gtest.T) { j, err := gjson.LoadContent(data) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(j.Get("n").String(), "123456789") t.Assert(j.Get("m").Map(), g.Map{"k": "v"}) t.Assert(j.Get("m.k").String(), "v") @@ -145,7 +145,7 @@ m: // YAML gtest.C(t, func(t *gtest.T) { j, err := gjson.LoadYaml(data, true) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(j.Get("n").String(), "123456789") t.Assert(j.Get("m").Map(), g.Map{"k": "v"}) t.Assert(j.Get("m.k").String(), "v") @@ -158,7 +158,7 @@ m: gfile.PutBytes(path, data) defer gfile.Remove(path) j, err := gjson.Load(path) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(j.Get("n").String(), "123456789") t.Assert(j.Get("m").Map(), g.Map{"k": "v"}) t.Assert(j.Get("m.k").String(), "v") @@ -171,7 +171,7 @@ func Test_Load_YAML2(t *testing.T) { data := []byte("i : 123456789") gtest.C(t, func(t *gtest.T) { j, err := gjson.LoadContent(data) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(j.Get("i"), "123456789") }) gtest.C(t, func(t *gtest.T) { @@ -192,7 +192,7 @@ n = 123456789 // TOML gtest.C(t, func(t *gtest.T) { j, err := gjson.LoadContent(data) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(j.Get("n").String(), "123456789") t.Assert(j.Get("m").Map(), g.Map{"k": "v"}) t.Assert(j.Get("m.k").String(), "v") @@ -202,7 +202,7 @@ n = 123456789 // TOML gtest.C(t, func(t *gtest.T) { j, err := gjson.LoadToml(data, true) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(j.Get("n").String(), "123456789") t.Assert(j.Get("m").Map(), g.Map{"k": "v"}) t.Assert(j.Get("m.k").String(), "v") @@ -215,7 +215,7 @@ n = 123456789 gfile.PutBytes(path, data) defer gfile.Remove(path) j, err := gjson.Load(path) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(j.Get("n").String(), "123456789") t.Assert(j.Get("m").Map(), g.Map{"k": "v"}) t.Assert(j.Get("m.k").String(), "v") @@ -228,7 +228,7 @@ func Test_Load_TOML2(t *testing.T) { data := []byte("i=123456789") gtest.C(t, func(t *gtest.T) { j, err := gjson.LoadContent(data) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(j.Get("i"), "123456789") }) gtest.C(t, func(t *gtest.T) { @@ -247,11 +247,11 @@ func Test_Load_Basic(t *testing.T) { _, err = gjson.DecodeToJson(nil) t.AssertNE(err, nil) j, err = gjson.LoadContent(nil) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(j.Interface(), nil) j, err = gjson.LoadContent(`{"name": "gf"}`) - t.Assert(err, nil) + t.AssertNil(err) j, err = gjson.LoadContent(`{"name": "gf"""}`) t.AssertNE(err, nil) diff --git a/encoding/gjson/gjson_z_unit_feature_new_test.go b/encoding/gjson/gjson_z_unit_feature_new_test.go index 38e844649..b5695af1b 100644 --- a/encoding/gjson/gjson_z_unit_feature_new_test.go +++ b/encoding/gjson/gjson_z_unit_feature_new_test.go @@ -65,7 +65,7 @@ func Test_New_CustomStruct(t *testing.T) { t.AssertNE(j, nil) s, err := j.ToJsonString() - t.Assert(err, nil) + t.AssertNil(err) t.Assert(s == `{"Id":1,"Name":"john"}` || s == `{"Name":"john","Id":1}`, true) }) } diff --git a/encoding/gjson/gjson_z_unit_feature_set_test.go b/encoding/gjson/gjson_z_unit_feature_set_test.go index a389d0f79..0e48d5290 100644 --- a/encoding/gjson/gjson_z_unit_feature_set_test.go +++ b/encoding/gjson/gjson_z_unit_feature_set_test.go @@ -236,7 +236,7 @@ func Test_Set15(t *testing.T) { t.Assert(j.Set("k", "v"), nil) s, err := j.ToJsonString() - t.Assert(err, nil) + t.AssertNil(err) t.Assert( gstr.Contains(s, `"root":[{"k1":"v1"},{"k2":"v2"}`) || gstr.Contains(s, `"root":[{"k2":"v2"},{"k1":"v1"}`), @@ -259,7 +259,7 @@ func Test_Set16(t *testing.T) { t.Assert(j.Set("description", "3"), nil) s, err := j.ToJsonString() - t.Assert(err, nil) + t.AssertNil(err) t.Assert( gstr.Contains(s, `"processors":[{"set":{"0field":"2","0value":"1"}}]`) || gstr.Contains(s, `"processors":[{"set":{"0value":"1","0field":"2"}}]`), @@ -282,7 +282,7 @@ func Test_Set17(t *testing.T) { t.Assert(j.Set("k", "v"), nil) s, err := j.ToJsonString() - t.Assert(err, nil) + t.AssertNil(err) t.Assert(s, `{"k":"v"}`) }) } @@ -294,7 +294,7 @@ func Test_Set18(t *testing.T) { t.Assert(j.Set("0.1.k1", "v1"), nil) t.Assert(j.Set("0.2.k2", "v2"), nil) s, err := j.ToJsonString() - t.Assert(err, nil) + t.AssertNil(err) t.Assert(s, `[[null,{"k1":"v1"},{"k2":"v2"}]]`) }) } @@ -306,7 +306,7 @@ func Test_Set19(t *testing.T) { t.Assert(j.Set("0.1.1.k1", "v1"), nil) t.Assert(j.Set("0.2.1.k2", "v2"), nil) s, err := j.ToJsonString() - t.Assert(err, nil) + t.AssertNil(err) t.Assert(s, `[[null,[null,{"k1":"v1"}],[null,{"k2":"v2"}]]]`) }) } @@ -320,7 +320,7 @@ func Test_Set20(t *testing.T) { t.Assert(j.Set("k2.1", 20), nil) t.Assert(j.Set("k2.2", g.Map{"k3": "v3"}), nil) s, err := j.ToJsonString() - t.Assert(err, nil) + t.AssertNil(err) t.Assert(gstr.InArray( g.SliceStr{ `{"k1":"v1","k2":[1,20,{"k3":"v3"}]}`, diff --git a/encoding/gjson/gjson_z_unit_feature_struct_test.go b/encoding/gjson/gjson_z_unit_feature_struct_test.go index b7c514ff2..49f7c0a4a 100644 --- a/encoding/gjson/gjson_z_unit_feature_struct_test.go +++ b/encoding/gjson/gjson_z_unit_feature_struct_test.go @@ -22,7 +22,7 @@ func Test_GetScan(t *testing.T) { gtest.C(t, func(t *gtest.T) { var user *User err := j.Get("1").Scan(&user) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(user, &User{ Name: "smith", Score: 60, @@ -31,7 +31,7 @@ func Test_GetScan(t *testing.T) { gtest.C(t, func(t *gtest.T) { var users []User err := j.Get(".").Scan(&users) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(users, []User{ { Name: "john", @@ -54,7 +54,7 @@ func Test_GetScanDeep(t *testing.T) { gtest.C(t, func(t *gtest.T) { var user *User err := j.Get("1").Scan(&user) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(user, &User{ Name: "smith", Score: 60, @@ -63,7 +63,7 @@ func Test_GetScanDeep(t *testing.T) { gtest.C(t, func(t *gtest.T) { var users []User err := j.Get(".").Scan(&users) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(users, []User{ { Name: "john", @@ -86,7 +86,7 @@ func Test_Scan1(t *testing.T) { gtest.C(t, func(t *gtest.T) { var users []User err := j.Var().Scan(&users) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(users, []User{ { Name: "john", @@ -109,7 +109,7 @@ func Test_Scan2(t *testing.T) { gtest.C(t, func(t *gtest.T) { var users []User err := j.Var().Scan(&users) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(users, []User{ { Name: "john", @@ -198,9 +198,9 @@ func Test_Struct1(t *testing.T) { }` data := new(UserCollectionAddReq) j, err := gjson.LoadJson(jsonContent, true) - t.Assert(err, nil) + t.AssertNil(err) err = j.Scan(data) - t.Assert(err, nil) + t.AssertNil(err) }) } @@ -226,14 +226,14 @@ func Test_Struct(t *testing.T) { }` j, err := gjson.LoadContent(txt) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(j.Get("me.name").String(), "mikey") t.Assert(j.Get("items").String(), "") t.Assert(j.Get("items").Bool(), false) t.Assert(j.Get("items").Array(), nil) m := new(M) err = j.Scan(m) - t.Assert(err, nil) + t.AssertNil(err) t.AssertNE(m.Me, nil) t.Assert(m.Me["day"], "20009") t.Assert(m.Items, nil) @@ -289,10 +289,10 @@ func Test_Struct_Complicated(t *testing.T) { ] }` j, err := gjson.LoadContent(jsonContent) - t.Assert(err, nil) + t.AssertNil(err) var response = new(Response) err = j.Scan(response) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(len(response.CertList), 3) t.Assert(response.CertList[0].CertID, 2023313) t.Assert(response.CertList[1].CertID, 2023314) diff --git a/encoding/gjson/gjson_z_unit_implements_test.go b/encoding/gjson/gjson_z_unit_implements_test.go index e0aaec6f2..a47746e3d 100644 --- a/encoding/gjson/gjson_z_unit_implements_test.go +++ b/encoding/gjson/gjson_z_unit_implements_test.go @@ -24,7 +24,7 @@ func TestJson_UnmarshalJSON(t *testing.T) { j = gjson.New(nil) err = json.UnmarshalUseNumber(data, j) ) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(j.Get(".").String(), `["a","b","c"]`) t.Assert(j.Get("2").String(), `c`) }) @@ -35,7 +35,7 @@ func TestJson_UnmarshalJSON(t *testing.T) { j = gjson.New(nil) err = json.UnmarshalUseNumber(data, j) ) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(j.Get(".").String(), `[{"a":1},{"b":2},{"c":3}]`) t.Assert(j.Get("2.c").String(), `3`) }) @@ -46,7 +46,7 @@ func TestJson_UnmarshalJSON(t *testing.T) { j = gjson.New(nil) err = json.UnmarshalUseNumber(data, j) ) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(j.Get("n").String(), "123456789") t.Assert(j.Get("m").Map(), g.Map{"k": "v"}) t.Assert(j.Get("m.k").String(), "v") @@ -68,7 +68,7 @@ func TestJson_UnmarshalValue(t *testing.T) { "name": "john", "json": []byte(`{"n":123456789, "m":{"k":"v"}, "a":[1,2,3]}`), }, &v) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(v.Name, "john") t.Assert(v.Json.Get("n").String(), "123456789") t.Assert(v.Json.Get("m").Map(), g.Map{"k": "v"}) @@ -83,7 +83,7 @@ func TestJson_UnmarshalValue(t *testing.T) { "name": "john", "json": `["a", "b", "c"]`, }, &v) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(v.Name, "john") t.Assert(v.Json.Get(".").String(), `["a","b","c"]`) t.Assert(v.Json.Get("2").String(), `c`) @@ -95,7 +95,7 @@ func TestJson_UnmarshalValue(t *testing.T) { "name": "john", "json": `[{"a":1},{"b":2},{"c":3}]`, }, &v) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(v.Name, "john") t.Assert(v.Json.Get(".").String(), `[{"a":1},{"b":2},{"c":3}]`) t.Assert(v.Json.Get("2.c").String(), `3`) @@ -111,7 +111,7 @@ func TestJson_UnmarshalValue(t *testing.T) { "a": g.Slice{1, 2, 3}, }, }, &v) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(v.Name, "john") t.Assert(v.Json.Get("n").String(), "123456789") t.Assert(v.Json.Get("m").Map(), g.Map{"k": "v"}) diff --git a/encoding/gjson/gjson_z_unit_test.go b/encoding/gjson/gjson_z_unit_test.go index cc07a1d49..6691024c6 100644 --- a/encoding/gjson/gjson_z_unit_test.go +++ b/encoding/gjson/gjson_z_unit_test.go @@ -66,7 +66,7 @@ func Test_Encode(t *testing.T) { value := g.Slice{1, 2, 3} gtest.C(t, func(t *gtest.T) { b, err := gjson.Encode(value) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(b, []byte(`[1,2,3]`)) }) } @@ -75,7 +75,7 @@ func Test_Decode(t *testing.T) { data := []byte(`{"n":123456789, "m":{"k":"v"}, "a":[1,2,3]}`) gtest.C(t, func(t *gtest.T) { v, err := gjson.Decode(data) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(v, g.Map{ "n": 123456789, "a": g.Slice{1, 2, 3}, @@ -87,7 +87,7 @@ func Test_Decode(t *testing.T) { gtest.C(t, func(t *gtest.T) { var v interface{} err := gjson.DecodeTo(data, &v) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(v, g.Map{ "n": 123456789, "a": g.Slice{1, 2, 3}, @@ -98,7 +98,7 @@ func Test_Decode(t *testing.T) { }) gtest.C(t, func(t *gtest.T) { j, err := gjson.DecodeToJson(data) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(j.Get("n").String(), "123456789") t.Assert(j.Get("m").Map(), g.Map{"k": "v"}) t.Assert(j.Get("m.k"), "v") @@ -112,7 +112,7 @@ func Test_SplitChar(t *testing.T) { gtest.C(t, func(t *gtest.T) { j, err := gjson.DecodeToJson(data) j.SetSplitChar(byte('#')) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(j.Get("n").String(), "123456789") t.Assert(j.Get("m").Map(), g.Map{"k": "v"}) t.Assert(j.Get("m#k").String(), "v") @@ -125,7 +125,7 @@ func Test_ViolenceCheck(t *testing.T) { data := []byte(`{"m":{"a":[1,2,3], "v1.v2":"4"}}`) gtest.C(t, func(t *gtest.T) { j, err := gjson.DecodeToJson(data) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(j.Get("m.a.2"), 3) t.Assert(j.Get("m.v1.v2"), nil) j.SetViolenceCheck(true) @@ -137,7 +137,7 @@ func Test_GetVar(t *testing.T) { data := []byte(`{"n":123456789, "m":{"k":"v"}, "a":[1,2,3]}`) gtest.C(t, func(t *gtest.T) { j, err := gjson.DecodeToJson(data) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(j.Get("n").String(), "123456789") t.Assert(j.Get("m").Map(), g.Map{"k": "v"}) t.Assert(j.Get("a").Interfaces(), g.Slice{1, 2, 3}) @@ -150,7 +150,7 @@ func Test_GetMap(t *testing.T) { data := []byte(`{"n":123456789, "m":{"k":"v"}, "a":[1,2,3]}`) gtest.C(t, func(t *gtest.T) { j, err := gjson.DecodeToJson(data) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(j.Get("n").Map(), nil) t.Assert(j.Get("m").Map(), g.Map{"k": "v"}) t.Assert(j.Get("a").Map(), g.Map{"1": "2", "3": nil}) @@ -161,7 +161,7 @@ func Test_GetJson(t *testing.T) { data := []byte(`{"n":123456789, "m":{"k":"v"}, "a":[1,2,3]}`) gtest.C(t, func(t *gtest.T) { j, err := gjson.DecodeToJson(data) - t.Assert(err, nil) + t.AssertNil(err) j2 := j.GetJson("m") t.AssertNE(j2, nil) t.Assert(j2.Get("k"), "v") @@ -174,7 +174,7 @@ func Test_GetArray(t *testing.T) { data := []byte(`{"n":123456789, "m":{"k":"v"}, "a":[1,2,3]}`) gtest.C(t, func(t *gtest.T) { j, err := gjson.DecodeToJson(data) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(j.Get("n").Array(), g.Array{123456789}) t.Assert(j.Get("m").Array(), g.Array{g.Map{"k": "v"}}) t.Assert(j.Get("a").Array(), g.Array{1, 2, 3}) @@ -185,7 +185,7 @@ func Test_GetString(t *testing.T) { data := []byte(`{"n":123456789, "m":{"k":"v"}, "a":[1,2,3]}`) gtest.C(t, func(t *gtest.T) { j, err := gjson.DecodeToJson(data) - t.Assert(err, nil) + t.AssertNil(err) t.AssertEQ(j.Get("n").String(), "123456789") t.AssertEQ(j.Get("m").String(), `{"k":"v"}`) t.AssertEQ(j.Get("a").String(), `[1,2,3]`) @@ -197,7 +197,7 @@ func Test_GetStrings(t *testing.T) { data := []byte(`{"n":123456789, "m":{"k":"v"}, "a":[1,2,3]}`) gtest.C(t, func(t *gtest.T) { j, err := gjson.DecodeToJson(data) - t.Assert(err, nil) + t.AssertNil(err) t.AssertEQ(j.Get("n").Strings(), g.SliceStr{"123456789"}) t.AssertEQ(j.Get("m").Strings(), g.SliceStr{`{"k":"v"}`}) t.AssertEQ(j.Get("a").Strings(), g.SliceStr{"1", "2", "3"}) @@ -209,7 +209,7 @@ func Test_GetInterfaces(t *testing.T) { data := []byte(`{"n":123456789, "m":{"k":"v"}, "a":[1,2,3]}`) gtest.C(t, func(t *gtest.T) { j, err := gjson.DecodeToJson(data) - t.Assert(err, nil) + t.AssertNil(err) t.AssertEQ(j.Get("n").Interfaces(), g.Array{123456789}) t.AssertEQ(j.Get("m").Interfaces(), g.Array{g.Map{"k": "v"}}) t.AssertEQ(j.Get("a").Interfaces(), g.Array{1, 2, 3}) @@ -332,37 +332,37 @@ func Test_Convert(t *testing.T) { gtest.C(t, func(t *gtest.T) { j := gjson.New(`{"name":"gf"}`) arr, err := j.ToXml() - t.Assert(err, nil) + t.AssertNil(err) t.Assert(string(arr), "gf") arr, err = j.ToXmlIndent() - t.Assert(err, nil) + t.AssertNil(err) t.Assert(string(arr), "gf") str, err := j.ToXmlString() - t.Assert(err, nil) + t.AssertNil(err) t.Assert(str, "gf") str, err = j.ToXmlIndentString() - t.Assert(err, nil) + t.AssertNil(err) t.Assert(str, "gf") arr, err = j.ToJsonIndent() - t.Assert(err, nil) + t.AssertNil(err) t.Assert(string(arr), "{\n\t\"name\": \"gf\"\n}") str, err = j.ToJsonIndentString() - t.Assert(err, nil) + t.AssertNil(err) t.Assert(string(arr), "{\n\t\"name\": \"gf\"\n}") arr, err = j.ToYaml() - t.Assert(err, nil) + t.AssertNil(err) t.Assert(string(arr), "name: gf\n") str, err = j.ToYamlString() - t.Assert(err, nil) + t.AssertNil(err) t.Assert(string(arr), "name: gf\n") arr, err = j.ToToml() - t.Assert(err, nil) + t.AssertNil(err) t.Assert(string(arr), "name = \"gf\"\n") str, err = j.ToTomlString() - t.Assert(err, nil) + t.AssertNil(err) t.Assert(string(arr), "name = \"gf\"\n") }) } @@ -387,19 +387,19 @@ func Test_Convert2(t *testing.T) { t.Assert(j.Get("time").Duration().String(), "0s") err := j.Var().Scan(&name) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(name.Name, "gf") // j.Dump() - t.Assert(err, nil) + t.AssertNil(err) j = gjson.New(`{"person":{"name":"gf"}}`) err = j.Get("person").Scan(&name) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(name.Name, "gf") j = gjson.New(`{"name":"gf""}`) // j.Dump() - t.Assert(err, nil) + t.AssertNil(err) j = gjson.New(`[1,2,3]`) t.Assert(len(j.Var().Array()), 3) @@ -417,12 +417,12 @@ func Test_Basic(t *testing.T) { t.Assert(j.Get(".").Interface().(g.Map)["name"], "gf") err := j.Set("name", "gf1") - t.Assert(err, nil) + t.AssertNil(err) t.Assert(j.Get("name"), "gf1") j = gjson.New(`[1,2,3]`) err = j.Set("\"0\".1", 11) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(j.Get("1"), 11) j = gjson.New(`[1,2,3]`) @@ -431,7 +431,7 @@ func Test_Basic(t *testing.T) { j = gjson.New(`[1,2,3]`) err = j.Remove("1") - t.Assert(err, nil) + t.AssertNil(err) t.Assert(j.Get("0"), 1) t.Assert(len(j.Var().Array()), 2) @@ -445,18 +445,18 @@ func Test_Basic(t *testing.T) { j = gjson.New(`[1,2,3]`) err = j.Remove("3") - t.Assert(err, nil) + t.AssertNil(err) t.Assert(j.Get("0"), 1) t.Assert(len(j.Var().Array()), 3) j = gjson.New(`[1,2,3]`) err = j.Remove("0.3") - t.Assert(err, nil) + t.AssertNil(err) t.Assert(j.Get("0"), 1) j = gjson.New(`[1,2,3]`) err = j.Remove("0.a") - t.Assert(err, nil) + t.AssertNil(err) t.Assert(j.Get("0"), 1) name := struct { @@ -465,35 +465,35 @@ func Test_Basic(t *testing.T) { j = gjson.New(name) t.Assert(j.Get("Name"), "gf") err = j.Remove("Name") - t.Assert(err, nil) + t.AssertNil(err) t.Assert(j.Get("Name"), nil) err = j.Set("Name", "gf1") - t.Assert(err, nil) + t.AssertNil(err) t.Assert(j.Get("Name"), "gf1") j = gjson.New(nil) err = j.Remove("Name") - t.Assert(err, nil) + t.AssertNil(err) t.Assert(j.Get("Name"), nil) j = gjson.New(name) t.Assert(j.Get("Name"), "gf") err = j.Set("Name1", g.Map{"Name": "gf1"}) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(j.Get("Name1").Interface().(g.Map)["Name"], "gf1") err = j.Set("Name2", g.Slice{1, 2, 3}) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(j.Get("Name2").Interface().(g.Slice)[0], 1) err = j.Set("Name3", name) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(j.Get("Name3").Interface().(g.Map)["Name"], "gf") err = j.Set("Name4", &name) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(j.Get("Name4").Interface().(g.Map)["Name"], "gf") arr := [3]int{1, 2, 3} err = j.Set("Name5", arr) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(j.Get("Name5").Interface().(g.Array)[0], 1) }) diff --git a/encoding/gxml/gxml_z_unit_test.go b/encoding/gxml/gxml_z_unit_test.go index 35a80e32a..649e730fc 100644 --- a/encoding/gxml/gxml_z_unit_test.go +++ b/encoding/gxml/gxml_z_unit_test.go @@ -112,7 +112,7 @@ func Test_Decode2(t *testing.T) { johngcn123456123456 ` m, err := gxml.Decode([]byte(content)) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(m["doc"].(map[string]interface{})["username"], "johngcn") t.Assert(m["doc"].(map[string]interface{})["password1"], "123456") t.Assert(m["doc"].(map[string]interface{})["password2"], "123456") @@ -125,7 +125,7 @@ func Test_DecodeWitoutRoot(t *testing.T) { johngcn123456123456 ` m, err := gxml.DecodeWithoutRoot([]byte(content)) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(m["username"], "johngcn") t.Assert(m["password1"], "123456") t.Assert(m["password2"], "123456") diff --git a/encoding/gyaml/gyaml_z_unit_test.go b/encoding/gyaml/gyaml_z_unit_test.go index c840f4ef0..10a480982 100644 --- a/encoding/gyaml/gyaml_z_unit_test.go +++ b/encoding/gyaml/gyaml_z_unit_test.go @@ -74,7 +74,7 @@ func Test_EncodeIndent(t *testing.T) { func Test_Decode(t *testing.T) { gtest.C(t, func(t *gtest.T) { result, err := gyaml.Decode([]byte(yamlStr)) - t.Assert(err, nil) + t.AssertNil(err) m, ok := result.(map[string]interface{}) t.Assert(ok, true) @@ -92,7 +92,7 @@ func Test_DecodeTo(t *testing.T) { gtest.C(t, func(t *gtest.T) { result := make(map[string]interface{}) err := gyaml.DecodeTo([]byte(yamlStr), &result) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(result, map[string]interface{}{ "url": "https://goframe.org", "server": g.Slice{"120.168.117.21", "120.168.117.22"}, @@ -121,9 +121,9 @@ m: k: v `) v, err := gyaml.Decode(data) - t.Assert(err, nil) + t.AssertNil(err) b, err := json.Marshal(v) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(b, `{"m":{"k":"v"}}`) }) } diff --git a/errors/gerror/gerror_z_unit_test.go b/errors/gerror/gerror_z_unit_test.go index f4aa6b2df..228cb91df 100644 --- a/errors/gerror/gerror_z_unit_test.go +++ b/errors/gerror/gerror_z_unit_test.go @@ -251,7 +251,7 @@ func Test_Next(t *testing.T) { t.Assert(err.Error(), "1") err = gerror.Next(err) - t.Assert(err, nil) + t.AssertNil(err) }) } diff --git a/frame/gins/gins_z_unit_config_test.go b/frame/gins/gins_z_unit_config_test.go index 1395e34d6..ddfc98915 100644 --- a/frame/gins/gins_z_unit_config_test.go +++ b/frame/gins/gins_z_unit_config_test.go @@ -42,15 +42,15 @@ func Test_Config2(t *testing.T) { var err error dirPath := gfile.Temp(gtime.TimestampNanoStr()) err = gfile.Mkdir(dirPath) - t.Assert(err, nil) + t.AssertNil(err) defer gfile.Remove(dirPath) name := "config.toml" err = gfile.PutContents(gfile.Join(dirPath, name), configContent) - t.Assert(err, nil) + t.AssertNil(err) err = gins.Config().GetAdapter().(*gcfg.AdapterFile).AddPath(dirPath) - t.Assert(err, nil) + t.AssertNil(err) defer gins.Config().GetAdapter().(*gcfg.AdapterFile).Clear() @@ -91,15 +91,15 @@ func Test_Config3(t *testing.T) { var err error dirPath := gfile.Temp(gtime.TimestampNanoStr()) err = gfile.Mkdir(dirPath) - t.Assert(err, nil) + t.AssertNil(err) defer gfile.Remove(dirPath) name := "test.toml" err = gfile.PutContents(gfile.Join(dirPath, name), configContent) - t.Assert(err, nil) + t.AssertNil(err) err = gins.Config("test").GetAdapter().(*gcfg.AdapterFile).AddPath(dirPath) - t.Assert(err, nil) + t.AssertNil(err) defer gins.Config("test").GetAdapter().(*gcfg.AdapterFile).Clear() gins.Config("test").GetAdapter().(*gcfg.AdapterFile).SetFileName("test.toml") @@ -115,15 +115,15 @@ func Test_Config3(t *testing.T) { var err error dirPath := gfile.Temp(gtime.TimestampNanoStr()) err = gfile.Mkdir(dirPath) - t.Assert(err, nil) + t.AssertNil(err) defer gfile.Remove(dirPath) name := "config/test.toml" err = gfile.PutContents(gfile.Join(dirPath, name), configContent) - t.Assert(err, nil) + t.AssertNil(err) err = gins.Config("test").GetAdapter().(*gcfg.AdapterFile).AddPath(dirPath) - t.Assert(err, nil) + t.AssertNil(err) defer gins.Config("test").GetAdapter().(*gcfg.AdapterFile).Clear() gins.Config("test").GetAdapter().(*gcfg.AdapterFile).SetFileName("test.toml") @@ -142,7 +142,7 @@ func Test_Config4(t *testing.T) { path := fmt.Sprintf(`%s/%d`, gfile.Temp(), gtime.TimestampNano()) file := fmt.Sprintf(`%s/%s`, path, "config.toml") err := gfile.PutContents(file, configContent) - t.Assert(err, nil) + t.AssertNil(err) defer gfile.Remove(file) defer gins.Config().GetAdapter().(*gcfg.AdapterFile).Clear() @@ -157,7 +157,7 @@ func Test_Config4(t *testing.T) { path := fmt.Sprintf(`%s/%d/config`, gfile.Temp(), gtime.TimestampNano()) file := fmt.Sprintf(`%s/%s`, path, "config.toml") err := gfile.PutContents(file, configContent) - t.Assert(err, nil) + t.AssertNil(err) defer gfile.Remove(file) defer gins.Config().GetAdapter().(*gcfg.AdapterFile).Clear() t.Assert(gins.Config().GetAdapter().(*gcfg.AdapterFile).AddPath(path), nil) @@ -171,7 +171,7 @@ func Test_Config4(t *testing.T) { path := fmt.Sprintf(`%s/%d`, gfile.Temp(), gtime.TimestampNano()) file := fmt.Sprintf(`%s/%s`, path, "test.toml") err := gfile.PutContents(file, configContent) - t.Assert(err, nil) + t.AssertNil(err) defer gfile.Remove(file) defer gins.Config("test").GetAdapter().(*gcfg.AdapterFile).Clear() gins.Config("test").GetAdapter().(*gcfg.AdapterFile).SetFileName("test.toml") @@ -186,7 +186,7 @@ func Test_Config4(t *testing.T) { path := fmt.Sprintf(`%s/%d/config`, gfile.Temp(), gtime.TimestampNano()) file := fmt.Sprintf(`%s/%s`, path, "test.toml") err := gfile.PutContents(file, configContent) - t.Assert(err, nil) + t.AssertNil(err) defer gfile.Remove(file) defer gins.Config().GetAdapter().(*gcfg.AdapterFile).Clear() gins.Config("test").GetAdapter().(*gcfg.AdapterFile).SetFileName("test.toml") diff --git a/frame/gins/gins_z_unit_database_test.go b/frame/gins/gins_z_unit_database_test.go index 6fd224f6f..5ec575660 100644 --- a/frame/gins/gins_z_unit_database_test.go +++ b/frame/gins/gins_z_unit_database_test.go @@ -26,15 +26,15 @@ func Test_Database(t *testing.T) { var err error dirPath := gfile.Temp(gtime.TimestampNanoStr()) err = gfile.Mkdir(dirPath) - t.Assert(err, nil) + t.AssertNil(err) defer gfile.Remove(dirPath) name := "config.toml" err = gfile.PutContents(gfile.Join(dirPath, name), databaseContent) - t.Assert(err, nil) + t.AssertNil(err) err = gins.Config().GetAdapter().(*gcfg.AdapterFile).AddPath(dirPath) - t.Assert(err, nil) + t.AssertNil(err) defer gins.Config().GetAdapter().(*gcfg.AdapterFile).Clear() diff --git a/frame/gins/gins_z_unit_redis_test.go b/frame/gins/gins_z_unit_redis_test.go index 7fe073a1a..237db241c 100644 --- a/frame/gins/gins_z_unit_redis_test.go +++ b/frame/gins/gins_z_unit_redis_test.go @@ -27,15 +27,15 @@ func Test_Redis(t *testing.T) { var err error dirPath := gfile.Temp(gtime.TimestampNanoStr()) err = gfile.Mkdir(dirPath) - t.Assert(err, nil) + t.AssertNil(err) defer gfile.Remove(dirPath) name := "config.toml" err = gfile.PutContents(gfile.Join(dirPath, name), redisContent) - t.Assert(err, nil) + t.AssertNil(err) err = gins.Config().GetAdapter().(*gcfg.AdapterFile).AddPath(dirPath) - t.Assert(err, nil) + t.AssertNil(err) defer gins.Config().GetAdapter().(*gcfg.AdapterFile).Clear() @@ -58,13 +58,13 @@ func Test_Redis(t *testing.T) { t.Assert(r, "PONG") r, err = redisCache.Do(ctx, "PING") - t.Assert(err, nil) + t.AssertNil(err) t.Assert(r, "PONG") _, err = redisDisk.Do(ctx, "SET", "k", "v") - t.Assert(err, nil) + t.AssertNil(err) r, err = redisDisk.Do(ctx, "GET", "k") - t.Assert(err, nil) + t.AssertNil(err) t.Assert(r, []byte("v")) }) } diff --git a/frame/gins/gins_z_unit_view_test.go b/frame/gins/gins_z_unit_view_test.go index f40e73730..bc66d5376 100644 --- a/frame/gins/gins_z_unit_view_test.go +++ b/frame/gins/gins_z_unit_view_test.go @@ -28,7 +28,7 @@ func Test_View(t *testing.T) { gtest.C(t, func(t *gtest.T) { tpl := "t.tpl" err := gfile.PutContents(tpl, `{{"我是中国人" | substr 2 -1}}`) - t.Assert(err, nil) + t.AssertNil(err) defer gfile.Remove(tpl) b, e := View().Parse(context.TODO(), "t.tpl", nil) @@ -39,10 +39,10 @@ func Test_View(t *testing.T) { path := fmt.Sprintf(`%s/%d`, gfile.Temp(), gtime.TimestampNano()) tpl := fmt.Sprintf(`%s/%s`, path, "t.tpl") err := gfile.PutContents(tpl, `{{"我是中国人" | substr 2 -1}}`) - t.Assert(err, nil) + t.AssertNil(err) defer gfile.Remove(tpl) err = View().AddPath(path) - t.Assert(err, nil) + t.AssertNil(err) b, e := View().Parse(context.TODO(), "t.tpl", nil) t.Assert(e, nil) @@ -61,16 +61,16 @@ func Test_View_Config(t *testing.T) { view := View("test1") t.AssertNE(view, nil) err := view.AddPath(dirPath) - t.Assert(err, nil) + t.AssertNil(err) str := `hello ${.name},version:${.version}` view.Assigns(map[string]interface{}{"version": "1.9.0"}) result, err := view.ParseContent(context.TODO(), str, nil) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(result, "hello test1,version:1.9.0") result, err = view.ParseDefault(context.TODO()) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(result, "test1:test1") }) // view1 test2 @@ -83,16 +83,16 @@ func Test_View_Config(t *testing.T) { view := View("test2") t.AssertNE(view, nil) err := view.AddPath(dirPath) - t.Assert(err, nil) + t.AssertNil(err) str := `hello #{.name},version:#{.version}` view.Assigns(map[string]interface{}{"version": "1.9.0"}) result, err := view.ParseContent(context.TODO(), str, nil) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(result, "hello test2,version:1.9.0") result, err = view.ParseDefault(context.TODO()) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(result, "test2:test2") }) // view2 @@ -105,16 +105,16 @@ func Test_View_Config(t *testing.T) { view := View() t.AssertNE(view, nil) err := view.AddPath(dirPath) - t.Assert(err, nil) + t.AssertNil(err) str := `hello {.name},version:{.version}` view.Assigns(map[string]interface{}{"version": "1.9.0"}) result, err := view.ParseContent(context.TODO(), str, nil) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(result, "hello test,version:1.9.0") result, err = view.ParseDefault(context.TODO()) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(result, "test:test") }) // view2 @@ -127,16 +127,16 @@ func Test_View_Config(t *testing.T) { view := View("test100") t.AssertNE(view, nil) err := view.AddPath(dirPath) - t.Assert(err, nil) + t.AssertNil(err) str := `hello {.name},version:{.version}` view.Assigns(map[string]interface{}{"version": "1.9.0"}) result, err := view.ParseContent(context.TODO(), str, nil) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(result, "hello test,version:1.9.0") result, err = view.ParseDefault(context.TODO()) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(result, "test:test") }) } diff --git a/i18n/gi18n/gi18n_z_unit_test.go b/i18n/gi18n/gi18n_z_unit_test.go index c7d5cf22b..d1e56db2a 100644 --- a/i18n/gi18n/gi18n_z_unit_test.go +++ b/i18n/gi18n/gi18n_z_unit_test.go @@ -85,7 +85,7 @@ func Test_TranslateFormat(t *testing.T) { func Test_DefaultManager(t *testing.T) { gtest.C(t, func(t *gtest.T) { err := gi18n.SetPath(gdebug.TestDataPath("i18n")) - t.Assert(err, nil) + t.AssertNil(err) gi18n.SetLanguage("none") t.Assert(gi18n.T(context.Background(), "{#hello}{#world}"), "{#hello}{#world}") @@ -99,7 +99,7 @@ func Test_DefaultManager(t *testing.T) { gtest.C(t, func(t *gtest.T) { err := gi18n.SetPath(gdebug.CallerDirectory() + gfile.Separator + "testdata" + gfile.Separator + "i18n-dir") - t.Assert(err, nil) + t.AssertNil(err) gi18n.SetLanguage("none") t.Assert(gi18n.Translate(context.Background(), "{#hello}{#world}"), "{#hello}{#world}") @@ -117,7 +117,7 @@ func Test_Instance(t *testing.T) { gtest.C(t, func(t *gtest.T) { m := gi18n.Instance() err := m.SetPath("i18n-dir") - t.Assert(err, nil) + t.AssertNil(err) m.SetLanguage("zh-CN") t.Assert(m.T(context.Background(), "{#hello}{#world}"), "你好世界") }) @@ -141,7 +141,7 @@ func Test_Resource(t *testing.T) { gtest.C(t, func(t *gtest.T) { m := g.I18n("resource") err := m.SetPath("i18n-dir") - t.Assert(err, nil) + t.AssertNil(err) m.SetLanguage("none") t.Assert(m.T(context.Background(), "{#hello}{#world}"), "{#hello}{#world}") diff --git a/net/gclient/gclient_z_unit_test.go b/net/gclient/gclient_z_unit_test.go index 6fcfa5f2e..e9328bca7 100644 --- a/net/gclient/gclient_z_unit_test.go +++ b/net/gclient/gclient_z_unit_test.go @@ -144,7 +144,7 @@ func Test_Client_Cookies(t *testing.T) { c.SetPrefix(fmt.Sprintf("http://127.0.0.1:%d", p)) resp, err := c.Get(ctx, "/cookie") - t.Assert(err, nil) + t.AssertNil(err) defer resp.Close() t.AssertNE(resp.Header.Get("Set-Cookie"), "") @@ -318,12 +318,12 @@ func Test_Client_File_And_Param(t *testing.T) { s.BindHandler("/", func(r *ghttp.Request) { tmpPath := gfile.Temp(guid.S()) err := gfile.Mkdir(tmpPath) - gtest.Assert(err, nil) + gtest.AssertNil(err) defer gfile.Remove(tmpPath) file := r.GetUploadFile("file") _, err = file.Save(tmpPath) - gtest.Assert(err, nil) + gtest.AssertNil(err) r.Response.Write( r.Get("json"), gfile.GetContents(gfile.Join(tmpPath, gfile.Basename(file.Filename))), @@ -398,7 +398,7 @@ func Test_Client_Middleware(t *testing.T) { }) resp, err := c.Get(ctx, "/") t.Assert(str1, "acefdb") - t.Assert(err, nil) + t.AssertNil(err) t.Assert(resp.ReadAllString(), str2) t.Assert(isServerHandler, true) @@ -473,7 +473,7 @@ func Test_Client_Request_13_Dump(t *testing.T) { url := fmt.Sprintf("http://127.0.0.1:%d", p) client := g.Client().SetPrefix(url).ContentJson() r, err := client.Post(ctx, "/hello", g.Map{"field": "test_for_request_body"}) - t.Assert(err, nil) + t.AssertNil(err) dumpedText := r.RawRequest() t.Assert(gstr.Contains(dumpedText, "test_for_request_body"), true) dumpedText2 := r.RawResponse() @@ -482,7 +482,7 @@ func Test_Client_Request_13_Dump(t *testing.T) { client2 := g.Client().SetPrefix(url).ContentType("text/html") r2, err := client2.Post(ctx, "/hello2", g.Map{"field": "test_for_request_body"}) - t.Assert(err, nil) + t.AssertNil(err) dumpedText3 := r2.RawRequest() t.Assert(gstr.Contains(dumpedText3, "test_for_request_body"), true) dumpedText4 := r2.RawResponse() @@ -520,15 +520,15 @@ func Test_WebSocketClient(t *testing.T) { client.HandshakeTimeout = time.Minute conn, _, err := client.Dial(fmt.Sprintf("ws://127.0.0.1:%d/ws", p), nil) - t.Assert(err, nil) + t.AssertNil(err) defer conn.Close() msg := []byte("hello") err = conn.WriteMessage(websocket.TextMessage, msg) - t.Assert(err, nil) + t.AssertNil(err) mt, data, err := conn.ReadMessage() - t.Assert(err, nil) + t.AssertNil(err) t.Assert(mt, websocket.TextMessage) t.Assert(data, msg) }) diff --git a/net/ghttp/ghttp_z_unit_feature_config_test.go b/net/ghttp/ghttp_z_unit_feature_config_test.go index 1aaca1f5f..ff04f7e7e 100644 --- a/net/ghttp/ghttp_z_unit_feature_config_test.go +++ b/net/ghttp/ghttp_z_unit_feature_config_test.go @@ -34,7 +34,7 @@ func Test_ConfigFromMap(t *testing.T) { "cookieHttpOnly": true, } config, err := ghttp.ConfigFromMap(m) - t.Assert(err, nil) + t.AssertNil(err) d1, _ := time.ParseDuration(gconv.String(m["readTimeout"])) d2, _ := time.ParseDuration(gconv.String(m["cookieMaxAge"])) t.Assert(config.Address, m["address"]) @@ -67,7 +67,7 @@ func Test_SetConfigWithMap(t *testing.T) { } s := g.Server() err := s.SetConfigWithMap(m) - t.Assert(err, nil) + t.AssertNil(err) }) } diff --git a/net/ghttp/ghttp_z_unit_feature_middleware_basic_test.go b/net/ghttp/ghttp_z_unit_feature_middleware_basic_test.go index bc473fa4a..bb3841daa 100644 --- a/net/ghttp/ghttp_z_unit_feature_middleware_basic_test.go +++ b/net/ghttp/ghttp_z_unit_feature_middleware_basic_test.go @@ -207,7 +207,7 @@ func Test_Middleware_Status(t *testing.T) { resp, err := client.Get(ctx, "/") defer resp.Close() - t.Assert(err, nil) + t.AssertNil(err) t.Assert(resp.StatusCode, 404) }) } @@ -583,7 +583,7 @@ func Test_Middleware_CORSAndAuth(t *testing.T) { t.Assert(client.PostContent(ctx, "/api.v2/user/list", "token=123456"), "list") // CORS Checks. resp, err := client.Post(ctx, "/api.v2/user/list", "token=123456") - t.Assert(err, nil) + t.AssertNil(err) t.Assert(len(resp.Header["Access-Control-Allow-Headers"]), 1) t.Assert(resp.Header["Access-Control-Allow-Headers"][0], "Origin,Content-Type,Accept,User-Agent,Cookie,Authorization,X-Auth-Token,X-Requested-With") t.Assert(resp.Header["Access-Control-Allow-Methods"][0], "GET,PUT,POST,DELETE,PATCH,HEAD,CONNECT,OPTIONS,TRACE") diff --git a/net/ghttp/ghttp_z_unit_feature_middleware_cors_test.go b/net/ghttp/ghttp_z_unit_feature_middleware_cors_test.go index d0f4752e7..98d82345e 100644 --- a/net/ghttp/ghttp_z_unit_feature_middleware_cors_test.go +++ b/net/ghttp/ghttp_z_unit_feature_middleware_cors_test.go @@ -38,14 +38,14 @@ func Test_Middleware_CORS1(t *testing.T) { // GET request does not any route. resp, err := client.Get(ctx, "/api.v2/user/list") - t.Assert(err, nil) + t.AssertNil(err) t.Assert(len(resp.Header["Access-Control-Allow-Headers"]), 0) t.Assert(resp.StatusCode, 404) resp.Close() // POST request matches the route and CORS middleware. resp, err = client.Post(ctx, "/api.v2/user/list") - t.Assert(err, nil) + t.AssertNil(err) t.Assert(len(resp.Header["Access-Control-Allow-Headers"]), 1) t.Assert(resp.Header["Access-Control-Allow-Headers"][0], "Origin,Content-Type,Accept,User-Agent,Cookie,Authorization,X-Auth-Token,X-Requested-With") t.Assert(resp.Header["Access-Control-Allow-Methods"][0], "GET,PUT,POST,DELETE,PATCH,HEAD,CONNECT,OPTIONS,TRACE") @@ -59,7 +59,7 @@ func Test_Middleware_CORS1(t *testing.T) { client.SetPrefix(fmt.Sprintf("http://127.0.0.1:%d", s.GetListenedPort())) client.SetHeader("Access-Control-Request-Method", "GET") resp, err := client.Options(ctx, "/api.v2/user/list") - t.Assert(err, nil) + t.AssertNil(err) t.Assert(len(resp.Header["Access-Control-Allow-Headers"]), 0) t.Assert(resp.ReadAllString(), "Not Found") t.Assert(resp.StatusCode, 404) @@ -71,7 +71,7 @@ func Test_Middleware_CORS1(t *testing.T) { client.SetPrefix(fmt.Sprintf("http://127.0.0.1:%d", s.GetListenedPort())) client.SetHeader("Access-Control-Request-Method", "POST") resp, err := client.Options(ctx, "/api.v2/user/list") - t.Assert(err, nil) + t.AssertNil(err) t.Assert(len(resp.Header["Access-Control-Allow-Headers"]), 1) t.Assert(resp.StatusCode, 200) resp.Close() @@ -98,7 +98,7 @@ func Test_Middleware_CORS2(t *testing.T) { t.Assert(client.GetContent(ctx, "/api.v2"), "Not Found") // Get request. resp, err := client.Get(ctx, "/api.v2/user/list/1") - t.Assert(err, nil) + t.AssertNil(err) t.Assert(len(resp.Header["Access-Control-Allow-Headers"]), 1) t.Assert(resp.Header["Access-Control-Allow-Headers"][0], "Origin,Content-Type,Accept,User-Agent,Cookie,Authorization,X-Auth-Token,X-Requested-With") t.Assert(resp.Header["Access-Control-Allow-Methods"][0], "GET,PUT,POST,DELETE,PATCH,HEAD,CONNECT,OPTIONS,TRACE") @@ -113,7 +113,7 @@ func Test_Middleware_CORS2(t *testing.T) { client.SetPrefix(fmt.Sprintf("http://127.0.0.1:%d", s.GetListenedPort())) client.SetHeader("Access-Control-Request-Method", "GET") resp, err := client.Options(ctx, "/api.v2/user") - t.Assert(err, nil) + t.AssertNil(err) t.Assert(len(resp.Header["Access-Control-Allow-Headers"]), 0) t.Assert(resp.StatusCode, 404) resp.Close() @@ -124,7 +124,7 @@ func Test_Middleware_CORS2(t *testing.T) { client.SetPrefix(fmt.Sprintf("http://127.0.0.1:%d", s.GetListenedPort())) client.SetHeader("Access-Control-Request-Method", "GET") resp, err := client.Options(ctx, "/api.v2/user/list/1") - t.Assert(err, nil) + t.AssertNil(err) t.Assert(len(resp.Header["Access-Control-Allow-Headers"]), 1) t.Assert(resp.StatusCode, 200) resp.Close() @@ -135,7 +135,7 @@ func Test_Middleware_CORS2(t *testing.T) { client.SetPrefix(fmt.Sprintf("http://127.0.0.1:%d", s.GetListenedPort())) client.SetHeader("Access-Control-Request-Method", "POST") resp, err := client.Options(ctx, "/api.v2/user/list/1") - t.Assert(err, nil) + t.AssertNil(err) t.Assert(len(resp.Header["Access-Control-Allow-Headers"]), 0) t.Assert(resp.StatusCode, 404) resp.Close() diff --git a/net/ghttp/ghttp_z_unit_feature_router_basic_test.go b/net/ghttp/ghttp_z_unit_feature_router_basic_test.go index 72bf276c6..5698edef0 100644 --- a/net/ghttp/ghttp_z_unit_feature_router_basic_test.go +++ b/net/ghttp/ghttp_z_unit_feature_router_basic_test.go @@ -115,22 +115,22 @@ func Test_Router_Method(t *testing.T) { resp1, err := client.Get(ctx, "/get") defer resp1.Close() - t.Assert(err, nil) + t.AssertNil(err) t.Assert(resp1.StatusCode, 200) resp2, err := client.Post(ctx, "/get") defer resp2.Close() - t.Assert(err, nil) + t.AssertNil(err) t.Assert(resp2.StatusCode, 404) resp3, err := client.Get(ctx, "/post") defer resp3.Close() - t.Assert(err, nil) + t.AssertNil(err) t.Assert(resp3.StatusCode, 404) resp4, err := client.Post(ctx, "/post") defer resp4.Close() - t.Assert(err, nil) + t.AssertNil(err) t.Assert(resp4.StatusCode, 200) }) } @@ -187,27 +187,27 @@ func Test_Router_Status(t *testing.T) { resp1, err := client.Get(ctx, "/200") defer resp1.Close() - t.Assert(err, nil) + t.AssertNil(err) t.Assert(resp1.StatusCode, 200) resp2, err := client.Get(ctx, "/300") defer resp2.Close() - t.Assert(err, nil) + t.AssertNil(err) t.Assert(resp2.StatusCode, 300) resp3, err := client.Get(ctx, "/400") defer resp3.Close() - t.Assert(err, nil) + t.AssertNil(err) t.Assert(resp3.StatusCode, 400) resp4, err := client.Get(ctx, "/500") defer resp4.Close() - t.Assert(err, nil) + t.AssertNil(err) t.Assert(resp4.StatusCode, 500) resp5, err := client.Get(ctx, "/404") defer resp5.Close() - t.Assert(err, nil) + t.AssertNil(err) t.Assert(resp5.StatusCode, 404) }) } @@ -232,7 +232,7 @@ func Test_Router_CustomStatusHandler(t *testing.T) { t.Assert(client.GetContent(ctx, "/"), "hello") resp, err := client.Get(ctx, "/ThisDoesNotExist") defer resp.Close() - t.Assert(err, nil) + t.AssertNil(err) t.Assert(resp.StatusCode, 404) t.Assert(resp.ReadAllString(), "404 page") }) @@ -256,7 +256,7 @@ func Test_Router_404(t *testing.T) { t.Assert(client.GetContent(ctx, "/"), "hello") resp, err := client.Get(ctx, "/ThisDoesNotExist") defer resp.Close() - t.Assert(err, nil) + t.AssertNil(err) t.Assert(resp.StatusCode, 404) }) } diff --git a/net/ghttp/ghttp_z_unit_feature_router_domain_basic_test.go b/net/ghttp/ghttp_z_unit_feature_router_domain_basic_test.go index c8c00d908..a9af14ea2 100644 --- a/net/ghttp/ghttp_z_unit_feature_router_domain_basic_test.go +++ b/net/ghttp/ghttp_z_unit_feature_router_domain_basic_test.go @@ -87,22 +87,22 @@ func Test_Router_DomainMethod(t *testing.T) { resp1, err := client.Get(ctx, "/get") defer resp1.Close() - t.Assert(err, nil) + t.AssertNil(err) t.Assert(resp1.StatusCode, 404) resp2, err := client.Post(ctx, "/get") defer resp2.Close() - t.Assert(err, nil) + t.AssertNil(err) t.Assert(resp2.StatusCode, 404) resp3, err := client.Get(ctx, "/post") defer resp3.Close() - t.Assert(err, nil) + t.AssertNil(err) t.Assert(resp3.StatusCode, 404) resp4, err := client.Post(ctx, "/post") defer resp4.Close() - t.Assert(err, nil) + t.AssertNil(err) t.Assert(resp4.StatusCode, 404) }) @@ -112,22 +112,22 @@ func Test_Router_DomainMethod(t *testing.T) { resp1, err := client.Get(ctx, "/get") defer resp1.Close() - t.Assert(err, nil) + t.AssertNil(err) t.Assert(resp1.StatusCode, 200) resp2, err := client.Post(ctx, "/get") defer resp2.Close() - t.Assert(err, nil) + t.AssertNil(err) t.Assert(resp2.StatusCode, 404) resp3, err := client.Get(ctx, "/post") defer resp3.Close() - t.Assert(err, nil) + t.AssertNil(err) t.Assert(resp3.StatusCode, 404) resp4, err := client.Post(ctx, "/post") defer resp4.Close() - t.Assert(err, nil) + t.AssertNil(err) t.Assert(resp4.StatusCode, 200) }) @@ -137,22 +137,22 @@ func Test_Router_DomainMethod(t *testing.T) { resp1, err := client.Get(ctx, "/get") defer resp1.Close() - t.Assert(err, nil) + t.AssertNil(err) t.Assert(resp1.StatusCode, 200) resp2, err := client.Post(ctx, "/get") defer resp2.Close() - t.Assert(err, nil) + t.AssertNil(err) t.Assert(resp2.StatusCode, 404) resp3, err := client.Get(ctx, "/post") defer resp3.Close() - t.Assert(err, nil) + t.AssertNil(err) t.Assert(resp3.StatusCode, 404) resp4, err := client.Post(ctx, "/post") defer resp4.Close() - t.Assert(err, nil) + t.AssertNil(err) t.Assert(resp4.StatusCode, 200) }) } @@ -183,22 +183,22 @@ func Test_Router_DomainStatus(t *testing.T) { resp1, err := client.Get(ctx, "/200") defer resp1.Close() - t.Assert(err, nil) + t.AssertNil(err) t.Assert(resp1.StatusCode, 404) resp2, err := client.Get(ctx, "/300") defer resp2.Close() - t.Assert(err, nil) + t.AssertNil(err) t.Assert(resp2.StatusCode, 404) resp3, err := client.Get(ctx, "/400") defer resp3.Close() - t.Assert(err, nil) + t.AssertNil(err) t.Assert(resp3.StatusCode, 404) resp4, err := client.Get(ctx, "/500") defer resp4.Close() - t.Assert(err, nil) + t.AssertNil(err) t.Assert(resp4.StatusCode, 404) }) gtest.C(t, func(t *gtest.T) { @@ -207,22 +207,22 @@ func Test_Router_DomainStatus(t *testing.T) { resp1, err := client.Get(ctx, "/200") defer resp1.Close() - t.Assert(err, nil) + t.AssertNil(err) t.Assert(resp1.StatusCode, 200) resp2, err := client.Get(ctx, "/300") defer resp2.Close() - t.Assert(err, nil) + t.AssertNil(err) t.Assert(resp2.StatusCode, 300) resp3, err := client.Get(ctx, "/400") defer resp3.Close() - t.Assert(err, nil) + t.AssertNil(err) t.Assert(resp3.StatusCode, 400) resp4, err := client.Get(ctx, "/500") defer resp4.Close() - t.Assert(err, nil) + t.AssertNil(err) t.Assert(resp4.StatusCode, 500) }) gtest.C(t, func(t *gtest.T) { @@ -231,22 +231,22 @@ func Test_Router_DomainStatus(t *testing.T) { resp1, err := client.Get(ctx, "/200") defer resp1.Close() - t.Assert(err, nil) + t.AssertNil(err) t.Assert(resp1.StatusCode, 200) resp2, err := client.Get(ctx, "/300") defer resp2.Close() - t.Assert(err, nil) + t.AssertNil(err) t.Assert(resp2.StatusCode, 300) resp3, err := client.Get(ctx, "/400") defer resp3.Close() - t.Assert(err, nil) + t.AssertNil(err) t.Assert(resp3.StatusCode, 400) resp4, err := client.Get(ctx, "/500") defer resp4.Close() - t.Assert(err, nil) + t.AssertNil(err) t.Assert(resp4.StatusCode, 500) }) } diff --git a/net/ghttp/ghttp_z_unit_feature_router_domain_object_rest_test.go b/net/ghttp/ghttp_z_unit_feature_router_domain_object_rest_test.go index 6b30f82a8..a8f6cb1c2 100644 --- a/net/ghttp/ghttp_z_unit_feature_router_domain_object_rest_test.go +++ b/net/ghttp/ghttp_z_unit_feature_router_domain_object_rest_test.go @@ -78,7 +78,7 @@ func Test_Router_DomainObjectRest(t *testing.T) { if err == nil { defer resp1.Close() } - t.Assert(err, nil) + t.AssertNil(err) t.Assert(resp1.Header.Get("head-ok"), "") t.Assert(client.GetContent(ctx, "/none-exist"), "Not Found") }) @@ -96,7 +96,7 @@ func Test_Router_DomainObjectRest(t *testing.T) { if err == nil { defer resp1.Close() } - t.Assert(err, nil) + t.AssertNil(err) t.Assert(resp1.Header.Get("head-ok"), "1") t.Assert(client.GetContent(ctx, "/none-exist"), "Not Found") }) @@ -114,7 +114,7 @@ func Test_Router_DomainObjectRest(t *testing.T) { if err == nil { defer resp1.Close() } - t.Assert(err, nil) + t.AssertNil(err) t.Assert(resp1.Header.Get("head-ok"), "1") t.Assert(client.GetContent(ctx, "/none-exist"), "Not Found") }) diff --git a/net/ghttp/ghttp_z_unit_feature_router_group_rest_test.go b/net/ghttp/ghttp_z_unit_feature_router_group_rest_test.go index b46c64cc0..ca47cac70 100644 --- a/net/ghttp/ghttp_z_unit_feature_router_group_rest_test.go +++ b/net/ghttp/ghttp_z_unit_feature_router_group_rest_test.go @@ -80,7 +80,7 @@ func Test_Router_GroupRest1(t *testing.T) { if err == nil { defer resp2.Close() } - t.Assert(err, nil) + t.AssertNil(err) t.Assert(resp2.Header.Get("head-ok"), "1") t.Assert(client.GetContent(ctx, "/api/group-obj-rest"), "Not Found") @@ -94,7 +94,7 @@ func Test_Router_GroupRest1(t *testing.T) { if err == nil { defer resp4.Close() } - t.Assert(err, nil) + t.AssertNil(err) t.Assert(resp4.Header.Get("head-ok"), "1") }) } @@ -125,7 +125,7 @@ func Test_Router_GroupRest2(t *testing.T) { if err == nil { defer resp2.Close() } - t.Assert(err, nil) + t.AssertNil(err) t.Assert(resp2.Header.Get("head-ok"), "1") t.Assert(client.GetContent(ctx, "/api/group-obj-rest"), "Not Found") @@ -139,7 +139,7 @@ func Test_Router_GroupRest2(t *testing.T) { if err == nil { defer resp4.Close() } - t.Assert(err, nil) + t.AssertNil(err) t.Assert(resp4.Header.Get("head-ok"), "1") }) } diff --git a/net/ghttp/ghttp_z_unit_feature_router_object_rest1_test.go b/net/ghttp/ghttp_z_unit_feature_router_object_rest1_test.go index 840ddbb94..32d5ec7d1 100644 --- a/net/ghttp/ghttp_z_unit_feature_router_object_rest1_test.go +++ b/net/ghttp/ghttp_z_unit_feature_router_object_rest1_test.go @@ -78,7 +78,7 @@ func Test_Router_ObjectRest(t *testing.T) { if err == nil { defer resp1.Close() } - t.Assert(err, nil) + t.AssertNil(err) t.Assert(resp1.Header.Get("head-ok"), "1") t.Assert(client.GetContent(ctx, "/object-rest/get"), "1Object Get2") @@ -91,7 +91,7 @@ func Test_Router_ObjectRest(t *testing.T) { if err == nil { defer resp2.Close() } - t.Assert(err, nil) + t.AssertNil(err) t.Assert(resp2.Header.Get("head-ok"), "1") t.Assert(client.GetContent(ctx, "/none-exist"), "Not Found") diff --git a/net/ghttp/ghttp_z_unit_feature_session_test.go b/net/ghttp/ghttp_z_unit_feature_session_test.go index 59fe356dc..e76187848 100644 --- a/net/ghttp/ghttp_z_unit_feature_session_test.go +++ b/net/ghttp/ghttp_z_unit_feature_session_test.go @@ -179,7 +179,7 @@ func Test_Session_Custom_Id(t *testing.T) { client := g.Client() client.SetPrefix(fmt.Sprintf("http://127.0.0.1:%d", s.GetListenedPort())) r, err := client.Get(ctx, "/id") - t.Assert(err, nil) + t.AssertNil(err) defer r.Close() t.Assert(r.ReadAllString(), sessionId) t.Assert(r.GetCookie(s.GetSessionIdName()), sessionId) diff --git a/net/ghttp/ghttp_z_unit_feature_template_test.go b/net/ghttp/ghttp_z_unit_feature_template_test.go index 8a3ee07b1..8c41f443f 100644 --- a/net/ghttp/ghttp_z_unit_feature_template_test.go +++ b/net/ghttp/ghttp_z_unit_feature_template_test.go @@ -31,7 +31,7 @@ func Test_Template_Basic(t *testing.T) { err := r.Response.WriteTpl("index.html", g.Map{ "name": "john", }) - t.Assert(err, nil) + t.AssertNil(err) }) s.SetDumpRouterMap(false) s.Start() @@ -55,7 +55,7 @@ func Test_Template_Encode(t *testing.T) { err := r.Response.WriteTpl("index.html", g.Map{ "name": "john", }) - t.Assert(err, nil) + t.AssertNil(err) }) s.SetDumpRouterMap(false) s.Start() @@ -78,11 +78,11 @@ func Test_Template_Layout1(t *testing.T) { err := r.Response.WriteTpl("layout.html", g.Map{ "mainTpl": "main/main1.html", }) - t.Assert(err, nil) + t.AssertNil(err) }) s.BindHandler("/nil", func(r *ghttp.Request) { err := r.Response.WriteTpl("layout.html", nil) - t.Assert(err, nil) + t.AssertNil(err) }) s.SetDumpRouterMap(false) s.Start() @@ -106,17 +106,17 @@ func Test_Template_Layout2(t *testing.T) { err := r.Response.WriteTpl("layout.html", g.Map{ "mainTpl": "main/main1.html", }) - t.Assert(err, nil) + t.AssertNil(err) }) s.BindHandler("/main2", func(r *ghttp.Request) { err := r.Response.WriteTpl("layout.html", g.Map{ "mainTpl": "main/main2.html", }) - t.Assert(err, nil) + t.AssertNil(err) }) s.BindHandler("/nil", func(r *ghttp.Request) { err := r.Response.WriteTpl("layout.html", nil) - t.Assert(err, nil) + t.AssertNil(err) }) s.SetDumpRouterMap(false) s.Start() @@ -137,7 +137,7 @@ func Test_Template_BuildInVarRequest(t *testing.T) { s := g.Server(guid.S()) s.BindHandler("/:table/test", func(r *ghttp.Request) { err := r.Response.WriteTplContent("{{.Request.table}}") - t.Assert(err, nil) + t.AssertNil(err) }) s.SetDumpRouterMap(false) s.Start() @@ -162,7 +162,7 @@ func Test_Template_XSS(t *testing.T) { err := r.Response.WriteTplContent("{{if eq 1 1}}{{.v}}{{end}}", g.Map{ "v": c, }) - t.Assert(err, nil) + t.AssertNil(err) }) s.SetDumpRouterMap(false) s.Start() diff --git a/net/ghttp/ghttp_z_unit_feature_websocket_test.go b/net/ghttp/ghttp_z_unit_feature_websocket_test.go index 5887100b6..916291eda 100644 --- a/net/ghttp/ghttp_z_unit_feature_websocket_test.go +++ b/net/ghttp/ghttp_z_unit_feature_websocket_test.go @@ -44,15 +44,15 @@ func Test_WebSocket(t *testing.T) { conn, _, err := websocket.DefaultDialer.Dial(fmt.Sprintf( "ws://127.0.0.1:%d/ws", s.GetListenedPort(), ), nil) - t.Assert(err, nil) + t.AssertNil(err) defer conn.Close() msg := []byte("hello") err = conn.WriteMessage(websocket.TextMessage, msg) - t.Assert(err, nil) + t.AssertNil(err) mt, data, err := conn.ReadMessage() - t.Assert(err, nil) + t.AssertNil(err) t.Assert(mt, websocket.TextMessage) t.Assert(data, msg) }) diff --git a/net/gtcp/gtcp_z_unit_conn_pkg_test.go b/net/gtcp/gtcp_z_unit_conn_pkg_test.go index 71ce6938a..8d216ade4 100644 --- a/net/gtcp/gtcp_z_unit_conn_pkg_test.go +++ b/net/gtcp/gtcp_z_unit_conn_pkg_test.go @@ -34,21 +34,21 @@ func Test_Package_Basic(t *testing.T) { // SendPkg gtest.C(t, func(t *gtest.T) { conn, err := gtcp.NewConn(fmt.Sprintf("127.0.0.1:%d", p)) - t.Assert(err, nil) + t.AssertNil(err) defer conn.Close() for i := 0; i < 100; i++ { err := conn.SendPkg([]byte(gconv.String(i))) - t.Assert(err, nil) + t.AssertNil(err) } for i := 0; i < 100; i++ { err := conn.SendPkgWithTimeout([]byte(gconv.String(i)), time.Second) - t.Assert(err, nil) + t.AssertNil(err) } }) // SendPkg with big data - failure. gtest.C(t, func(t *gtest.T) { conn, err := gtcp.NewConn(fmt.Sprintf("127.0.0.1:%d", p)) - t.Assert(err, nil) + t.AssertNil(err) defer conn.Close() data := make([]byte, 65536) err = conn.SendPkg(data) @@ -57,25 +57,25 @@ func Test_Package_Basic(t *testing.T) { // SendRecvPkg gtest.C(t, func(t *gtest.T) { conn, err := gtcp.NewConn(fmt.Sprintf("127.0.0.1:%d", p)) - t.Assert(err, nil) + t.AssertNil(err) defer conn.Close() for i := 100; i < 200; i++ { data := []byte(gconv.String(i)) result, err := conn.SendRecvPkg(data) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(result, data) } for i := 100; i < 200; i++ { data := []byte(gconv.String(i)) result, err := conn.SendRecvPkgWithTimeout(data, time.Second) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(result, data) } }) // SendRecvPkg with big data - failure. gtest.C(t, func(t *gtest.T) { conn, err := gtcp.NewConn(fmt.Sprintf("127.0.0.1:%d", p)) - t.Assert(err, nil) + t.AssertNil(err) defer conn.Close() data := make([]byte, 65536) result, err := conn.SendRecvPkg(data) @@ -85,13 +85,13 @@ func Test_Package_Basic(t *testing.T) { // SendRecvPkg with big data - success. gtest.C(t, func(t *gtest.T) { conn, err := gtcp.NewConn(fmt.Sprintf("127.0.0.1:%d", p)) - t.Assert(err, nil) + t.AssertNil(err) defer conn.Close() data := make([]byte, 65500) data[100] = byte(65) data[65400] = byte(85) result, err := conn.SendRecvPkg(data) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(result, data) }) } @@ -114,7 +114,7 @@ func Test_Package_Timeout(t *testing.T) { time.Sleep(100 * time.Millisecond) gtest.C(t, func(t *gtest.T) { conn, err := gtcp.NewConn(fmt.Sprintf("127.0.0.1:%d", p)) - t.Assert(err, nil) + t.AssertNil(err) defer conn.Close() data := []byte("10000") result, err := conn.SendRecvPkgWithTimeout(data, time.Millisecond*500) @@ -123,11 +123,11 @@ func Test_Package_Timeout(t *testing.T) { }) gtest.C(t, func(t *gtest.T) { conn, err := gtcp.NewConn(fmt.Sprintf("127.0.0.1:%d", p)) - t.Assert(err, nil) + t.AssertNil(err) defer conn.Close() data := []byte("10000") result, err := conn.SendRecvPkgWithTimeout(data, time.Second*2) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(result, data) }) } @@ -151,7 +151,7 @@ func Test_Package_Option(t *testing.T) { // SendRecvPkg with big data - failure. gtest.C(t, func(t *gtest.T) { conn, err := gtcp.NewConn(fmt.Sprintf("127.0.0.1:%d", p)) - t.Assert(err, nil) + t.AssertNil(err) defer conn.Close() data := make([]byte, 0xFF+1) result, err := conn.SendRecvPkg(data, gtcp.PkgOption{HeaderSize: 1}) @@ -161,13 +161,13 @@ func Test_Package_Option(t *testing.T) { // SendRecvPkg with big data - success. gtest.C(t, func(t *gtest.T) { conn, err := gtcp.NewConn(fmt.Sprintf("127.0.0.1:%d", p)) - t.Assert(err, nil) + t.AssertNil(err) defer conn.Close() data := make([]byte, 0xFF) data[100] = byte(65) data[200] = byte(85) result, err := conn.SendRecvPkg(data, gtcp.PkgOption{HeaderSize: 1}) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(result, data) }) } diff --git a/net/gtcp/gtcp_z_unit_pool_pkg_test.go b/net/gtcp/gtcp_z_unit_pool_pkg_test.go index 4a0a8a86f..54df536aa 100644 --- a/net/gtcp/gtcp_z_unit_pool_pkg_test.go +++ b/net/gtcp/gtcp_z_unit_pool_pkg_test.go @@ -34,21 +34,21 @@ func Test_Pool_Package_Basic(t *testing.T) { // SendPkg gtest.C(t, func(t *gtest.T) { conn, err := gtcp.NewPoolConn(fmt.Sprintf("127.0.0.1:%d", p)) - t.Assert(err, nil) + t.AssertNil(err) defer conn.Close() for i := 0; i < 100; i++ { err := conn.SendPkg([]byte(gconv.String(i))) - t.Assert(err, nil) + t.AssertNil(err) } for i := 0; i < 100; i++ { err := conn.SendPkgWithTimeout([]byte(gconv.String(i)), time.Second) - t.Assert(err, nil) + t.AssertNil(err) } }) // SendPkg with big data - failure. gtest.C(t, func(t *gtest.T) { conn, err := gtcp.NewPoolConn(fmt.Sprintf("127.0.0.1:%d", p)) - t.Assert(err, nil) + t.AssertNil(err) defer conn.Close() data := make([]byte, 65536) err = conn.SendPkg(data) @@ -57,25 +57,25 @@ func Test_Pool_Package_Basic(t *testing.T) { // SendRecvPkg gtest.C(t, func(t *gtest.T) { conn, err := gtcp.NewPoolConn(fmt.Sprintf("127.0.0.1:%d", p)) - t.Assert(err, nil) + t.AssertNil(err) defer conn.Close() for i := 100; i < 200; i++ { data := []byte(gconv.String(i)) result, err := conn.SendRecvPkg(data) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(result, data) } for i := 100; i < 200; i++ { data := []byte(gconv.String(i)) result, err := conn.SendRecvPkgWithTimeout(data, time.Second) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(result, data) } }) // SendRecvPkg with big data - failure. gtest.C(t, func(t *gtest.T) { conn, err := gtcp.NewPoolConn(fmt.Sprintf("127.0.0.1:%d", p)) - t.Assert(err, nil) + t.AssertNil(err) defer conn.Close() data := make([]byte, 65536) result, err := conn.SendRecvPkg(data) @@ -85,13 +85,13 @@ func Test_Pool_Package_Basic(t *testing.T) { // SendRecvPkg with big data - success. gtest.C(t, func(t *gtest.T) { conn, err := gtcp.NewPoolConn(fmt.Sprintf("127.0.0.1:%d", p)) - t.Assert(err, nil) + t.AssertNil(err) defer conn.Close() data := make([]byte, 65500) data[100] = byte(65) data[65400] = byte(85) result, err := conn.SendRecvPkg(data) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(result, data) }) } @@ -114,7 +114,7 @@ func Test_Pool_Package_Timeout(t *testing.T) { time.Sleep(100 * time.Millisecond) gtest.C(t, func(t *gtest.T) { conn, err := gtcp.NewPoolConn(fmt.Sprintf("127.0.0.1:%d", p)) - t.Assert(err, nil) + t.AssertNil(err) defer conn.Close() data := []byte("10000") result, err := conn.SendRecvPkgWithTimeout(data, time.Millisecond*500) @@ -123,11 +123,11 @@ func Test_Pool_Package_Timeout(t *testing.T) { }) gtest.C(t, func(t *gtest.T) { conn, err := gtcp.NewPoolConn(fmt.Sprintf("127.0.0.1:%d", p)) - t.Assert(err, nil) + t.AssertNil(err) defer conn.Close() data := []byte("10000") result, err := conn.SendRecvPkgWithTimeout(data, time.Second*2) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(result, data) }) } @@ -151,7 +151,7 @@ func Test_Pool_Package_Option(t *testing.T) { // SendRecvPkg with big data - failure. gtest.C(t, func(t *gtest.T) { conn, err := gtcp.NewPoolConn(fmt.Sprintf("127.0.0.1:%d", p)) - t.Assert(err, nil) + t.AssertNil(err) defer conn.Close() data := make([]byte, 0xFF+1) result, err := conn.SendRecvPkg(data, gtcp.PkgOption{HeaderSize: 1}) @@ -161,13 +161,13 @@ func Test_Pool_Package_Option(t *testing.T) { // SendRecvPkg with big data - success. gtest.C(t, func(t *gtest.T) { conn, err := gtcp.NewPoolConn(fmt.Sprintf("127.0.0.1:%d", p)) - t.Assert(err, nil) + t.AssertNil(err) defer conn.Close() data := make([]byte, 0xFF) data[100] = byte(65) data[200] = byte(85) result, err := conn.SendRecvPkg(data, gtcp.PkgOption{HeaderSize: 1}) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(result, data) }) } diff --git a/net/gtcp/gtcp_z_unit_pool_test.go b/net/gtcp/gtcp_z_unit_pool_test.go index 7b3544328..6eae0bf44 100644 --- a/net/gtcp/gtcp_z_unit_pool_test.go +++ b/net/gtcp/gtcp_z_unit_pool_test.go @@ -32,13 +32,13 @@ func Test_Pool_Basic1(t *testing.T) { time.Sleep(100 * time.Millisecond) gtest.C(t, func(t *gtest.T) { conn, err := gtcp.NewPoolConn(fmt.Sprintf("127.0.0.1:%d", p)) - t.Assert(err, nil) + t.AssertNil(err) defer conn.Close() data := []byte("9999") err = conn.SendPkg(data) - t.Assert(err, nil) + t.AssertNil(err) err = conn.SendPkgWithTimeout(data, time.Second) - t.Assert(err, nil) + t.AssertNil(err) }) } @@ -52,13 +52,13 @@ func Test_Pool_Basic2(t *testing.T) { time.Sleep(100 * time.Millisecond) gtest.C(t, func(t *gtest.T) { conn, err := gtcp.NewPoolConn(fmt.Sprintf("127.0.0.1:%d", p)) - t.Assert(err, nil) + t.AssertNil(err) defer conn.Close() data := []byte("9999") err = conn.SendPkg(data) - t.Assert(err, nil) + t.AssertNil(err) //err = conn.SendPkgWithTimeout(data, time.Second) - //t.Assert(err, nil) + //t.AssertNil(err) _, err = conn.SendRecv(data, -1) t.AssertNE(err, nil) diff --git a/net/gudp/gudp_z_unit_test.go b/net/gudp/gudp_z_unit_test.go index 7b1154d02..55d6f6e85 100644 --- a/net/gudp/gudp_z_unit_test.go +++ b/net/gudp/gudp_z_unit_test.go @@ -44,7 +44,7 @@ func Test_Basic(t *testing.T) { gtest.C(t, func(t *gtest.T) { for i := 0; i < 100; i++ { conn, err := gudp.NewConn(fmt.Sprintf("127.0.0.1:%d", p)) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(conn.Send([]byte(gconv.String(i))), nil) conn.Close() } @@ -53,9 +53,9 @@ func Test_Basic(t *testing.T) { gtest.C(t, func(t *gtest.T) { for i := 0; i < 100; i++ { conn, err := gudp.NewConn(fmt.Sprintf("127.0.0.1:%d", p)) - t.Assert(err, nil) + t.AssertNil(err) _, err = conn.SendRecv([]byte(gconv.String(i)), -1) - t.Assert(err, nil) + t.AssertNil(err) //t.Assert(string(result), fmt.Sprintf(`> %d`, i)) conn.Close() } @@ -64,14 +64,14 @@ func Test_Basic(t *testing.T) { gtest.C(t, func(t *gtest.T) { for i := 0; i < 100; i++ { err := gudp.Send(fmt.Sprintf("127.0.0.1:%d", p), []byte(gconv.String(i))) - t.Assert(err, nil) + t.AssertNil(err) } }) // gudp.SendRecv gtest.C(t, func(t *gtest.T) { for i := 0; i < 100; i++ { result, err := gudp.SendRecv(fmt.Sprintf("127.0.0.1:%d", p), []byte(gconv.String(i)), -1) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(string(result), fmt.Sprintf(`> %d`, i)) } }) @@ -103,12 +103,12 @@ func Test_Buffer(t *testing.T) { time.Sleep(100 * time.Millisecond) gtest.C(t, func(t *gtest.T) { result, err := gudp.SendRecv(fmt.Sprintf("127.0.0.1:%d", p), []byte("123"), -1) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(string(result), "1") }) gtest.C(t, func(t *gtest.T) { result, err := gudp.SendRecv(fmt.Sprintf("127.0.0.1:%d", p), []byte("456"), -1) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(string(result), "4") }) } diff --git a/os/gcfg/gcfg_z_unit_basic_test.go b/os/gcfg/gcfg_z_unit_basic_test.go index 67ecbe29e..ff0347660 100644 --- a/os/gcfg/gcfg_z_unit_basic_test.go +++ b/os/gcfg/gcfg_z_unit_basic_test.go @@ -105,7 +105,7 @@ func Test_SetFileName(t *testing.T) { gtest.C(t, func(t *gtest.T) { path := "config.json" err := gfile.PutContents(path, config) - t.Assert(err, nil) + t.AssertNil(err) defer func() { _ = gfile.Remove(path) }() @@ -155,18 +155,18 @@ func TestCfg_Get_WrongConfigFile(t *testing.T) { var err error configPath := gfile.Temp(gtime.TimestampNanoStr()) err = gfile.Mkdir(configPath) - t.Assert(err, nil) + t.AssertNil(err) defer gfile.Remove(configPath) defer gfile.Chdir(gfile.Pwd()) err = gfile.Chdir(configPath) - t.Assert(err, nil) + t.AssertNil(err) err = gfile.PutContents( gfile.Join(configPath, "config.yml"), "wrong config", ) - t.Assert(err, nil) + t.AssertNil(err) adapterFile, err := gcfg.NewAdapterFile("config.yml") t.AssertNil(err) diff --git a/os/gcmd/gcmd_z_unit_parser_test.go b/os/gcmd/gcmd_z_unit_parser_test.go index 2b7699f68..5a9307d01 100644 --- a/os/gcmd/gcmd_z_unit_parser_test.go +++ b/os/gcmd/gcmd_z_unit_parser_test.go @@ -25,7 +25,7 @@ func Test_Parse(t *testing.T) { "f,force": false, "q,quiet": false, }) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(len(p.GetArgAll()), 3) t.Assert(p.GetArg(0), "gf") t.Assert(p.GetArg(1), "remove") @@ -64,7 +64,7 @@ func Test_ParseArgs(t *testing.T) { "f,force": false, "q,quiet": false, }) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(len(p.GetArgAll()), 3) t.Assert(p.GetArg(0), "gf") t.Assert(p.GetArg(1), "remove") diff --git a/os/genv/genv_z_unit_test.go b/os/genv/genv_z_unit_test.go index ccdc9e5b7..b1b23e64c 100644 --- a/os/genv/genv_z_unit_test.go +++ b/os/genv/genv_z_unit_test.go @@ -29,7 +29,7 @@ func Test_GEnv_Map(t *testing.T) { value := gconv.String(gtime.TimestampNano()) key := "TEST_ENV_" + value err := os.Setenv(key, "TEST") - t.Assert(err, nil) + t.AssertNil(err) t.Assert(genv.Map()[key], "TEST") }) } @@ -39,7 +39,7 @@ func Test_GEnv_Get(t *testing.T) { value := gconv.String(gtime.TimestampNano()) key := "TEST_ENV_" + value err := os.Setenv(key, "TEST") - t.Assert(err, nil) + t.AssertNil(err) t.AssertEQ(genv.Get(key).String(), "TEST") }) } @@ -49,7 +49,7 @@ func Test_GEnv_GetVar(t *testing.T) { value := gconv.String(gtime.TimestampNano()) key := "TEST_ENV_" + value err := os.Setenv(key, "TEST") - t.Assert(err, nil) + t.AssertNil(err) t.AssertEQ(genv.Get(key).String(), "TEST") }) } @@ -59,7 +59,7 @@ func Test_GEnv_Contains(t *testing.T) { value := gconv.String(gtime.TimestampNano()) key := "TEST_ENV_" + value err := os.Setenv(key, "TEST") - t.Assert(err, nil) + t.AssertNil(err) t.AssertEQ(genv.Contains(key), true) t.AssertEQ(genv.Contains("none"), false) }) @@ -70,7 +70,7 @@ func Test_GEnv_Set(t *testing.T) { value := gconv.String(gtime.TimestampNano()) key := "TEST_ENV_" + value err := genv.Set(key, "TEST") - t.Assert(err, nil) + t.AssertNil(err) t.AssertEQ(os.Getenv(key), "TEST") }) } @@ -81,7 +81,7 @@ func Test_GEnv_SetMap(t *testing.T) { "K1": "TEST1", "K2": "TEST2", }) - t.Assert(err, nil) + t.AssertNil(err) t.AssertEQ(os.Getenv("K1"), "TEST1") t.AssertEQ(os.Getenv("K2"), "TEST2") }) @@ -102,9 +102,9 @@ func Test_GEnv_Remove(t *testing.T) { value := gconv.String(gtime.TimestampNano()) key := "TEST_ENV_" + value err := os.Setenv(key, "TEST") - t.Assert(err, nil) + t.AssertNil(err) err = genv.Remove(key) - t.Assert(err, nil) + t.AssertNil(err) t.AssertEQ(os.Getenv(key), "") }) } diff --git a/os/gfile/gfile_z_unit_contents_test.go b/os/gfile/gfile_z_unit_contents_test.go index bb9b01da3..684af97cf 100644 --- a/os/gfile/gfile_z_unit_contents_test.go +++ b/os/gfile/gfile_z_unit_contents_test.go @@ -100,10 +100,10 @@ func Test_Truncate(t *testing.T) { createTestFile(filepaths1, "abcdefghijkmln") defer delTestFiles(filepaths1) err = gfile.Truncate(testpath()+filepaths1, 10) - t.Assert(err, nil) + t.AssertNil(err) files, err = os.Open(testpath() + filepaths1) - t.Assert(err, nil) + t.AssertNil(err) defer files.Close() fileinfo, err2 := files.Stat() t.Assert(err2, nil) @@ -126,10 +126,10 @@ func Test_PutContents(t *testing.T) { defer delTestFiles(filepaths) err = gfile.PutContents(testpath()+filepaths, "test!") - t.Assert(err, nil) + t.AssertNil(err) readcontent, err = ioutil.ReadFile(testpath() + filepaths) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(string(readcontent), "test!") err = gfile.PutContents("", "test!") @@ -149,10 +149,10 @@ func Test_PutContentsAppend(t *testing.T) { createTestFile(filepaths, "a") defer delTestFiles(filepaths) err = gfile.PutContentsAppend(testpath()+filepaths, "hello") - t.Assert(err, nil) + t.AssertNil(err) readcontent, err = ioutil.ReadFile(testpath() + filepaths) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(string(readcontent), "ahello") err = gfile.PutContentsAppend("", "hello") @@ -173,10 +173,10 @@ func Test_PutBinContents(t *testing.T) { defer delTestFiles(filepaths) err = gfile.PutBytes(testpath()+filepaths, []byte("test!!")) - t.Assert(err, nil) + t.AssertNil(err) readcontent, err = ioutil.ReadFile(testpath() + filepaths) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(string(readcontent), "test!!") err = gfile.PutBytes("", []byte("test!!")) @@ -195,10 +195,10 @@ func Test_PutBinContentsAppend(t *testing.T) { createTestFile(filepaths, "test!!") defer delTestFiles(filepaths) err = gfile.PutBytesAppend(testpath()+filepaths, []byte("word")) - t.Assert(err, nil) + t.AssertNil(err) readcontent, err = ioutil.ReadFile(testpath() + filepaths) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(string(readcontent), "test!!word") err = gfile.PutBytesAppend("", []byte("word")) @@ -324,7 +324,7 @@ func Test_Home(t *testing.T) { ) reads, err = gfile.Home("a", "b") - t.Assert(err, nil) + t.AssertNil(err) t.AssertNE(reads, "") }) } diff --git a/os/gfile/gfile_z_unit_copy_test.go b/os/gfile/gfile_z_unit_copy_test.go index 6a00895fa..13557933d 100644 --- a/os/gfile/gfile_z_unit_copy_test.go +++ b/os/gfile/gfile_z_unit_copy_test.go @@ -127,7 +127,7 @@ func Test_CopyDir(t *testing.T) { t.Assert(gfile.GetContents(dst), dstContent) err := gfile.CopyDir(gfile.Dir(src), gfile.Dir(dst)) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(gfile.GetContents(src), srcContent) t.Assert(gfile.GetContents(dst), srcContent) diff --git a/os/gfile/gfile_z_unit_scan_test.go b/os/gfile/gfile_z_unit_scan_test.go index c64ec62c0..42e80faf5 100644 --- a/os/gfile/gfile_z_unit_scan_test.go +++ b/os/gfile/gfile_z_unit_scan_test.go @@ -19,14 +19,14 @@ func Test_ScanDir(t *testing.T) { teatPath := gdebug.TestDataPath() gtest.C(t, func(t *gtest.T) { files, err := gfile.ScanDir(teatPath, "*", false) - t.Assert(err, nil) + t.AssertNil(err) t.AssertIN(teatPath+gfile.Separator+"dir1", files) t.AssertIN(teatPath+gfile.Separator+"dir2", files) t.AssertNE(teatPath+gfile.Separator+"dir1"+gfile.Separator+"file1", files) }) gtest.C(t, func(t *gtest.T) { files, err := gfile.ScanDir(teatPath, "*", true) - t.Assert(err, nil) + t.AssertNil(err) t.AssertIN(teatPath+gfile.Separator+"dir1", files) t.AssertIN(teatPath+gfile.Separator+"dir2", files) t.AssertIN(teatPath+gfile.Separator+"dir1"+gfile.Separator+"file1", files) @@ -43,7 +43,7 @@ func Test_ScanDirFunc(t *testing.T) { } return path }) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(len(files), 1) t.Assert(gfile.Name(files[0]), "file1") }) @@ -53,12 +53,12 @@ func Test_ScanDirFile(t *testing.T) { teatPath := gdebug.TestDataPath() gtest.C(t, func(t *gtest.T) { files, err := gfile.ScanDirFile(teatPath, "*", false) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(len(files), 0) }) gtest.C(t, func(t *gtest.T) { files, err := gfile.ScanDirFile(teatPath, "*", true) - t.Assert(err, nil) + t.AssertNil(err) t.AssertNI(teatPath+gfile.Separator+"dir1", files) t.AssertNI(teatPath+gfile.Separator+"dir2", files) t.AssertIN(teatPath+gfile.Separator+"dir1"+gfile.Separator+"file1", files) @@ -74,7 +74,7 @@ func Test_ScanDirFileFunc(t *testing.T) { array.Append(1) return path }) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(len(files), 0) t.Assert(array.Len(), 0) }) @@ -87,7 +87,7 @@ func Test_ScanDirFileFunc(t *testing.T) { } return "" }) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(len(files), 1) t.Assert(array.Len(), 3) }) diff --git a/os/gfile/gfile_z_unit_search_test.go b/os/gfile/gfile_z_unit_search_test.go index 6a93d34a0..527abec5f 100644 --- a/os/gfile/gfile_z_unit_search_test.go +++ b/os/gfile/gfile_z_unit_search_test.go @@ -31,13 +31,13 @@ func Test_Search(t *testing.T) { ypaths1 = paths1 tpath, err = gfile.Search(testpath() + paths1) - t.Assert(err, nil) + t.AssertNil(err) tpath = filepath.ToSlash(tpath) // 自定义优先路径 tpath2, err = gfile.Search(testpath() + paths1) - t.Assert(err, nil) + t.AssertNil(err) tpath2 = filepath.ToSlash(tpath2) tempstr = testpath() diff --git a/os/gfile/gfile_z_unit_test.go b/os/gfile/gfile_z_unit_test.go index e290621e7..58f939069 100644 --- a/os/gfile/gfile_z_unit_test.go +++ b/os/gfile/gfile_z_unit_test.go @@ -69,7 +69,7 @@ func Test_Create(t *testing.T) { fileobj, err = gfile.Create(testpath() + v) defer delTestFiles(v) fileobj.Close() - t.Assert(err, nil) + t.AssertNil(err) } }) } @@ -97,7 +97,7 @@ func Test_Open(t *testing.T) { fileobj, err = gfile.Open(testpath() + v) fileobj.Close() if flags[k] { - t.Assert(err, nil) + t.AssertNil(err) } else { t.AssertNE(err, nil) } @@ -130,7 +130,7 @@ func Test_OpenFile(t *testing.T) { fileobj, err = gfile.OpenFile(testpath()+v, os.O_RDWR, 0666) fileobj.Close() if flags[k] { - t.Assert(err, nil) + t.AssertNil(err) } else { t.AssertNE(err, nil) } @@ -162,7 +162,7 @@ func Test_OpenWithFlag(t *testing.T) { fileobj, err = gfile.OpenWithFlag(testpath()+v, os.O_RDWR) fileobj.Close() if flags[k] { - t.Assert(err, nil) + t.AssertNil(err) } else { t.AssertNE(err, nil) } @@ -193,7 +193,7 @@ func Test_OpenWithFlagPerm(t *testing.T) { fileobj, err = gfile.OpenWithFlagPerm(testpath()+v, os.O_RDWR, 0666) fileobj.Close() if flags[k] { - t.Assert(err, nil) + t.AssertNil(err) } else { t.AssertNE(err, nil) } @@ -238,7 +238,7 @@ func Test_Exists(t *testing.T) { func Test_Pwd(t *testing.T) { gtest.C(t, func(t *gtest.T) { paths, err := os.Getwd() - t.Assert(err, nil) + t.AssertNil(err) t.Assert(gfile.Pwd(), paths) }) @@ -292,10 +292,10 @@ func Test_Info(t *testing.T) { createTestFile(paths, "") defer delTestFiles(paths) files, err = gfile.Stat(testpath() + paths) - t.Assert(err, nil) + t.AssertNil(err) files2, err = os.Stat(testpath() + paths) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(files, files2) @@ -370,7 +370,7 @@ func Test_DirNames(t *testing.T) { readlist, err = gfile.DirNames(testpath() + paths) - t.Assert(err, nil) + t.AssertNil(err) t.AssertIN(readlist, havelist) _, err = gfile.DirNames("") @@ -406,16 +406,16 @@ func Test_Glob(t *testing.T) { defer delTestFiles(dirpath) resultlist, err = gfile.Glob(testpath()+paths, true) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(resultlist, havelist1) resultlist, err = gfile.Glob(testpath()+paths, false) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(formatpaths(resultlist), formatpaths(havelist2)) _, err = gfile.Glob("", true) - t.Assert(err, nil) + t.AssertNil(err) }) } @@ -628,13 +628,13 @@ func Test_Mkdir(t *testing.T) { defer delTestFiles("/testfile") err = gfile.Mkdir(testpath() + tpath) - t.Assert(err, nil) + t.AssertNil(err) err = gfile.Mkdir("") t.AssertNE(err, nil) err = gfile.Mkdir(testpath() + tpath + "2/t1") - t.Assert(err, nil) + t.AssertNil(err) }) } @@ -652,7 +652,7 @@ func Test_Stat(t *testing.T) { defer delTestFiles(tpath1) fileiofo, err = gfile.Stat(testpath() + tpath1) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(fileiofo.Size(), 1) diff --git a/os/gfile/gfile_z_unit_time_test.go b/os/gfile/gfile_z_unit_time_test.go index bb22bf8a1..fb83d1faa 100644 --- a/os/gfile/gfile_z_unit_time_test.go +++ b/os/gfile/gfile_z_unit_time_test.go @@ -27,7 +27,7 @@ func Test_MTime(t *testing.T) { createTestFile(file1, "") defer delTestFiles(file1) fileobj, err = os.Stat(testpath() + file1) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(gfile.MTime(testpath()+file1), fileobj.ModTime()) t.Assert(gfile.MTime(""), "") @@ -45,7 +45,7 @@ func Test_MTimeMillisecond(t *testing.T) { createTestFile(file1, "") defer delTestFiles(file1) fileobj, err = os.Stat(testpath() + file1) - t.Assert(err, nil) + t.AssertNil(err) time.Sleep(time.Millisecond * 100) t.AssertGE( diff --git a/os/gfpool/gfpool_z_unit_test.go b/os/gfpool/gfpool_z_unit_test.go index 6ea9df9f0..6960d668c 100644 --- a/os/gfpool/gfpool_z_unit_test.go +++ b/os/gfpool/gfpool_z_unit_test.go @@ -150,29 +150,29 @@ func Test_ConcurrentOS(t *testing.T) { path := gfile.Temp(gtime.TimestampNanoStr()) defer gfile.Remove(path) f1, err := os.OpenFile(path, os.O_RDWR|os.O_CREATE|os.O_TRUNC|os.O_APPEND, 0666) - t.Assert(err, nil) + t.AssertNil(err) defer f1.Close() f2, err := os.OpenFile(path, os.O_RDWR|os.O_CREATE|os.O_TRUNC|os.O_APPEND, 0666) - t.Assert(err, nil) + t.AssertNil(err) defer f2.Close() for i := 0; i < 100; i++ { _, err = f1.Write([]byte("@1234567890#")) - t.Assert(err, nil) + t.AssertNil(err) } for i := 0; i < 100; i++ { _, err = f2.Write([]byte("@1234567890#")) - t.Assert(err, nil) + t.AssertNil(err) } for i := 0; i < 1000; i++ { _, err = f1.Write([]byte("@1234567890#")) - t.Assert(err, nil) + t.AssertNil(err) } for i := 0; i < 1000; i++ { _, err = f2.Write([]byte("@1234567890#")) - t.Assert(err, nil) + t.AssertNil(err) } t.Assert(gstr.Count(gfile.GetContents(path), "@1234567890#"), 2200) }) @@ -181,20 +181,20 @@ func Test_ConcurrentOS(t *testing.T) { path := gfile.Temp(gtime.TimestampNanoStr()) defer gfile.Remove(path) f1, err := os.OpenFile(path, os.O_RDWR|os.O_CREATE|os.O_TRUNC|os.O_APPEND, 0666) - t.Assert(err, nil) + t.AssertNil(err) defer f1.Close() f2, err := os.OpenFile(path, os.O_RDWR|os.O_CREATE|os.O_TRUNC|os.O_APPEND, 0666) - t.Assert(err, nil) + t.AssertNil(err) defer f2.Close() for i := 0; i < 1000; i++ { _, err = f1.Write([]byte("@1234567890#")) - t.Assert(err, nil) + t.AssertNil(err) } for i := 0; i < 1000; i++ { _, err = f2.Write([]byte("@1234567890#")) - t.Assert(err, nil) + t.AssertNil(err) } t.Assert(gstr.Count(gfile.GetContents(path), "@1234567890#"), 2000) }) @@ -202,11 +202,11 @@ func Test_ConcurrentOS(t *testing.T) { path := gfile.Temp(gtime.TimestampNanoStr()) defer gfile.Remove(path) f1, err := os.OpenFile(path, os.O_RDWR|os.O_CREATE|os.O_TRUNC|os.O_APPEND, 0666) - t.Assert(err, nil) + t.AssertNil(err) defer f1.Close() f2, err := os.OpenFile(path, os.O_RDWR|os.O_CREATE|os.O_TRUNC|os.O_APPEND, 0666) - t.Assert(err, nil) + t.AssertNil(err) defer f2.Close() s1 := "" @@ -214,14 +214,14 @@ func Test_ConcurrentOS(t *testing.T) { s1 += "@1234567890#" } _, err = f2.Write([]byte(s1)) - t.Assert(err, nil) + t.AssertNil(err) s2 := "" for i := 0; i < 1000; i++ { s2 += "@1234567890#" } _, err = f2.Write([]byte(s2)) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(gstr.Count(gfile.GetContents(path), "@1234567890#"), 2000) }) @@ -230,11 +230,11 @@ func Test_ConcurrentOS(t *testing.T) { // path := gfile.Temp(gtime.TimestampNanoStr()) // defer gfile.Remove(path) // f1, err := os.OpenFile(path, os.O_RDWR|os.O_CREATE|os.O_TRUNC|os.O_APPEND, 0666) - // t.Assert(err, nil) + // t.AssertNil(err) // defer f1.Close() // // f2, err := os.OpenFile(path, os.O_RDWR|os.O_CREATE|os.O_TRUNC|os.O_APPEND, 0666) - // t.Assert(err, nil) + // t.AssertNil(err) // defer f2.Close() // // wg := sync.WaitGroup{} @@ -245,7 +245,7 @@ func Test_ConcurrentOS(t *testing.T) { // defer wg.Done() // <-ch // _, err = f1.Write([]byte("@1234567890#")) - // t.Assert(err, nil) + // t.AssertNil(err) // }() // } // for i := 0; i < 1000; i++ { @@ -254,7 +254,7 @@ func Test_ConcurrentOS(t *testing.T) { // defer wg.Done() // <-ch // _, err = f2.Write([]byte("@1234567890#")) - // t.Assert(err, nil) + // t.AssertNil(err) // }() // } // close(ch) @@ -268,20 +268,20 @@ func Test_ConcurrentGFPool(t *testing.T) { path := gfile.Temp(gtime.TimestampNanoStr()) defer gfile.Remove(path) f1, err := gfpool.Open(path, os.O_RDWR|os.O_CREATE|os.O_TRUNC|os.O_APPEND, 0666) - t.Assert(err, nil) + t.AssertNil(err) defer f1.Close() f2, err := gfpool.Open(path, os.O_RDWR|os.O_CREATE|os.O_TRUNC|os.O_APPEND, 0666) - t.Assert(err, nil) + t.AssertNil(err) defer f2.Close() for i := 0; i < 1000; i++ { _, err = f1.Write([]byte("@1234567890#")) - t.Assert(err, nil) + t.AssertNil(err) } for i := 0; i < 1000; i++ { _, err = f2.Write([]byte("@1234567890#")) - t.Assert(err, nil) + t.AssertNil(err) } t.Assert(gstr.Count(gfile.GetContents(path), "@1234567890#"), 2000) }) @@ -290,11 +290,11 @@ func Test_ConcurrentGFPool(t *testing.T) { // path := gfile.Temp(gtime.TimestampNanoStr()) // defer gfile.Remove(path) // f1, err := gfpool.Open(path, os.O_RDWR|os.O_CREATE|os.O_TRUNC|os.O_APPEND, 0666) - // t.Assert(err, nil) + // t.AssertNil(err) // defer f1.Close() // // f2, err := gfpool.Open(path, os.O_RDWR|os.O_CREATE|os.O_TRUNC|os.O_APPEND, 0666) - // t.Assert(err, nil) + // t.AssertNil(err) // defer f2.Close() // // wg := sync.WaitGroup{} @@ -305,7 +305,7 @@ func Test_ConcurrentGFPool(t *testing.T) { // defer wg.Done() // <-ch // _, err = f1.Write([]byte("@1234567890#")) - // t.Assert(err, nil) + // t.AssertNil(err) // }() // } // for i := 0; i < 1000; i++ { @@ -314,7 +314,7 @@ func Test_ConcurrentGFPool(t *testing.T) { // defer wg.Done() // <-ch // _, err = f2.Write([]byte("@1234567890#")) - // t.Assert(err, nil) + // t.AssertNil(err) // }() // } // close(ch) diff --git a/os/gfsnotify/gfsnotify_z_unit_test.go b/os/gfsnotify/gfsnotify_z_unit_test.go index d72530b33..0cab0a6b0 100644 --- a/os/gfsnotify/gfsnotify_z_unit_test.go +++ b/os/gfsnotify/gfsnotify_z_unit_test.go @@ -24,31 +24,31 @@ func TestWatcher_AddOnce(t *testing.T) { value := gtype.New() path := gfile.Temp(gconv.String(gtime.TimestampNano())) err := gfile.PutContents(path, "init") - t.Assert(err, nil) + t.AssertNil(err) defer gfile.Remove(path) time.Sleep(100 * time.Millisecond) callback1, err := gfsnotify.AddOnce("mywatch", path, func(event *gfsnotify.Event) { value.Set(1) }) - t.Assert(err, nil) + t.AssertNil(err) callback2, err := gfsnotify.AddOnce("mywatch", path, func(event *gfsnotify.Event) { value.Set(2) }) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(callback2, nil) err = gfile.PutContents(path, "1") - t.Assert(err, nil) + t.AssertNil(err) time.Sleep(100 * time.Millisecond) t.Assert(value, 1) err = gfsnotify.RemoveCallback(callback1.Id) - t.Assert(err, nil) + t.AssertNil(err) err = gfile.PutContents(path, "2") - t.Assert(err, nil) + t.AssertNil(err) time.Sleep(100 * time.Millisecond) t.Assert(value, 1) @@ -76,7 +76,7 @@ func TestWatcher_AddRemove(t *testing.T) { return } }) - t.Assert(err, nil) + t.AssertNil(err) t.AssertNE(callback, nil) gfile.PutContents(path1, "2") @@ -105,7 +105,7 @@ func TestWatcher_AddRemove(t *testing.T) { return } }) - t.Assert(err, nil) + t.AssertNil(err) t.AssertNE(callback, nil) gfile.PutContents(path1, "2") @@ -136,7 +136,7 @@ func TestWatcher_Callback1(t *testing.T) { return } }) - t.Assert(err, nil) + t.AssertNil(err) t.AssertNE(callback, nil) gfile.PutContents(path1, "2") diff --git a/os/glog/glog_z_unit_config_test.go b/os/glog/glog_z_unit_config_test.go index 6b33466d9..bb31284d8 100644 --- a/os/glog/glog_z_unit_config_test.go +++ b/os/glog/glog_z_unit_config_test.go @@ -24,7 +24,7 @@ func Test_SetConfigWithMap(t *testing.T) { "StStatus": 0, } err := l.SetConfigWithMap(m) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(l.config.Path, m["path"]) t.Assert(l.config.Level, LEVEL_ALL) t.Assert(l.config.StdoutPrint, m["stdout"]) @@ -39,7 +39,7 @@ func Test_SetConfigWithMap_LevelStr(t *testing.T) { "level": "all", } err := l.SetConfigWithMap(m) - t.Assert(err, nil) + t.AssertNil(err) l.SetWriter(buffer) @@ -56,7 +56,7 @@ func Test_SetConfigWithMap_LevelStr(t *testing.T) { "level": "warn", } err := l.SetConfigWithMap(m) - t.Assert(err, nil) + t.AssertNil(err) l.SetWriter(buffer) l.Debug(ctx, "test") l.Warning(ctx, "test") diff --git a/os/glog/glog_z_unit_logger_chaining_test.go b/os/glog/glog_z_unit_logger_chaining_test.go index 1a0d958db..b794b8184 100644 --- a/os/glog/glog_z_unit_logger_chaining_test.go +++ b/os/glog/glog_z_unit_logger_chaining_test.go @@ -34,7 +34,7 @@ func Test_Path(t *testing.T) { file := fmt.Sprintf(`%d.log`, gtime.TimestampNano()) err := gfile.Mkdir(path) - t.Assert(err, nil) + t.AssertNil(err) defer gfile.Remove(path) Path(path).File(file).Stdout(false).Error(ctx, 1, 2, 3) @@ -52,7 +52,7 @@ func Test_Cat(t *testing.T) { file := fmt.Sprintf(`%d.log`, gtime.TimestampNano()) err := gfile.Mkdir(path) - t.Assert(err, nil) + t.AssertNil(err) defer gfile.Remove(path) Path(path).File(file).Cat(cat).Stdout(false).Error(ctx, 1, 2, 3) @@ -69,7 +69,7 @@ func Test_Level(t *testing.T) { file := fmt.Sprintf(`%d.log`, gtime.TimestampNano()) err := gfile.Mkdir(path) - t.Assert(err, nil) + t.AssertNil(err) defer gfile.Remove(path) Path(path).File(file).Level(LEVEL_PROD).Stdout(false).Debug(ctx, 1, 2, 3) @@ -86,7 +86,7 @@ func Test_Skip(t *testing.T) { file := fmt.Sprintf(`%d.log`, gtime.TimestampNano()) err := gfile.Mkdir(path) - t.Assert(err, nil) + t.AssertNil(err) defer gfile.Remove(path) Path(path).File(file).Skip(10).Stdout(false).Error(ctx, 1, 2, 3) @@ -105,7 +105,7 @@ func Test_Stack(t *testing.T) { file := fmt.Sprintf(`%d.log`, gtime.TimestampNano()) err := gfile.Mkdir(path) - t.Assert(err, nil) + t.AssertNil(err) defer gfile.Remove(path) Path(path).File(file).Stack(false).Stdout(false).Error(ctx, 1, 2, 3) @@ -124,7 +124,7 @@ func Test_StackWithFilter(t *testing.T) { file := fmt.Sprintf(`%d.log`, gtime.TimestampNano()) err := gfile.Mkdir(path) - t.Assert(err, nil) + t.AssertNil(err) defer gfile.Remove(path) Path(path).File(file).StackWithFilter("none").Stdout(false).Error(ctx, 1, 2, 3) @@ -140,7 +140,7 @@ func Test_StackWithFilter(t *testing.T) { file := fmt.Sprintf(`%d.log`, gtime.TimestampNano()) err := gfile.Mkdir(path) - t.Assert(err, nil) + t.AssertNil(err) defer gfile.Remove(path) Path(path).File(file).StackWithFilter("/gf/").Stdout(false).Error(ctx, 1, 2, 3) @@ -158,7 +158,7 @@ func Test_Header(t *testing.T) { file := fmt.Sprintf(`%d.log`, gtime.TimestampNano()) err := gfile.Mkdir(path) - t.Assert(err, nil) + t.AssertNil(err) defer gfile.Remove(path) Path(path).File(file).Header(true).Stdout(false).Error(ctx, 1, 2, 3) @@ -171,7 +171,7 @@ func Test_Header(t *testing.T) { file := fmt.Sprintf(`%d.log`, gtime.TimestampNano()) err := gfile.Mkdir(path) - t.Assert(err, nil) + t.AssertNil(err) defer gfile.Remove(path) Path(path).File(file).Header(false).Stdout(false).Error(ctx, 1, 2, 3) @@ -187,7 +187,7 @@ func Test_Line(t *testing.T) { file := fmt.Sprintf(`%d.log`, gtime.TimestampNano()) err := gfile.Mkdir(path) - t.Assert(err, nil) + t.AssertNil(err) defer gfile.Remove(path) Path(path).File(file).Line(true).Stdout(false).Debug(ctx, 1, 2, 3) @@ -203,7 +203,7 @@ func Test_Line(t *testing.T) { file := fmt.Sprintf(`%d.log`, gtime.TimestampNano()) err := gfile.Mkdir(path) - t.Assert(err, nil) + t.AssertNil(err) defer gfile.Remove(path) Path(path).File(file).Line(false).Stdout(false).Debug(ctx, 1, 2, 3) @@ -221,7 +221,7 @@ func Test_Async(t *testing.T) { file := fmt.Sprintf(`%d.log`, gtime.TimestampNano()) err := gfile.Mkdir(path) - t.Assert(err, nil) + t.AssertNil(err) defer gfile.Remove(path) Path(path).File(file).Async().Stdout(false).Debug(ctx, 1, 2, 3) @@ -239,7 +239,7 @@ func Test_Async(t *testing.T) { file := fmt.Sprintf(`%d.log`, gtime.TimestampNano()) err := gfile.Mkdir(path) - t.Assert(err, nil) + t.AssertNil(err) defer gfile.Remove(path) Path(path).File(file).Async(false).Stdout(false).Debug(ctx, 1, 2, 3) diff --git a/os/glog/glog_z_unit_logger_rotate_test.go b/os/glog/glog_z_unit_logger_rotate_test.go index f17719054..e777746f9 100644 --- a/os/glog/glog_z_unit_logger_rotate_test.go +++ b/os/glog/glog_z_unit_logger_rotate_test.go @@ -38,7 +38,7 @@ func Test_Rotate_Size(t *testing.T) { "RotateBackupCompress": 9, "RotateCheckInterval": time.Second, // For unit testing only. }) - t.Assert(err, nil) + t.AssertNil(err) defer gfile.Remove(p) s := "1234567890abcdefg" @@ -50,7 +50,7 @@ func Test_Rotate_Size(t *testing.T) { time.Sleep(time.Second * 3) files, err := gfile.ScanDirFile(p, "*.gz") - t.Assert(err, nil) + t.AssertNil(err) t.Assert(len(files), 2) content := gfile.GetContents(gfile.Join(p, "access.log")) @@ -58,7 +58,7 @@ func Test_Rotate_Size(t *testing.T) { time.Sleep(time.Second * 5) files, err = gfile.ScanDirFile(p, "*.gz") - t.Assert(err, nil) + t.AssertNil(err) t.Assert(len(files), 0) }) } @@ -77,7 +77,7 @@ func Test_Rotate_Expire(t *testing.T) { "RotateBackupCompress": 9, "RotateCheckInterval": time.Second, // For unit testing only. }) - t.Assert(err, nil) + t.AssertNil(err) defer gfile.Remove(p) s := "1234567890abcdefg" @@ -86,7 +86,7 @@ func Test_Rotate_Expire(t *testing.T) { } files, err := gfile.ScanDirFile(p, "*.gz") - t.Assert(err, nil) + t.AssertNil(err) t.Assert(len(files), 0) t.Assert(gstr.Count(gfile.GetContents(gfile.Join(p, "access.log")), s), 10) @@ -94,14 +94,14 @@ func Test_Rotate_Expire(t *testing.T) { time.Sleep(time.Second * 3) files, err = gfile.ScanDirFile(p, "*.gz") - t.Assert(err, nil) + t.AssertNil(err) t.Assert(len(files), 1) t.Assert(gstr.Count(gfile.GetContents(gfile.Join(p, "access.log")), s), 0) time.Sleep(time.Second * 5) files, err = gfile.ScanDirFile(p, "*.gz") - t.Assert(err, nil) + t.AssertNil(err) t.Assert(len(files), 0) }) } diff --git a/os/glog/glog_z_unit_test.go b/os/glog/glog_z_unit_test.go index f22677dbd..7f99cee0a 100644 --- a/os/glog/glog_z_unit_test.go +++ b/os/glog/glog_z_unit_test.go @@ -43,7 +43,7 @@ func Test_Ctx_Config(t *testing.T) { "CtxKeys": g.SliceStr{"Trace-Id", "Span-Id", "Test"}, } err := l.SetConfigWithMap(m) - t.Assert(err, nil) + t.AssertNil(err) ctx := context.WithValue(context.Background(), "Trace-Id", "1234567890") ctx = context.WithValue(ctx, "Span-Id", "abcdefg") diff --git a/os/gres/gres_z_unit_test.go b/os/gres/gres_z_unit_test.go index 1a1975410..2a5b424c7 100644 --- a/os/gres/gres_z_unit_test.go +++ b/os/gres/gres_z_unit_test.go @@ -28,7 +28,7 @@ func Test_PackToGoFile(t *testing.T) { pkgName = "testdata" err = gres.PackToGoFile(srcPath, goFilePath, pkgName) ) - t.Assert(err, nil) + t.AssertNil(err) _ = gfile.Remove(goFilePath) }) } @@ -39,11 +39,11 @@ func Test_Pack(t *testing.T) { srcPath = gdebug.TestDataPath("files") data, err = gres.Pack(srcPath) ) - t.Assert(err, nil) + t.AssertNil(err) r := gres.New() err = r.Add(string(data)) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(r.Contains("files/"), true) }) } @@ -55,13 +55,13 @@ func Test_PackToFile(t *testing.T) { dstPath = gfile.Temp(gtime.TimestampNanoStr()) err = gres.PackToFile(srcPath, dstPath) ) - t.Assert(err, nil) + t.AssertNil(err) defer gfile.Remove(dstPath) r := gres.New() err = r.Load(dstPath) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(r.Contains("files"), true) }) } @@ -74,9 +74,9 @@ func Test_PackMulti(t *testing.T) { pkgName = "data" array, err = gfile.ScanDir(srcPath, "*", false) ) - t.Assert(err, nil) + t.AssertNil(err) err = gres.PackToGoFile(strings.Join(array, ","), goFilePath, pkgName) - t.Assert(err, nil) + t.AssertNil(err) _ = gfile.Remove(goFilePath) }) } @@ -102,7 +102,7 @@ func Test_PackWithPrefix2(t *testing.T) { pkgName = "testdata" err = gres.PackToGoFile(srcPath, goFilePath, pkgName, "/var/www/gf-site/test") ) - t.Assert(err, nil) + t.AssertNil(err) _ = gfile.Remove(goFilePath) }) } @@ -127,13 +127,13 @@ func Test_Basic(t *testing.T) { t.Assert(info.Name(), "test1") rc, err := file.Open() - t.Assert(err, nil) + t.AssertNil(err) defer rc.Close() b := make([]byte, 5) n, err := rc.Read(b) t.Assert(n, 5) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(string(b), "test1") t.Assert(file.Content(), "test1 content") @@ -151,7 +151,7 @@ func Test_Basic(t *testing.T) { t.Assert(info.Name(), "dir2") rc, err := file.Open() - t.Assert(err, nil) + t.AssertNil(err) defer rc.Close() t.Assert(file.Content(), nil) diff --git a/os/gsession/gsession_z_unit_storage_redis_hashtable_test.go b/os/gsession/gsession_z_unit_storage_redis_hashtable_test.go index 22b5bdc44..c135d99a3 100644 --- a/os/gsession/gsession_z_unit_storage_redis_hashtable_test.go +++ b/os/gsession/gsession_z_unit_storage_redis_hashtable_test.go @@ -88,7 +88,7 @@ func Test_StorageRedisHashTablePrefix(t *testing.T) { Db: 0, }) gtest.C(t, func(t *gtest.T) { - t.Assert(err, nil) + t.AssertNil(err) }) prefix := "s_" diff --git a/os/gsession/gsession_z_unit_storage_redis_test.go b/os/gsession/gsession_z_unit_storage_redis_test.go index 13461c55f..dbb1e3d6a 100644 --- a/os/gsession/gsession_z_unit_storage_redis_test.go +++ b/os/gsession/gsession_z_unit_storage_redis_test.go @@ -22,7 +22,7 @@ func Test_StorageRedis(t *testing.T) { Address: "127.0.0.1:6379", Db: 0, }) - gtest.Assert(err, nil) + gtest.AssertNil(err) storage := gsession.NewStorageRedis(redis) manager := gsession.New(time.Second, storage) @@ -86,7 +86,7 @@ func Test_StorageRedisPrefix(t *testing.T) { Address: "127.0.0.1:6379", Db: 0, }) - gtest.Assert(err, nil) + gtest.AssertNil(err) prefix := "s_" storage := gsession.NewStorageRedis(redis, prefix) diff --git a/os/gspath/gspath_z_unit_test.go b/os/gspath/gspath_z_unit_test.go index 907dff4b6..b269585a6 100644 --- a/os/gspath/gspath_z_unit_test.go +++ b/os/gspath/gspath_z_unit_test.go @@ -45,7 +45,7 @@ func TestSPath_Basic(t *testing.T) { defer gfile.Remove(gfile.Join(root, "gf_tmp")) gsp := gspath.New(root, false) realPath, err := gsp.Add(gfile.Join(root, "gf_tmp")) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(realPath, gfile.Join(root, "gf_tmp")) realPath, err = gsp.Add("gf_tmp1") t.Assert(err != nil, true) @@ -65,7 +65,7 @@ func TestSPath_Basic(t *testing.T) { t.Assert(realPath, "") realPath, err = gsp.Set(root) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(realPath, root) fp, isDir := gsp.Search("gf_tmp") @@ -80,7 +80,7 @@ func TestSPath_Basic(t *testing.T) { gsp = gspath.New(root, true) realPath, err = gsp.Add(gfile.Join(root, "gf_tmp")) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(realPath, gfile.Join(root, "gf_tmp")) gfile.Mkdir(gfile.Join(root, "gf_tmp1")) diff --git a/os/gtime/gtime_z_unit_feature_sql_test.go b/os/gtime/gtime_z_unit_feature_sql_test.go index b4133daad..015425bb0 100644 --- a/os/gtime/gtime_z_unit_feature_sql_test.go +++ b/os/gtime/gtime_z_unit_feature_sql_test.go @@ -30,12 +30,12 @@ func TestTime_Value(t1 *testing.T) { gtest.C(t1, func(t *gtest.T) { tt := gtime.Now() s, err := tt.Value() - t.Assert(err, nil) + t.AssertNil(err) t.Assert(s, tt.Time) // test nil none := (*gtime.Time)(nil) s, err = none.Value() - t.Assert(err, nil) + t.AssertNil(err) t.Assert(s, nil) }) diff --git a/os/gtime/gtime_z_unit_test.go b/os/gtime/gtime_z_unit_test.go index a65635507..7d51f20ed 100644 --- a/os/gtime/gtime_z_unit_test.go +++ b/os/gtime/gtime_z_unit_test.go @@ -105,7 +105,7 @@ func Test_StrToTime(t *testing.T) { for _, item := range testDateTimes { timeTemp, err := gtime.StrToTime(item) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(timeTemp.Time.Format("2006-01-02 15:04:05"), "2006-01-02 15:04:05") } @@ -118,7 +118,7 @@ func Test_StrToTime(t *testing.T) { for _, item := range testDates { timeTemp, err := gtime.StrToTime(item) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(timeTemp.Time.Format("2006-01-02 15:04:05"), "2006-01-02 00:00:00") } @@ -130,9 +130,9 @@ func Test_StrToTime(t *testing.T) { for k, v := range testTimes { time1, err := gtime.StrToTime(k) - t.Assert(err, nil) + t.AssertNil(err) time2, err := time.ParseInLocation(v, k, time.Local) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(time1.Time, time2) } @@ -232,22 +232,22 @@ func Test_ConvertZone(t *testing.T) { func Test_ParseDuration(t *testing.T) { gtest.C(t, func(t *gtest.T) { d, err := gtime.ParseDuration("1d") - t.Assert(err, nil) + t.AssertNil(err) t.Assert(d.String(), "24h0m0s") }) gtest.C(t, func(t *gtest.T) { d, err := gtime.ParseDuration("1d2h3m") - t.Assert(err, nil) + t.AssertNil(err) t.Assert(d.String(), "26h3m0s") }) gtest.C(t, func(t *gtest.T) { d, err := gtime.ParseDuration("-1d2h3m") - t.Assert(err, nil) + t.AssertNil(err) t.Assert(d.String(), "-26h3m0s") }) gtest.C(t, func(t *gtest.T) { d, err := gtime.ParseDuration("3m") - t.Assert(err, nil) + t.AssertNil(err) t.Assert(d.String(), "3m0s") }) // error diff --git a/os/gview/gview_z_unit_config_test.go b/os/gview/gview_z_unit_config_test.go index ea70d0a08..f8c125b5e 100644 --- a/os/gview/gview_z_unit_config_test.go +++ b/os/gview/gview_z_unit_config_test.go @@ -28,16 +28,16 @@ func Test_Config(t *testing.T) { } view := gview.New() err := view.SetConfig(config) - t.Assert(err, nil) + t.AssertNil(err) str := `hello ${.name},version:${.version}` view.Assigns(g.Map{"version": "1.7.0"}) result, err := view.ParseContent(context.TODO(), str, nil) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(result, "hello gf,version:1.7.0") result, err = view.ParseDefault(context.TODO()) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(result, "name:gf") }) } @@ -53,16 +53,16 @@ func Test_ConfigWithMap(t *testing.T) { "name": "gf", }, }) - t.Assert(err, nil) + t.AssertNil(err) str := `hello ${.name},version:${.version}` view.Assigns(g.Map{"version": "1.7.0"}) result, err := view.ParseContent(context.TODO(), str, nil) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(result, "hello gf,version:1.7.0") result, err = view.ParseDefault(context.TODO()) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(result, "name:gf") }) } diff --git a/os/gview/gview_z_unit_feature_encode_test.go b/os/gview/gview_z_unit_feature_encode_test.go index dc7913de5..55a3665ba 100644 --- a/os/gview/gview_z_unit_feature_encode_test.go +++ b/os/gview/gview_z_unit_feature_encode_test.go @@ -25,7 +25,7 @@ func Test_Encode_Parse(t *testing.T) { result, err := v.Parse(context.TODO(), "encode.tpl", g.Map{ "title": "my title", }) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(result, "
<b>my title</b>
") }) } @@ -38,7 +38,7 @@ func Test_Encode_ParseContent(t *testing.T) { result, err := v.ParseContent(context.TODO(), tplContent, g.Map{ "title": "my title", }) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(result, "
<b>my title</b>
") }) } diff --git a/os/gview/gview_z_unit_i18n_test.go b/os/gview/gview_z_unit_i18n_test.go index 58c1c27d5..5b22b8250 100644 --- a/os/gview/gview_z_unit_i18n_test.go +++ b/os/gview/gview_z_unit_i18n_test.go @@ -29,21 +29,21 @@ func Test_I18n(t *testing.T) { result1, err := g.View().ParseContent(context.TODO(), content, g.Map{ "name": "john", }) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(result1, expect1) g.I18n().SetLanguage("ja") result2, err := g.View().ParseContent(context.TODO(), content, g.Map{ "name": "john", }) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(result2, expect2) g.I18n().SetLanguage("none") result3, err := g.View().ParseContent(context.TODO(), content, g.Map{ "name": "john", }) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(result3, expect3) }) gtest.C(t, func(t *gtest.T) { @@ -58,21 +58,21 @@ func Test_I18n(t *testing.T) { "name": "john", "I18nLanguage": "zh-CN", }) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(result1, expect1) result2, err := g.View().ParseContent(context.TODO(), content, g.Map{ "name": "john", "I18nLanguage": "ja", }) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(result2, expect2) result3, err := g.View().ParseContent(context.TODO(), content, g.Map{ "name": "john", "I18nLanguage": "none", }) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(result3, expect3) }) } diff --git a/os/gview/gview_z_unit_test.go b/os/gview/gview_z_unit_test.go index 8a298ea96..10468557d 100644 --- a/os/gview/gview_z_unit_test.go +++ b/os/gview/gview_z_unit_test.go @@ -176,7 +176,7 @@ func Test_Func(t *testing.T) { str = `{{concat "I" "Love" "GoFrame"}}` result, err = gview.ParseContent(context.TODO(), str, nil) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(result, `ILoveGoFrame`) }) // eq: multiple values. @@ -198,7 +198,7 @@ func Test_FuncNl2Br(t *testing.T) { gtest.C(t, func(t *gtest.T) { str := `{{"Go\nFrame" | nl2br}}` result, err := gview.ParseContent(context.TODO(), str, nil) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(result, `Go
Frame`) }) gtest.C(t, func(t *gtest.T) { @@ -210,7 +210,7 @@ func Test_FuncNl2Br(t *testing.T) { result, err := gview.ParseContent(context.TODO(), str, g.Map{ "content": s, }) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(result, strings.Replace(s, "\n", "
", -1)) }) } @@ -305,7 +305,7 @@ func Test_HotReload(t *testing.T) { // Initialize data. err := gfile.PutContents(filePath, "test:{{.var}}") - t.Assert(err, nil) + t.AssertNil(err) view := gview.New(dirPath) @@ -313,18 +313,18 @@ func Test_HotReload(t *testing.T) { result, err := view.Parse(context.TODO(), "test.html", g.Map{ "var": "1", }) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(result, `test:1`) // Update data. err = gfile.PutContents(filePath, "test2:{{.var}}") - t.Assert(err, nil) + t.AssertNil(err) time.Sleep(100 * time.Millisecond) result, err = view.Parse(context.TODO(), "test.html", g.Map{ "var": "2", }) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(result, `test2:2`) }) } @@ -336,7 +336,7 @@ func Test_XSS(t *testing.T) { r, err := v.ParseContent(context.TODO(), "{{.v}}", g.Map{ "v": s, }) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(r, s) }) gtest.C(t, func(t *gtest.T) { @@ -346,7 +346,7 @@ func Test_XSS(t *testing.T) { r, err := v.ParseContent(context.TODO(), "{{.v}}", g.Map{ "v": s, }) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(r, ghtml.Entities(s)) }) // Tag "if". @@ -357,7 +357,7 @@ func Test_XSS(t *testing.T) { r, err := v.ParseContent(context.TODO(), "{{if eq 1 1}}{{.v}}{{end}}", g.Map{ "v": s, }) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(r, ghtml.Entities(s)) }) } @@ -376,7 +376,7 @@ func Test_BuildInFuncMap(t *testing.T) { v := gview.New() v.Assign("v", new(TypeForBuildInFuncMap)) r, err := v.ParseContent(context.TODO(), "{{range $k, $v := map .v.Test}} {{$k}}:{{$v}} {{end}}") - t.Assert(err, nil) + t.AssertNil(err) t.Assert(gstr.Contains(r, "Name:john"), true) t.Assert(gstr.Contains(r, "Score:99.9"), true) }) @@ -399,7 +399,7 @@ func Test_BuildInFuncMaps(t *testing.T) { v := gview.New() v.Assign("v", new(TypeForBuildInFuncMaps)) r, err := v.ParseContent(context.TODO(), "{{range $k, $v := maps .v.Test}} {{$k}}:{{$v.Name}} {{$v.Score}} {{end}}") - t.Assert(err, nil) + t.AssertNil(err) t.Assert(r, ` 0:john 99.9 1:smith 100 `) }) } @@ -412,7 +412,7 @@ func Test_BuildInFuncDump(t *testing.T) { "score": 100, }) r, err := v.ParseContent(context.TODO(), "{{dump .}}") - t.Assert(err, nil) + t.AssertNil(err) fmt.Println(r) t.Assert(gstr.Contains(r, `"name": "john"`), true) t.Assert(gstr.Contains(r, `"score": 100`), true) @@ -426,7 +426,7 @@ func Test_BuildInFuncJson(t *testing.T) { "name": "john", }) r, err := v.ParseContent(context.TODO(), "{{json .v}}") - t.Assert(err, nil) + t.AssertNil(err) t.Assert(r, `{"name":"john"}`) }) } @@ -438,7 +438,7 @@ func Test_BuildInFuncXml(t *testing.T) { "name": "john", }) r, err := v.ParseContent(context.TODO(), "{{xml .v}}") - t.Assert(err, nil) + t.AssertNil(err) t.Assert(r, `john`) }) } @@ -499,7 +499,7 @@ func Test_BuildInFuncPlus(t *testing.T) { gtest.C(t, func(t *gtest.T) { v := gview.New() r, err := v.ParseContent(gctx.New(), "{{plus 1 2 3}}") - t.Assert(err, nil) + t.AssertNil(err) t.Assert(r, `6`) }) } @@ -508,7 +508,7 @@ func Test_BuildInFuncMinus(t *testing.T) { gtest.C(t, func(t *gtest.T) { v := gview.New() r, err := v.ParseContent(gctx.New(), "{{minus 1 2 3}}") - t.Assert(err, nil) + t.AssertNil(err) t.Assert(r, `-4`) }) } @@ -517,7 +517,7 @@ func Test_BuildInFuncTimes(t *testing.T) { gtest.C(t, func(t *gtest.T) { v := gview.New() r, err := v.ParseContent(gctx.New(), "{{times 1 2 3 4}}") - t.Assert(err, nil) + t.AssertNil(err) t.Assert(r, `24`) }) } @@ -526,7 +526,7 @@ func Test_BuildInFuncDivide(t *testing.T) { gtest.C(t, func(t *gtest.T) { v := gview.New() r, err := v.ParseContent(gctx.New(), "{{divide 8 2 2}}") - t.Assert(err, nil) + t.AssertNil(err) t.Assert(r, `2`) }) } diff --git a/text/gregex/gregex_z_unit_test.go b/text/gregex/gregex_z_unit_test.go index bf9aae5ab..ca07f8407 100644 --- a/text/gregex/gregex_z_unit_test.go +++ b/text/gregex/gregex_z_unit_test.go @@ -70,7 +70,7 @@ func Test_Match(t *testing.T) { wantSubs := "aaabb" s := "acbb" + wantSubs + "dd" subs, err := gregex.Match(re, []byte(s)) - t.Assert(err, nil) + t.AssertNil(err) if string(subs[0]) != wantSubs { t.Fatalf("regex:%s,Match(%q)[0] = %q; want %q", re, s, subs[0], wantSubs) } @@ -89,7 +89,7 @@ func Test_MatchString(t *testing.T) { wantSubs := "aaabb" s := "acbb" + wantSubs + "dd" subs, err := gregex.MatchString(re, s) - t.Assert(err, nil) + t.AssertNil(err) if string(subs[0]) != wantSubs { t.Fatalf("regex:%s,Match(%q)[0] = %q; want %q", re, s, subs[0], wantSubs) } @@ -109,7 +109,7 @@ func Test_MatchAll(t *testing.T) { s := "acbb" + wantSubs + "dd" s = s + `其他的` + s subs, err := gregex.MatchAll(re, []byte(s)) - t.Assert(err, nil) + t.AssertNil(err) if string(subs[0][0]) != wantSubs { t.Fatalf("regex:%s,Match(%q)[0] = %q; want %q", re, s, subs[0][0], wantSubs) } @@ -135,7 +135,7 @@ func Test_MatchAllString(t *testing.T) { wantSubs := "aaabb" s := "acbb" + wantSubs + "dd" subs, err := gregex.MatchAllString(re, s+`其他的`+s) - t.Assert(err, nil) + t.AssertNil(err) if string(subs[0][0]) != wantSubs { t.Fatalf("regex:%s,Match(%q)[0] = %q; want %q", re, s, subs[0][0], wantSubs) } @@ -163,7 +163,7 @@ func Test_Replace(t *testing.T) { s := "acbb" + wantSubs + "dd" wanted := "acbb" + replace + "dd" replacedStr, err := gregex.Replace(re, []byte(replace), []byte(s)) - t.Assert(err, nil) + t.AssertNil(err) if string(replacedStr) != wanted { t.Fatalf("regex:%s,old:%s; want %q", re, s, wanted) } @@ -181,7 +181,7 @@ func Test_ReplaceString(t *testing.T) { s := "acbb" + wantSubs + "dd" wanted := "acbb" + replace + "dd" replacedStr, err := gregex.ReplaceString(re, replace, s) - t.Assert(err, nil) + t.AssertNil(err) if replacedStr != wanted { t.Fatalf("regex:%s,old:%s; want %q", re, s, wanted) } @@ -205,7 +205,7 @@ func Test_ReplaceFun(t *testing.T) { } return []byte("[x" + string(s) + "y]") }) - t.Assert(err, nil) + t.AssertNil(err) if string(replacedStr) != wanted { t.Fatalf("regex:%s,old:%s; want %q", re, s, wanted) } @@ -263,7 +263,7 @@ func Test_ReplaceStringFunc(t *testing.T) { } return "[x" + s + "y]" }) - t.Assert(err, nil) + t.AssertNil(err) if replacedStr != wanted { t.Fatalf("regex:%s,old:%s; want %q", re, s, wanted) } diff --git a/text/gstr/gstr_z_unit_parse_test.go b/text/gstr/gstr_z_unit_parse_test.go index 1dbed1ac5..9d4bd90cd 100644 --- a/text/gstr/gstr_z_unit_parse_test.go +++ b/text/gstr/gstr_z_unit_parse_test.go @@ -22,41 +22,41 @@ func Test_Parse(t *testing.T) { gtest.C(t, func(t *gtest.T) { s := "goframe.org/index?name=john&score=100" u, err := url.Parse(s) - t.Assert(err, nil) + t.AssertNil(err) m, err := gstr.Parse(u.RawQuery) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(m["name"], "john") t.Assert(m["score"], "100") // name overwrite m, err = gstr.Parse("a=1&a=2") - t.Assert(err, nil) + t.AssertNil(err) t.Assert(m, g.Map{ "a": 2, }) // slice m, err = gstr.Parse("a[]=1&a[]=2") - t.Assert(err, nil) + t.AssertNil(err) t.Assert(m, g.Map{ "a": g.Slice{"1", "2"}, }) // map m, err = gstr.Parse("a=1&b=2&c=3") - t.Assert(err, nil) + t.AssertNil(err) t.Assert(m, g.Map{ "a": "1", "b": "2", "c": "3", }) m, err = gstr.Parse("a=1&a=2&c=3") - t.Assert(err, nil) + t.AssertNil(err) t.Assert(m, g.Map{ "a": "2", "c": "3", }) // map m, err = gstr.Parse("m[a]=1&m[b]=2&m[c]=3") - t.Assert(err, nil) + t.AssertNil(err) t.Assert(m, g.Map{ "m": g.Map{ "a": "1", @@ -65,7 +65,7 @@ func Test_Parse(t *testing.T) { }, }) m, err = gstr.Parse("m[a]=1&m[a]=2&m[b]=3") - t.Assert(err, nil) + t.AssertNil(err) t.Assert(m, g.Map{ "m": g.Map{ "a": "2", @@ -74,14 +74,14 @@ func Test_Parse(t *testing.T) { }) // map - slice m, err = gstr.Parse("m[a][]=1&m[a][]=2") - t.Assert(err, nil) + t.AssertNil(err) t.Assert(m, g.Map{ "m": g.Map{ "a": g.Slice{"1", "2"}, }, }) m, err = gstr.Parse("m[a][b][]=1&m[a][b][]=2") - t.Assert(err, nil) + t.AssertNil(err) t.Assert(m, g.Map{ "m": g.Map{ "a": g.Map{ @@ -91,7 +91,7 @@ func Test_Parse(t *testing.T) { }) // map - complicated m, err = gstr.Parse("m[a1][b1][c1][d1]=1&m[a2][b2]=2&m[a3][b3][c3]=3") - t.Assert(err, nil) + t.AssertNil(err) t.Assert(m, g.Map{ "m": g.Map{ "a1": g.Map{ diff --git a/util/gconv/gconv_z_unit_all_test.go b/util/gconv/gconv_z_unit_all_test.go index 6868e5d95..ab04223cc 100644 --- a/util/gconv/gconv_z_unit_all_test.go +++ b/util/gconv/gconv_z_unit_all_test.go @@ -1366,7 +1366,7 @@ func Test_Struct_PrivateAttribute_All(t *testing.T) { gtest.C(t, func(t *gtest.T) { user := new(User) err := gconv.Struct(g.Map{"id": 1, "name": "john"}, user) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(user.Id, 1) t.Assert(user.name, "") }) diff --git a/util/gconv/gconv_z_unit_custom_type_test.go b/util/gconv/gconv_z_unit_custom_type_test.go index 1bf79cd87..d6b168b63 100644 --- a/util/gconv/gconv_z_unit_custom_type_test.go +++ b/util/gconv/gconv_z_unit_custom_type_test.go @@ -36,6 +36,6 @@ func Test_Struct_CustomTimeDuration_Attribute(t *testing.T) { "name": "john", "timeout": "1s", }, &a) - t.Assert(err, nil) + t.AssertNil(err) }) } diff --git a/util/gconv/gconv_z_unit_map_test.go b/util/gconv/gconv_z_unit_map_test.go index c34897909..634d0ebd1 100644 --- a/util/gconv/gconv_z_unit_map_test.go +++ b/util/gconv/gconv_z_unit_map_test.go @@ -464,14 +464,14 @@ field3: parsed := &Outer{} err := yaml.Unmarshal(problemYaml, parsed) - t.Assert(err, nil) + t.AssertNil(err) _, err = json.Marshal(parsed) t.Assert(err.Error(), "json: unsupported type: map[interface {}]interface {}") converted := gconv.MapDeep(parsed) jsonData, err := json.Marshal(converted) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(string(jsonData), `{"field3":{"123":"integer_key"},"outer_struct":{"field1":{"inner1":123,"inner2":345},"field2":{"inner1":123,"inner2":345,"inner3":456,"inner4":789}}}`) }) diff --git a/util/gconv/gconv_z_unit_maptomap_test.go b/util/gconv/gconv_z_unit_maptomap_test.go index ea0aa9db2..78500ec99 100644 --- a/util/gconv/gconv_z_unit_maptomap_test.go +++ b/util/gconv/gconv_z_unit_maptomap_test.go @@ -91,7 +91,7 @@ func Test_MapToMap2(t *testing.T) { gtest.C(t, func(t *gtest.T) { m := (map[string]User)(nil) err := gconv.MapToMap(params, &m) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(len(m), 1) t.Assert(m["key"].Id, 1) t.Assert(m["key"].Name, "john") @@ -99,7 +99,7 @@ func Test_MapToMap2(t *testing.T) { gtest.C(t, func(t *gtest.T) { m := make(map[string]*User) err := gconv.MapToMap(params, &m) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(len(m), 1) t.Assert(m["key"].Id, 1) t.Assert(m["key"].Name, "john") @@ -107,7 +107,7 @@ func Test_MapToMap2(t *testing.T) { gtest.C(t, func(t *gtest.T) { m := (map[string]*User)(nil) err := gconv.MapToMap(params, &m) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(len(m), 1) t.Assert(m["key"].Id, 1) t.Assert(m["key"].Name, "john") @@ -136,7 +136,7 @@ func Test_MapToMapDeep(t *testing.T) { gtest.C(t, func(t *gtest.T) { m := (map[string]*User)(nil) err := gconv.MapToMap(params, &m) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(len(m), 1) t.Assert(m["key"].Id, 1) t.Assert(m["key"].Name, "john") diff --git a/util/gconv/gconv_z_unit_scan_test.go b/util/gconv/gconv_z_unit_scan_test.go index 12d488d90..f94bf3e1a 100644 --- a/util/gconv/gconv_z_unit_scan_test.go +++ b/util/gconv/gconv_z_unit_scan_test.go @@ -35,7 +35,7 @@ func Test_Scan_StructStructs(t *testing.T) { } ) err := gconv.Scan(params, user) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(user, &User{ Uid: 1, Name: "john", @@ -93,7 +93,7 @@ func Test_Scan_StructStr(t *testing.T) { params = `{"uid":1,"name":"john", "pass1":"123","pass2":"456"}` ) err := gconv.Scan(params, user) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(user, &User{ Uid: 1, Name: "john", @@ -110,7 +110,7 @@ func Test_Scan_StructStr(t *testing.T) { ]` ) err := gconv.Scan(params, &users) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(users, g.Slice{ &User{ Uid: 1, diff --git a/util/gconv/gconv_z_unit_slice_test.go b/util/gconv/gconv_z_unit_slice_test.go index 750711daa..019bf4aec 100644 --- a/util/gconv/gconv_z_unit_slice_test.go +++ b/util/gconv/gconv_z_unit_slice_test.go @@ -163,7 +163,7 @@ func Test_Slice_Structs(t *testing.T) { {"id": 2, "name": "smith", "age": 20}, } err := gconv.Structs(params, &users) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(len(users), 2) t.Assert(users[0].Id, params[0]["id"]) t.Assert(users[0].Name, params[0]["name"]) diff --git a/util/gconv/gconv_z_unit_struct_marshal_unmarshal_test.go b/util/gconv/gconv_z_unit_struct_marshal_unmarshal_test.go index c6381923b..b200e732b 100644 --- a/util/gconv/gconv_z_unit_struct_marshal_unmarshal_test.go +++ b/util/gconv/gconv_z_unit_struct_marshal_unmarshal_test.go @@ -40,7 +40,7 @@ func Test_Struct_UnmarshalValue1(t *testing.T) { gtest.C(t, func(t *gtest.T) { st := &MyTimeSt{} err := gconv.Struct(g.Map{"ServiceDate": "2020-10-10 12:00:01"}, st) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(st.ServiceDate.Time.Format("2006-01-02 15:04:05"), "2020-10-10 12:00:01") }) gtest.C(t, func(t *gtest.T) { @@ -103,7 +103,7 @@ func Test_Struct_UnmarshalValue2(t *testing.T) { var p1, p2 *Pkg p1 = NewPkg([]byte("123")) err := gconv.Struct(p1.Marshal(), &p2) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(p1, p2) }) } diff --git a/util/gconv/gconv_z_unit_struct_test.go b/util/gconv/gconv_z_unit_struct_test.go index a224b746a..d48050313 100644 --- a/util/gconv/gconv_z_unit_struct_test.go +++ b/util/gconv/gconv_z_unit_struct_test.go @@ -341,7 +341,7 @@ func Test_Struct_Attr_CustomType1(t *testing.T) { gtest.C(t, func(t *gtest.T) { user := new(User) err := gconv.Struct(g.Map{"id": 1, "name": "john"}, user) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(user.Id, 1) t.Assert(user.Name, "john") }) @@ -409,7 +409,7 @@ func Test_Struct_PrivateAttribute(t *testing.T) { gtest.C(t, func(t *gtest.T) { user := new(User) err := gconv.Struct(g.Map{"id": 1, "name": "john"}, user) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(user.Id, 1) t.Assert(user.name, "") }) @@ -432,7 +432,7 @@ func Test_StructEmbedded1(t *testing.T) { "age": 18, } err := gconv.Struct(params, user) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(user.Id, params["id"]) t.Assert(user.Name, params["name"]) t.Assert(user.Age, 18) @@ -460,7 +460,7 @@ func Test_StructEmbedded2(t *testing.T) { gtest.C(t, func(t *gtest.T) { user := new(User) err := gconv.Struct(params, user) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(user.Id, 1) t.Assert(user.Uid, 10) t.Assert(user.Name, "john") @@ -493,7 +493,7 @@ func Test_StructEmbedded3(t *testing.T) { } user := new(User) err := gconv.Struct(data, user) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(user.Id, 100) t.Assert(user.Uid, 101) t.Assert(user.Nickname, "T1") @@ -565,16 +565,16 @@ func Test_StructEmbedded5(t *testing.T) { user1 := new(UserWithBase1) user2 := new(UserWithBase2) err = gconv.Struct(data, user1) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(user1, &UserWithBase1{1, "john", Base{"123", "456"}}) err = gconv.Struct(data, user2) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(user2, &UserWithBase2{1, "john", Base{"", ""}}) var user3 *UserWithBase1 err = gconv.Struct(user1, &user3) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(user3, user1) }) } @@ -670,7 +670,7 @@ func Test_Struct_Create(t *testing.T) { "Name": "john", } err := gconv.Struct(params, &user) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(user.Uid, 1) t.Assert(user.Name, "john") }) @@ -703,7 +703,7 @@ func Test_Struct_Interface(t *testing.T) { "Name": nil, } err := gconv.Struct(params, &user) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(user.Uid, 1) t.Assert(user.Name, nil) }) @@ -732,7 +732,7 @@ func Test_Struct_NilAttribute(t *testing.T) { "txt": "hello", "items": nil, }, m) - t.Assert(err, nil) + t.AssertNil(err) t.AssertNE(m.Me, nil) t.Assert(m.Me["day"], "20009") t.Assert(m.Items, nil) @@ -875,11 +875,11 @@ func Test_Struct_Complex(t *testing.T) { }` m := make(g.Map) err := json.UnmarshalUseNumber([]byte(data), &m) - t.Assert(err, nil) + t.AssertNil(err) model := new(XinYanModel) err = gconv.Struct(m, model) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(model.ErrorCode, nil) t.Assert(model.ErrorMsg, nil) t.Assert(model.Success, true) @@ -934,7 +934,7 @@ func Test_Struct_Embedded(t *testing.T) { } v2 := g.Map{} err := gconv.Struct(v2, &v1) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(v1.Test(), "john") }) // Implemented interface attribute. @@ -946,7 +946,7 @@ func Test_Struct_Embedded(t *testing.T) { "name": "test", } err := gconv.Struct(v2, &v1) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(v1.Test(), "test") }) // No implemented interface attribute. @@ -956,7 +956,7 @@ func Test_Struct_Embedded(t *testing.T) { "name": "test", } err := gconv.Struct(v2, &v1) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(v1.TestInterface, nil) }) } @@ -969,7 +969,7 @@ func Test_Struct_Slice(t *testing.T) { user := new(User) array := g.Slice{1, 2, 3} err := gconv.Struct(g.Map{"scores": array}, user) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(user.Scores, array) }) gtest.C(t, func(t *gtest.T) { @@ -979,7 +979,7 @@ func Test_Struct_Slice(t *testing.T) { user := new(User) array := g.Slice{1, 2, 3} err := gconv.Struct(g.Map{"scores": array}, user) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(user.Scores, array) }) gtest.C(t, func(t *gtest.T) { @@ -989,7 +989,7 @@ func Test_Struct_Slice(t *testing.T) { user := new(User) array := g.Slice{1, 2, 3} err := gconv.Struct(g.Map{"scores": array}, user) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(user.Scores, array) }) gtest.C(t, func(t *gtest.T) { @@ -999,7 +999,7 @@ func Test_Struct_Slice(t *testing.T) { user := new(User) array := g.Slice{1, 2, 3} err := gconv.Struct(g.Map{"scores": array}, user) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(user.Scores, array) }) gtest.C(t, func(t *gtest.T) { @@ -1009,7 +1009,7 @@ func Test_Struct_Slice(t *testing.T) { user := new(User) array := g.Slice{1, 2, 3} err := gconv.Struct(g.Map{"scores": array}, user) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(user.Scores, array) }) gtest.C(t, func(t *gtest.T) { @@ -1019,7 +1019,7 @@ func Test_Struct_Slice(t *testing.T) { user := new(User) array := g.Slice{1, 2, 3} err := gconv.Struct(g.Map{"scores": array}, user) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(user.Scores, array) }) gtest.C(t, func(t *gtest.T) { @@ -1029,7 +1029,7 @@ func Test_Struct_Slice(t *testing.T) { user := new(User) array := g.Slice{1, 2, 3} err := gconv.Struct(g.Map{"scores": array}, user) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(user.Scores, array) }) gtest.C(t, func(t *gtest.T) { @@ -1039,7 +1039,7 @@ func Test_Struct_Slice(t *testing.T) { user := new(User) array := g.Slice{1, 2, 3} err := gconv.Struct(g.Map{"scores": array}, user) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(user.Scores, array) }) } @@ -1079,7 +1079,7 @@ func Test_Struct_WithJson(t *testing.T) { b, _ := json.Marshal(b1) b2 := &B{} err := gconv.Struct(b, b2) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(b2, b1) }) } @@ -1103,7 +1103,7 @@ func Test_Struct_AttrStructHasTheSameTag(t *testing.T) { } order := new(Order) err := gconv.Struct(data, order) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(order.Id, data["id"]) t.Assert(order.UpdatedAt, data["updated_at"]) t.Assert(order.Product.Id, 0) @@ -1127,7 +1127,7 @@ func Test_Struct_DirectReflectSet(t *testing.T) { b *A ) err := gconv.Struct(a, &b) - t.Assert(err, nil) + t.AssertNil(err) t.AssertEQ(a, b) }) gtest.C(t, func(t *gtest.T) { @@ -1139,7 +1139,7 @@ func Test_Struct_DirectReflectSet(t *testing.T) { b A ) err := gconv.Struct(a, &b) - t.Assert(err, nil) + t.AssertNil(err) t.AssertEQ(a, b) }) } @@ -1161,7 +1161,7 @@ func Test_Struct_NilEmbeddedStructAttribute(t *testing.T) { "id": 1, "name": nil, }, &b) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(b.Id, 1) t.Assert(b.Name, "") }) @@ -1176,7 +1176,7 @@ func Test_Struct_JsonParam(t *testing.T) { gtest.C(t, func(t *gtest.T) { var a = A{} err := gconv.Struct([]byte(`{"id":1,"name":"john"}`), &a) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(a.Id, 1) t.Assert(a.Name, "john") }) @@ -1184,7 +1184,7 @@ func Test_Struct_JsonParam(t *testing.T) { gtest.C(t, func(t *gtest.T) { var a = &A{} err := gconv.Struct([]byte(`{"id":1,"name":"john"}`), a) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(a.Id, 1) t.Assert(a.Name, "john") }) @@ -1192,7 +1192,7 @@ func Test_Struct_JsonParam(t *testing.T) { gtest.C(t, func(t *gtest.T) { var a *A err := gconv.Struct([]byte(`{"id":1,"name":"john"}`), &a) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(a.Id, 1) t.Assert(a.Name, "john") }) @@ -1214,7 +1214,7 @@ func Test_Struct_GVarAttribute(t *testing.T) { } ) err := gconv.Struct(data, &a) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(a.Id, data["id"]) t.Assert(a.Name, data["name"]) t.Assert(a.Status, data["status"]) diff --git a/util/gconv/gconv_z_unit_structs_test.go b/util/gconv/gconv_z_unit_structs_test.go index f834fbb6b..673379b07 100644 --- a/util/gconv/gconv_z_unit_structs_test.go +++ b/util/gconv/gconv_z_unit_structs_test.go @@ -32,7 +32,7 @@ func Test_Structs_WithTag(t *testing.T) { }, } err := gconv.Structs(params, &users) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(len(users), 2) t.Assert(users[0].Uid, 1) t.Assert(users[0].NickName, "name1") @@ -52,7 +52,7 @@ func Test_Structs_WithTag(t *testing.T) { }, } err := gconv.Structs(params, &users) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(len(users), 2) t.Assert(users[0].Uid, 1) t.Assert(users[0].NickName, "name1") @@ -79,7 +79,7 @@ func Test_Structs_WithoutTag(t *testing.T) { }, } err := gconv.Structs(params, &users) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(len(users), 2) t.Assert(users[0].Uid, 1) t.Assert(users[0].NickName, "name1") @@ -99,7 +99,7 @@ func Test_Structs_WithoutTag(t *testing.T) { }, } err := gconv.Structs(params, &users) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(len(users), 2) t.Assert(users[0].Uid, 1) t.Assert(users[0].NickName, "name1") @@ -166,7 +166,7 @@ func Test_Structs_DirectReflectSet(t *testing.T) { b []*A ) err := gconv.Structs(a, &b) - t.Assert(err, nil) + t.AssertNil(err) t.AssertEQ(a, b) }) gtest.C(t, func(t *gtest.T) { @@ -178,7 +178,7 @@ func Test_Structs_DirectReflectSet(t *testing.T) { b []A ) err := gconv.Structs(a, &b) - t.Assert(err, nil) + t.AssertNil(err) t.AssertEQ(a, b) }) } @@ -199,7 +199,7 @@ func Test_Structs_IntSliceAttribute(t *testing.T) { g.Map{"id": nil, "name": "john"}, g.Map{"id": nil, "name": "smith"}, }, &array) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(len(array), 2) t.Assert(array[0].Name, "john") t.Assert(array[1].Name, "smith") diff --git a/util/gvalid/gvalid_z_unit_feature_checkmap_test.go b/util/gvalid/gvalid_z_unit_feature_checkmap_test.go index 9cdb0d4ba..f3fba9a7b 100755 --- a/util/gvalid/gvalid_z_unit_feature_checkmap_test.go +++ b/util/gvalid/gvalid_z_unit_feature_checkmap_test.go @@ -40,7 +40,7 @@ func Test_CheckMap2(t *testing.T) { var params interface{} gtest.C(t, func(t *gtest.T) { if err := g.Validator().Data(params).Run(context.TODO()); err == nil { - t.Assert(err, nil) + t.AssertNil(err) } }) diff --git a/util/gvalid/gvalid_z_unit_feature_checkstruct_test.go b/util/gvalid/gvalid_z_unit_feature_checkstruct_test.go index 237938d99..7e182d84c 100755 --- a/util/gvalid/gvalid_z_unit_feature_checkstruct_test.go +++ b/util/gvalid/gvalid_z_unit_feature_checkstruct_test.go @@ -35,7 +35,7 @@ func Test_CheckStruct(t *testing.T) { } obj := &Object{"john", 16} err := g.Validator().Data(obj).Rules(rules).Messages(msgs).Run(context.TODO()) - t.Assert(err, nil) + t.AssertNil(err) }) gtest.C(t, func(t *gtest.T) { @@ -133,7 +133,7 @@ func Test_CheckStruct(t *testing.T) { } var login LoginRequest err := g.Validator().Data(login).Run(context.TODO()) - t.Assert(err, nil) + t.AssertNil(err) }) gtest.C(t, func(t *gtest.T) { @@ -249,7 +249,7 @@ func Test_CheckStruct_EmbeddedObject_Attribute(t *testing.T) { obj.Name = "john" obj.Time = gtime.Now() err := g.Validator().Data(obj).Rules(rules).Messages(ruleMsg).Run(context.TODO()) - t.Assert(err, nil) + t.AssertNil(err) }) gtest.C(t, func(t *gtest.T) { type Base struct { @@ -273,7 +273,7 @@ func Test_CheckStruct_EmbeddedObject_Attribute(t *testing.T) { obj.Type = 1 obj.Name = "john" err := g.Validator().Data(obj).Rules(rules).Messages(ruleMsg).Run(context.TODO()) - t.Assert(err, nil) + t.AssertNil(err) }) } @@ -341,7 +341,7 @@ func Test_CheckStruct_Optional(t *testing.T) { Size: 10, } err := g.Validator().Data(obj).Run(context.TODO()) - t.Assert(err, nil) + t.AssertNil(err) }) gtest.C(t, func(t *gtest.T) { type Params struct { @@ -354,7 +354,7 @@ func Test_CheckStruct_Optional(t *testing.T) { Size: 10, } err := g.Validator().Data(obj).Run(context.TODO()) - t.Assert(err, nil) + t.AssertNil(err) }) gtest.C(t, func(t *gtest.T) { type Params struct { @@ -383,7 +383,7 @@ func Test_CheckStruct_NoTag(t *testing.T) { Size: 10, } err := g.Validator().Data(obj).Run(context.TODO()) - t.Assert(err, nil) + t.AssertNil(err) }) } diff --git a/util/gvalid/gvalid_z_unit_feature_custom_rule_test.go b/util/gvalid/gvalid_z_unit_feature_custom_rule_test.go index 8aaf05eee..82cf83125 100644 --- a/util/gvalid/gvalid_z_unit_feature_custom_rule_test.go +++ b/util/gvalid/gvalid_z_unit_feature_custom_rule_test.go @@ -39,7 +39,7 @@ func Test_CustomRule1(t *testing.T) { err := g.Validator().Data("123456").Rules(rule).Messages("custom message").Run(ctx) t.Assert(err.String(), "custom message") err = g.Validator().Data("123456").Assoc(g.Map{"data": "123456"}).Rules(rule).Messages("custom message").Run(ctx) - t.Assert(err, nil) + t.AssertNil(err) }) // Error with struct validation. gtest.C(t, func(t *gtest.T) { @@ -65,7 +65,7 @@ func Test_CustomRule1(t *testing.T) { Data: "123456", } err := g.Validator().Data(st).Run(ctx) - t.Assert(err, nil) + t.AssertNil(err) }) } @@ -108,7 +108,7 @@ func Test_CustomRule2(t *testing.T) { Data: "123456", } err := g.Validator().Data(st).Run(ctx) - t.Assert(err, nil) + t.AssertNil(err) }) } @@ -139,7 +139,7 @@ func Test_CustomRule_AllowEmpty(t *testing.T) { Data: "123456", } err := g.Validator().Data(st).Run(ctx) - t.Assert(err, nil) + t.AssertNil(err) }) // No error with struct validation. gtest.C(t, func(t *gtest.T) { diff --git a/util/gvalid/gvalid_z_unit_feature_rule_test.go b/util/gvalid/gvalid_z_unit_feature_rule_test.go index f249ed73b..5229ef9b4 100755 --- a/util/gvalid/gvalid_z_unit_feature_rule_test.go +++ b/util/gvalid/gvalid_z_unit_feature_rule_test.go @@ -670,7 +670,7 @@ func Test_Domain(t *testing.T) { err = g.Validator().Data(k).Rules("domain").Run(ctx) if v { // fmt.Println(k) - t.Assert(err, nil) + t.AssertNil(err) } else { // fmt.Println(k) t.AssertNE(err, nil)