github.com/wangyougui/gf/v2@v2.6.5/util/gvalid/gvalid_z_unit_internal_test.go (about)

     1  // Copyright GoFrame Author(https://goframe.org). All Rights Reserved.
     2  //
     3  // This Source Code Form is subject to the terms of the MIT License.
     4  // If a copy of the MIT was not distributed with this file,
     5  // You can obtain one at https://github.com/wangyougui/gf.
     6  
     7  package gvalid
     8  
     9  import (
    10  	"testing"
    11  
    12  	"github.com/wangyougui/gf/v2/test/gtest"
    13  )
    14  
    15  func Test_parseSequenceTag(t *testing.T) {
    16  	gtest.C(t, func(t *gtest.T) {
    17  		s := "name@required|length:2,20|password3|same:password1#||密码强度不足|两次密码不一致"
    18  		field, rule, msg := ParseTagValue(s)
    19  		t.Assert(field, "name")
    20  		t.Assert(rule, "required|length:2,20|password3|same:password1")
    21  		t.Assert(msg, "||密码强度不足|两次密码不一致")
    22  	})
    23  	gtest.C(t, func(t *gtest.T) {
    24  		s := "required|length:2,20|password3|same:password1#||密码强度不足|两次密码不一致"
    25  		field, rule, msg := ParseTagValue(s)
    26  		t.Assert(field, "")
    27  		t.Assert(rule, "required|length:2,20|password3|same:password1")
    28  		t.Assert(msg, "||密码强度不足|两次密码不一致")
    29  	})
    30  	gtest.C(t, func(t *gtest.T) {
    31  		s := "required|length:2,20|password3|same:password1"
    32  		field, rule, msg := ParseTagValue(s)
    33  		t.Assert(field, "")
    34  		t.Assert(rule, "required|length:2,20|password3|same:password1")
    35  		t.Assert(msg, "")
    36  	})
    37  	gtest.C(t, func(t *gtest.T) {
    38  		s := "required"
    39  		field, rule, msg := ParseTagValue(s)
    40  		t.Assert(field, "")
    41  		t.Assert(rule, "required")
    42  		t.Assert(msg, "")
    43  	})
    44  }
    45  
    46  func Test_GetTags(t *testing.T) {
    47  	gtest.C(t, func(t *gtest.T) {
    48  		t.Assert(structTagPriority, GetTags())
    49  	})
    50  }