本文整理汇总了C++中ObjectPtr::getBoolean方法的典型用法代码示例。如果您正苦于以下问题:C++ ObjectPtr::getBoolean方法的具体用法?C++ ObjectPtr::getBoolean怎么用?C++ ObjectPtr::getBoolean使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ObjectPtr
的用法示例。
在下文中一共展示了ObjectPtr::getBoolean方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: createObject
TEST(ObjectTests, BooleanObject)
{
ObjectPtr object = createObject(false);
ASSERT_EQ(Object::BOOLEAN, object->getNativeType());
ASSERT_FALSE(object->isNil());
ASSERT_EQ(false, object->getBoolean());
ASSERT_EQ(0.f, object->getNumber());
ASSERT_STREQ("false", object->getString().c_str());
ASSERT_THROW(object->getUserdata(), ObjectConversionException);
ASSERT_STREQ("false", object->getReadableString().c_str());
object = createObject(true);
ASSERT_EQ(Object::BOOLEAN, object->getNativeType());
ASSERT_FALSE(object->isNil());
ASSERT_EQ(true, object->getBoolean());
ASSERT_EQ(1.f, object->getNumber());
ASSERT_STREQ("true", object->getString().c_str());
ASSERT_THROW(object->getUserdata(), ObjectConversionException);
ASSERT_STREQ("true", object->getReadableString().c_str());
}
示例2: malloc
TEST(ObjectTests, UserdataObject)
{
void* memory = malloc(32);
ObjectPtr object = createObject(memory);
ASSERT_EQ(Object::USERDATA, object->getNativeType());
ASSERT_FALSE(object->isNil());
ASSERT_TRUE(object->getBoolean());
ASSERT_THROW(object->getNumber(), ObjectConversionException);
// TODO: Check getString()
ASSERT_EQ(memory, object->getUserdata());
// TODO: Check getReadableString()
free(memory);
}