Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
YottaChain
YTBP
提交
c64b137c
Y
YTBP
项目概览
YottaChain
/
YTBP
通知
0
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
Y
YTBP
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
c64b137c
编写于
5月 02, 2018
作者:
A
arhag
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'slim' into slim-resource-limits-fix2
上级
f7a7030e
e96253b8
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
150 addition
and
20 deletion
+150
-20
libraries/testing/include/eosio/testing/tester.hpp
libraries/testing/include/eosio/testing/tester.hpp
+74
-20
libraries/testing/tester.cpp
libraries/testing/tester.cpp
+76
-0
未找到文件。
libraries/testing/include/eosio/testing/tester.hpp
浏览文件 @
c64b137c
...
...
@@ -5,7 +5,6 @@
#include <eosio/chain/account_object.hpp>
#include <eosio/chain/abi_serializer.hpp>
#include <fc/io/json.hpp>
#include <boost/algorithm/string/predicate.hpp>
#include <boost/test/unit_test.hpp>
#include <iosfwd>
...
...
@@ -181,15 +180,15 @@ namespace eosio { namespace testing {
static
action_result
error
(
const
string
&
msg
)
{
return
msg
;
}
auto
get_resolver
()
{
return
[
this
](
const
account_name
&
name
)
->
optional
<
abi_serializer
>
{
return
[
this
](
const
account_name
&
name
)
->
optional
<
abi_serializer
>
{
try
{
const
auto
&
accnt
=
control
->
db
().
get
<
account_object
,
by_name
>
(
name
);
const
auto
&
accnt
=
control
->
db
().
get
<
account_object
,
by_name
>
(
name
);
abi_def
abi
;
if
(
abi_serializer
::
to_abi
(
accnt
.
abi
,
abi
))
{
return
abi_serializer
(
abi
);
if
(
abi_serializer
::
to_abi
(
accnt
.
abi
,
abi
))
{
return
abi_serializer
(
abi
);
}
return
optional
<
abi_serializer
>
();
}
FC_RETHROW_EXCEPTIONS
(
error
,
"Failed to find or parse ABI for ${name}"
,
(
"name"
,
name
))
}
FC_RETHROW_EXCEPTIONS
(
error
,
"Failed to find or parse ABI for ${name}"
,
(
"name"
,
name
))
};
}
...
...
@@ -328,14 +327,10 @@ namespace eosio { namespace testing {
* Utility predicate to check whether an FC_ASSERT message ends with a given string
*/
struct
assert_message_ends_with
{
assert_message_ends_with
(
string
expected
)
:
expected
(
expected
)
{}
assert_message_ends_with
(
string
expected
)
:
expected
(
expected
)
{}
bool
operator
()(
const
fc
::
exception
&
ex
)
{
auto
message
=
ex
.
get_log
().
at
(
0
).
get_message
();
return
boost
::
algorithm
::
ends_with
(
message
,
expected
);
}
bool
operator
()(
const
fc
::
exception
&
ex
);
string
expected
;
};
...
...
@@ -344,17 +339,76 @@ namespace eosio { namespace testing {
* Utility predicate to check whether an FC_ASSERT message contains a given string
*/
struct
assert_message_contains
{
assert_message_contains
(
string
expected
)
:
expected
(
expected
)
{}
assert_message_contains
(
string
expected
)
:
expected
(
expected
)
{}
bool
operator
()(
const
fc
::
exception
&
ex
)
{
auto
message
=
ex
.
get_log
().
at
(
0
).
get_message
();
return
boost
::
algorithm
::
contains
(
message
,
expected
);
}
bool
operator
()(
const
fc
::
exception
&
ex
);
string
expected
;
};
/**
* Utility predicate to check whether an fc::exception message starts with a given string
*/
struct
fc_exception_message_starts_with
{
fc_exception_message_starts_with
(
const
string
&
msg
)
:
expected
(
msg
)
{}
bool
operator
()(
const
fc
::
exception
&
ex
);
string
expected
;
};
/**
* Utility predicate to check whether an fc::assert_exception message is equivalent to a given string
*/
struct
fc_assert_exception_message_is
{
fc_assert_exception_message_is
(
const
string
&
msg
)
:
expected
(
msg
)
{}
bool
operator
()(
const
fc
::
assert_exception
&
ex
);
string
expected
;
};
/**
* Utility predicate to check whether an fc::assert_exception message starts with a given string
*/
struct
fc_assert_exception_message_starts_with
{
fc_assert_exception_message_starts_with
(
const
string
&
msg
)
:
expected
(
msg
)
{}
bool
operator
()(
const
fc
::
assert_exception
&
ex
);
string
expected
;
};
/**
* Utility predicate to check whether an eosio_assert message is equivalent to a given string
*/
struct
eosio_assert_message_is
{
eosio_assert_message_is
(
const
string
&
msg
)
:
expected
(
"assertion failed: "
)
{
expected
.
append
(
msg
);
}
bool
operator
()(
const
fc
::
assert_exception
&
ex
);
string
expected
;
};
/**
* Utility predicate to check whether an eosio_assert message starts with a given string
*/
struct
eosio_assert_message_starts_with
{
eosio_assert_message_starts_with
(
const
string
&
msg
)
:
expected
(
"assertion failed: "
)
{
expected
.
append
(
msg
);
}
bool
operator
()(
const
fc
::
assert_exception
&
ex
);
string
expected
;
};
}
}
/// eosio::testing
libraries/testing/tester.cpp
浏览文件 @
c64b137c
#include <boost/test/unit_test.hpp>
#include <boost/algorithm/string/predicate.hpp>
#include <eosio/testing/tester.hpp>
#include <eosio/chain/wast_to_wasm.hpp>
#include <eosio/chain/eosio_contract.hpp>
...
...
@@ -677,6 +678,81 @@ namespace eosio { namespace testing {
return
tid
;
}
bool
assert_message_ends_with
::
operator
()(
const
fc
::
exception
&
ex
)
{
auto
message
=
ex
.
get_log
().
at
(
0
).
get_message
();
return
boost
::
algorithm
::
ends_with
(
message
,
expected
);
}
bool
assert_message_contains
::
operator
()(
const
fc
::
exception
&
ex
)
{
auto
message
=
ex
.
get_log
().
at
(
0
).
get_message
();
return
boost
::
algorithm
::
contains
(
message
,
expected
);
}
bool
fc_exception_message_starts_with
::
operator
()(
const
fc
::
exception
&
ex
)
{
auto
message
=
ex
.
get_log
().
at
(
0
).
get_message
();
bool
match
=
boost
::
algorithm
::
starts_with
(
message
,
expected
);
if
(
!
match
)
{
BOOST_TEST_MESSAGE
(
"LOG: expected: "
<<
expected
<<
", actual: "
<<
message
);
}
return
match
;
}
bool
fc_assert_exception_message_is
::
operator
()(
const
fc
::
assert_exception
&
ex
)
{
auto
message
=
ex
.
get_log
().
at
(
0
).
get_message
();
bool
match
=
false
;
auto
pos
=
message
.
find
(
": "
);
if
(
pos
!=
std
::
string
::
npos
)
{
message
=
message
.
substr
(
pos
+
2
);
match
=
(
message
==
expected
);
}
if
(
!
match
)
{
BOOST_TEST_MESSAGE
(
"LOG: expected: "
<<
expected
<<
", actual: "
<<
message
);
}
return
match
;
}
bool
fc_assert_exception_message_starts_with
::
operator
()(
const
fc
::
assert_exception
&
ex
)
{
auto
message
=
ex
.
get_log
().
at
(
0
).
get_message
();
bool
match
=
false
;
auto
pos
=
message
.
find
(
": "
);
if
(
pos
!=
std
::
string
::
npos
)
{
message
=
message
.
substr
(
pos
+
2
);
match
=
boost
::
algorithm
::
starts_with
(
message
,
expected
);
}
if
(
!
match
)
{
BOOST_TEST_MESSAGE
(
"LOG: expected: "
<<
expected
<<
", actual: "
<<
message
);
}
return
match
;
}
bool
eosio_assert_message_is
::
operator
()(
const
fc
::
assert_exception
&
ex
)
{
auto
message
=
ex
.
get_log
().
at
(
0
).
get_message
();
bool
match
=
false
;
auto
pos
=
message
.
find
(
": "
);
if
(
pos
!=
std
::
string
::
npos
)
{
message
=
message
.
substr
(
pos
+
2
);
match
=
(
message
==
expected
);
}
if
(
!
match
)
{
BOOST_TEST_MESSAGE
(
"LOG: expected: "
<<
expected
<<
", actual: "
<<
message
);
}
return
match
;
}
bool
eosio_assert_message_starts_with
::
operator
()(
const
fc
::
assert_exception
&
ex
)
{
auto
message
=
ex
.
get_log
().
at
(
0
).
get_message
();
bool
match
=
false
;
auto
pos
=
message
.
find
(
": "
);
if
(
pos
!=
std
::
string
::
npos
)
{
message
=
message
.
substr
(
pos
+
2
);
match
=
boost
::
algorithm
::
starts_with
(
message
,
expected
);
}
if
(
!
match
)
{
BOOST_TEST_MESSAGE
(
"LOG: expected: "
<<
expected
<<
", actual: "
<<
message
);
}
return
match
;
}
}
}
/// eosio::test
std
::
ostream
&
operator
<<
(
std
::
ostream
&
osm
,
const
fc
::
variant
&
v
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录