}
};
-TEST_F(DSPropertyTest, CreateProperty)
+TEST_F(DSPropertyTest, NewDSProperty)
{
/* DSProperty::DSProperty()*/
DSProperty *pro = new DSProperty();
ASSERT_NE(pro, nullptr) << "Failed to DSProperty()";
delete pro;
+}
+TEST_F(DSPropertyTest, SetGetProperty)
+{
/* DSProperty::DSProperty(std::__cxx11::string, const DSPropertyVariant&, DSPropertyType) */
- pro = new DSProperty("testProperty", 2020, DSPropertyType::INTEGER);
+ DSProperty *pro = new DSProperty("testProperty", 2020, DSPropertyType::INTEGER);
ASSERT_NE(pro, nullptr) << "Failed to DSProperty(key, data, type)";
ASSERT_EQ(pro->getKey(), "testProperty") << "Key value mismatch!";
ASSERT_EQ(pro->getType(), DSPropertyType::INTEGER) << "Type mistmatch!!";
try {
int data = std::get<int>(pro->getData());
ASSERT_TRUE(data == 2020) << "data value mismatch!!";
- } catch (std::bad_variant_access &e) {
+ } catch (DSPropertyException &e) {
ASSERT_TRUE(false) << e.what();
}
delete pro;
+}
+TEST_F(DSPropertyTest, NewProperty2)
+{
/* DSProperty::DSProperty(DSProperty&) */
DSProperty pro_s("testProperty2", 20.20, DSPropertyType::DOUBLE);
- pro = new DSProperty(pro_s);
+ DSProperty *pro = new DSProperty(pro_s);
ASSERT_NE(pro, nullptr) << "Failed to DSProperty(const DSProperty&)";
ASSERT_EQ(pro->getKey(), "testProperty2") << "Key value mismatch!";
ASSERT_EQ(pro->getType(), DSPropertyType::DOUBLE) << "Type mistmatch!!";
try {
double data = std::get<double>(pro->getData());
ASSERT_TRUE(data == 20.20) << "data value mismatch!!";
- } catch (std::bad_variant_access &e) {
+ } catch (DSPropertyException &e) {
ASSERT_TRUE(false) << e.what();
}
delete pro;
}
+
+TEST_F(DSPropertyTest, CopyAssign)
+{
+ /* DSProperty::DSProperty(DSProperty&) */
+ DSObject *obj = new DSObject();
+ DSProperty pro_s("testProperty3", (void *)obj, DSPropertyType::POINTER);
+ DSProperty pro = pro_s;
+ ASSERT_EQ(pro.getKey(), "testProperty3") << "Key value mismatch!";
+ ASSERT_EQ(pro.getType(), DSPropertyType::POINTER) << "Type mistmatch!!";
+ try {
+ DSObject *data = (DSObject *)std::get<void *>(pro.getData());
+ ASSERT_TRUE(data == obj) << "data value mismatch!!";
+ } catch (DSPropertyException &e) {
+ ASSERT_TRUE(false) << e.what();
+ }
+
+ if (obj) delete obj;
+}