Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
B
beego
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
go
beego
Commits
8917fe44
Commit
8917fe44
authored
Jun 28, 2016
by
Joshua Santos
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add test functions
parent
21c78216
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
5 deletions
+12
-5
templatefunc_test.go
templatefunc_test.go
+12
-5
No files found.
templatefunc_test.go
View file @
8917fe44
...
...
@@ -219,35 +219,42 @@ func TestParseFormTag(t *testing.T) {
OnlyLabel
int
`form:",,年龄:"`
OnlyName
int
`form:"name" id:"name" class:"form-name"`
Ignored
int
`form:"-"`
Required
int
`form:"name" meta:"true"`
}
objT
:=
reflect
.
TypeOf
(
&
user
{})
.
Elem
()
label
,
name
,
fType
,
id
,
class
,
ignored
:=
parseFormTag
(
objT
.
Field
(
0
))
label
,
name
,
fType
,
id
,
class
,
ignored
,
required
:=
parseFormTag
(
objT
.
Field
(
0
))
if
!
(
name
==
"name"
&&
label
==
"年龄:"
&&
fType
==
"text"
&&
ignored
==
false
)
{
t
.
Errorf
(
"Form Tag with name, label and type was not correctly parsed."
)
}
label
,
name
,
fType
,
id
,
class
,
ignored
=
parseFormTag
(
objT
.
Field
(
1
))
label
,
name
,
fType
,
id
,
class
,
ignored
,
required
=
parseFormTag
(
objT
.
Field
(
1
))
if
!
(
name
==
"NoName"
&&
label
==
"年龄:"
&&
fType
==
"hidden"
&&
ignored
==
false
)
{
t
.
Errorf
(
"Form Tag with label and type but without name was not correctly parsed."
)
}
label
,
name
,
fType
,
id
,
class
,
ignored
=
parseFormTag
(
objT
.
Field
(
2
))
label
,
name
,
fType
,
id
,
class
,
ignored
,
required
=
parseFormTag
(
objT
.
Field
(
2
))
if
!
(
name
==
"OnlyLabel"
&&
label
==
"年龄:"
&&
fType
==
"text"
&&
ignored
==
false
)
{
t
.
Errorf
(
"Form Tag containing only label was not correctly parsed."
)
}
label
,
name
,
fType
,
id
,
class
,
ignored
=
parseFormTag
(
objT
.
Field
(
3
))
label
,
name
,
fType
,
id
,
class
,
ignored
,
required
=
parseFormTag
(
objT
.
Field
(
3
))
if
!
(
name
==
"name"
&&
label
==
"OnlyName: "
&&
fType
==
"text"
&&
ignored
==
false
&&
id
==
"name"
&&
class
==
"form-name"
)
{
t
.
Errorf
(
"Form Tag containing only name was not correctly parsed."
)
}
label
,
name
,
fType
,
id
,
class
,
ignored
=
parseFormTag
(
objT
.
Field
(
4
))
label
,
name
,
fType
,
id
,
class
,
ignored
,
required
=
parseFormTag
(
objT
.
Field
(
4
))
if
ignored
==
false
{
t
.
Errorf
(
"Form Tag that should be ignored was not correctly parsed."
)
}
label
,
name
,
fType
,
id
,
class
,
ignored
,
required
=
parseFormTag
(
objT
.
Field
(
5
))
if
!
(
name
==
"name"
&&
required
==
true
)
{
t
.
Errorf
(
"Form Tag containing only name and required was not correctly parsed."
)
}
}
func
TestMapGet
(
t
*
testing
.
T
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment