Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EXPECT_FALSE()宏有问题! #25

Closed
fanjinhua opened this issue Sep 22, 2016 · 3 comments
Closed

EXPECT_FALSE()宏有问题! #25

fanjinhua opened this issue Sep 22, 2016 · 3 comments

Comments

@fanjinhua
Copy link

fanjinhua commented Sep 22, 2016

这样传参的话:EXPECT_FALSE(lept_get_boolean(&v))
lept_get_boolean() 正常情况下返回 LEPT_FALSE(1)
而宏展开则是 (actual) == 0,
应该是 (actual) == 1 才符合测试。

@chanchancl
Copy link

chanchancl commented Sep 22, 2016

你好,我觉得你可能对lept_get_boolean()返回值有点误解,
lept_get_boolean()返回的应该是,v所代表的布尔值对应的 0或1,
而不是 LEPT_FALSE 或者 LEPT_TRUE
这可以从这个函数的返回值看出来,返回的是int,而不是 lept_type
具体我是这样实现的,这样EXPECT_FALSE没问题
int lept_get_boolean(const lept_value* v) {
/* \TODO */
assert(v->type == LEPT_TRUE || v->type == LEPT_FALSE);
return v->type == LEPT_TRUE ? 1 : 0;
}

@fanjinhua
Copy link
Author

这样啊,那我理解错了...

@j178
Copy link

j178 commented Sep 23, 2016

@chanchancl 可以直接写成 return v->type == LEPT_TRUE; 吧 😄 当然, 你这样写清晰一些.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants