Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
二次元的罪恶王冠
beego
提交
60afcd06
B
beego
项目概览
二次元的罪恶王冠
/
beego
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
B
beego
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
60afcd06
编写于
7月 26, 2013
作者:
M
miraclesu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add utils test
上级
b99a09d7
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
158 addition
and
0 deletion
+158
-0
utils_test.go
utils_test.go
+158
-0
未找到文件。
utils_test.go
浏览文件 @
60afcd06
package
beego
package
beego
import
(
import
(
"html/template"
"net/url"
"net/url"
"testing"
"testing"
"time"
)
)
func
TestWebTime
(
t
*
testing
.
T
)
{
ts
:=
"Fri, 26 Jul 2013 12:27:42 CST"
tt
,
_
:=
time
.
Parse
(
time
.
RFC1123
,
ts
)
if
ts
!=
webTime
(
tt
)
{
t
.
Error
(
"should be equal"
)
}
if
"Fri, 26 Jul 2013 04:27:42 GMT"
!=
webTime
(
tt
.
UTC
())
{
t
.
Error
(
"should be equal"
)
}
}
func
TestMarkDown
(
t
*
testing
.
T
)
{
raw
:=
`## beego
[![Build Status](https://drone.io/github.com/astaxie/beego/status.png)](https://drone.io/github.com/astaxie/beego/latest)
beego is a Go Framework which is inspired from tornado and sinatra.
It is a simply & powerful web framework.
## Features
* RESTFul support
## Documentation
[English](https://github.com/astaxie/beego/tree/master/docs/en)
## LICENSE
beego is licensed under the Apache Licence, Version 2.0
(http://www.apache.org/licenses/LICENSE-2.0.html).
## Use case
- Displaying API documentation: [gowalker](https://github.com/Unknwon/gowalker)
`
output
:=
`<h2>beego</h2>
<p><a href="https://drone.io/github.com/astaxie/beego/latest">![Build Status](https://drone.io/github.com/astaxie/beego/status.png)</a></p>
<p>beego is a Go Framework which is inspired from tornado and sinatra.</p>
<p>It is a simply & powerful web framework.</p>
<h2>Features</h2>
<ul>
<li>RESTFul support</li>
</ul>
<h2>Documentation</h2>
<p><a href="https://github.com/astaxie/beego/tree/master/docs/en">English</a></p>
<h2>LICENSE</h2>
<p>beego is licensed under the Apache Licence, Version 2.0
(http://www.apache.org/licenses/LICENSE-2.0.html).</p>
<h2>Use case</h2>
<ul>
<li>Displaying API documentation: <a href="https://github.com/Unknwon/gowalker">gowalker</a></li>
</ul>
`
if
MarkDown
(
raw
)
!=
template
.
HTML
(
output
)
{
t
.
Error
(
"should be equal"
)
}
}
func
TestSubstr
(
t
*
testing
.
T
)
{
s
:=
`012345`
if
Substr
(
s
,
0
,
2
)
!=
"01"
{
t
.
Error
(
"should be equal"
)
}
if
Substr
(
s
,
0
,
100
)
!=
"012345"
{
t
.
Error
(
"should be equal"
)
}
}
func
TestHtml2str
(
t
*
testing
.
T
)
{
h
:=
`<HTML><style></style><script>x<x</script></HTML><123> 123\n
\n`
if
Html2str
(
h
)
!=
"123
\\
n
\n\\
n"
{
t
.
Error
(
"should be equal"
)
}
}
func
TestDateFormat
(
t
*
testing
.
T
)
{
ts
:=
"Mon, 01 Jul 2013 13:27:42 CST"
tt
,
_
:=
time
.
Parse
(
time
.
RFC1123
,
ts
)
if
DateFormat
(
tt
,
"2006-01-02 15:04:05"
)
!=
"2013-07-01 13:27:42"
{
t
.
Error
(
"should be equal"
)
}
}
func
TestDate
(
t
*
testing
.
T
)
{
ts
:=
"Mon, 01 Jul 2013 13:27:42 CST"
tt
,
_
:=
time
.
Parse
(
time
.
RFC1123
,
ts
)
if
Date
(
tt
,
"Y-m-d H:i:s"
)
!=
"2013-07-01 13:27:42"
{
t
.
Error
(
"should be equal"
)
}
if
Date
(
tt
,
"y-n-j h:i:s A"
)
!=
"13-7-1 01:27:42 PM"
{
t
.
Error
(
"should be equal"
)
}
if
Date
(
tt
,
"D, d M Y g:i:s a"
)
!=
"Mon, 01 Jul 2013 1:27:42 pm"
{
t
.
Error
(
"should be equal"
)
}
if
Date
(
tt
,
"l, d F Y G:i:s"
)
!=
"Monday, 01 July 2013 13:27:42"
{
t
.
Error
(
"should be equal"
)
}
}
func
TestCompare
(
t
*
testing
.
T
)
{
if
!
Compare
(
"abc"
,
"abc"
)
{
t
.
Error
(
"should be equal"
)
}
if
Compare
(
"abc"
,
"aBc"
)
{
t
.
Error
(
"should be not equal"
)
}
if
!
Compare
(
"1"
,
1
)
{
t
.
Error
(
"should be equal"
)
}
}
func
TestHtmlquote
(
t
*
testing
.
T
)
{
h
:=
`<' ”“&">`
s
:=
`<' ”“&">`
if
Htmlquote
(
s
)
!=
h
{
t
.
Error
(
"should be equal"
)
}
}
func
TestHtmlunquote
(
t
*
testing
.
T
)
{
h
:=
`<' ”“&">`
s
:=
`<' ”“&">`
if
Htmlunquote
(
h
)
!=
s
{
t
.
Error
(
"should be equal"
)
}
}
func
TestInSlice
(
t
*
testing
.
T
)
{
sl
:=
[]
string
{
"A"
,
"b"
}
if
!
inSlice
(
"A"
,
sl
)
{
t
.
Error
(
"should be true"
)
}
if
inSlice
(
"B"
,
sl
)
{
t
.
Error
(
"should be false"
)
}
}
func
TestParseForm
(
t
*
testing
.
T
)
{
func
TestParseForm
(
t
*
testing
.
T
)
{
type
user
struct
{
type
user
struct
{
Id
int
Id
int
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录