From f24847576d6e246ac437a235f6b4a464218df630 Mon Sep 17 00:00:00 2001 From: hailaz <739476267@qq.com> Date: Sat, 13 Jul 2019 10:52:02 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=88=E7=A7=BB=E9=99=A4=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E7=9A=84=E4=B8=A4=E4=B8=AAgvalid=E7=9A=84test=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gvalid_unit_basic_array_slice_test.go | 64 ------------------- g/util/gvalid/gvalid_unit_basic_map_test.go | 46 ------------- 2 files changed, 110 deletions(-) delete mode 100644 g/util/gvalid/gvalid_unit_basic_array_slice_test.go delete mode 100644 g/util/gvalid/gvalid_unit_basic_map_test.go diff --git a/g/util/gvalid/gvalid_unit_basic_array_slice_test.go b/g/util/gvalid/gvalid_unit_basic_array_slice_test.go deleted file mode 100644 index 83dff7702..000000000 --- a/g/util/gvalid/gvalid_unit_basic_array_slice_test.go +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright 2017 gf Author(https://github.com/gogf/gf). All Rights Reserved. -// -// This Source Code Form is subject to the terms of the MIT License. -// If a copy of the MIT was not distributed with this file, -// You can obtain one at https://github.com/gogf/gf. - -package gvalid_test - -import ( - "testing" - - "github.com/gogf/gf/g/test/gtest" - "github.com/gogf/gf/g/util/gvalid" -) - -func Test_Array(t *testing.T) { - gtest.Case(t, func() { - arrayData := [2]int{7, 8} - msgs := map[string]string{ - "between": "not between", - "in": "not in", - } - - err := gvalid.Check(arrayData, "between:6,10|in:7,8", msgs) - gtest.Assert(err, nil) - - if e := gvalid.Check(arrayData, "between:9,10|in:7,8", msgs); e != nil { - gtest.Assert(e.String(), "not between") - } - - if e := gvalid.Check(arrayData, "between:6,10|in:7", msgs); e != nil { - gtest.Assert(e.String(), "not in") - } - - err1 := gvalid.Check(&arrayData, "between:6,10|in:7,8", msgs) - gtest.Assert(err1, nil) - - if e := gvalid.Check(&arrayData, "between:9,10|in:7,8", msgs); e != nil { - gtest.Assert(e.String(), "not between") - } - - if e := gvalid.Check(&arrayData, "between:6,10|in:7", msgs); e != nil { - gtest.Assert(e.String(), "not in") - } - }) -} - -func Test_Slice(t *testing.T) { - gtest.Case(t, func() { - sliceData := [][]string{[]string{"12345678", "12345678"}, []string{"12345678", "12345678"}} - - msgs := map[string]string{ - "length": "length err", - } - - err := gvalid.Check(sliceData, "length:3,16", msgs) - gtest.Assert(err, nil) - - if e := gvalid.Check(sliceData, "length:9,16", msgs); e != nil { - gtest.Assert(e.String(), "length err") - } - - }) -} diff --git a/g/util/gvalid/gvalid_unit_basic_map_test.go b/g/util/gvalid/gvalid_unit_basic_map_test.go deleted file mode 100644 index 6d792aa92..000000000 --- a/g/util/gvalid/gvalid_unit_basic_map_test.go +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright 2017 gf Author(https://github.com/gogf/gf). All Rights Reserved. -// -// This Source Code Form is subject to the terms of the MIT License. -// If a copy of the MIT was not distributed with this file, -// You can obtain one at https://github.com/gogf/gf. - -package gvalid_test - -import ( - "testing" - - "github.com/gogf/gf/g/test/gtest" - "github.com/gogf/gf/g/util/gvalid" -) - -func Test_Map(t *testing.T) { - type Test struct { - Id int - } - gtest.Case(t, func() { - mapData := map[string]interface{}{ - "123": map[string]int{ - "aaa": 6, - "bbb": 7, - "ccc": 8, - }, - "456": &Test{ - Id: 9, - }, - } - - err := gvalid.Check(mapData, "between:6,10|in:6,7,8,9", nil) - gtest.Assert(err, nil) - - msgs := map[string]string{ - "between": "not between", - "in": "not in", - } - if e := gvalid.Check(mapData, "between:10,10|in:6,7,8,9", msgs); e != nil { - gtest.Assert(e.String(), "not between") - } - if e := gvalid.Check(mapData, "between:6,10|in:10", msgs); e != nil { - gtest.Assert(e.String(), "not in") - } - }) -}