Skip to content

Commit 30b111c

Browse files
author
yonbiaoxiao
committed
improve the test coverage for context.go
1 parent 622f5e3 commit 30b111c

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

context_test.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,15 @@ func BenchmarkAllocXML(b *testing.B) {
7272
}
7373
}
7474

75+
func BenchmarkRealIPForHeaderXForwardFor(b *testing.B) {
76+
c := context{request: &http.Request{
77+
Header: http.Header{HeaderXForwardedFor: []string{"127.0.0.1, 127.0.1.1, "}},
78+
}}
79+
for i := 0; i < b.N; i++ {
80+
c.RealIP()
81+
}
82+
}
83+
7584
func (t *Template) Render(w io.Writer, name string, data interface{}, c Context) error {
7685
return t.templates.ExecuteTemplate(w, name, data)
7786
}
@@ -871,12 +880,3 @@ func TestContext_RealIP(t *testing.T) {
871880
testify.Equal(t, tt.s, tt.c.RealIP())
872881
}
873882
}
874-
875-
func BenchmarkRealIPForHeaderXForwardFor(b *testing.B) {
876-
c := context{request: &http.Request{
877-
Header: http.Header{HeaderXForwardedFor: []string{"127.0.0.1, 127.0.1.1, "}},
878-
}}
879-
for i := 0; i < b.N; i++ {
880-
c.RealIP()
881-
}
882-
}

0 commit comments

Comments
 (0)