TEST(AmfObjectTraitsTest, Equality) { AmfObjectTraits obj1("foo", false, true); AmfObjectTraits obj2("foo", false, false); AmfObjectTraits obj3("foo", true, false); AmfObjectTraits obj4("foo", false, false); AmfObjectTraits obj5("bar", false, true); AmfObjectTraits obj1e("foo", false, true); EXPECT_NE(obj1, obj2); EXPECT_NE(obj1, obj3); EXPECT_NE(obj1, obj4); EXPECT_NE(obj1, obj5); EXPECT_EQ(obj1, obj1e); // Verify attributes are also compared. obj1.addAttribute("attr"); EXPECT_NE(obj1, obj1e); obj1e.addAttribute("attr"); EXPECT_EQ(obj1, obj1e); // Verify attributes can't be duplicated. obj1.addAttribute("attr"); EXPECT_EQ(obj1, obj1e); }
TEST(DynamicObject, Constructors) { kora::dynamic_t::object_t obj1; EXPECT_TRUE(obj1.empty()); obj1["key"] = 5; kora::dynamic_t::object_t obj2(obj1); EXPECT_EQ(1, obj2.count("key")); EXPECT_EQ(5, obj2.at("key")); kora::dynamic_t::object_t obj3(std::move(obj2)); EXPECT_EQ(1, obj3.count("key")); EXPECT_EQ(5, obj3.at("key")); std::map<std::string, kora::dynamic_t> map; map["key2"] = 6; kora::dynamic_t::object_t obj4(map); EXPECT_EQ(1, obj4.count("key2")); EXPECT_EQ(6, obj4.at("key2")); kora::dynamic_t::object_t obj5(std::move(map)); EXPECT_EQ(1, obj5.count("key2")); EXPECT_EQ(6, obj5.at("key2")); kora::dynamic_t::object_t obj6(obj5.begin(), obj5.end()); EXPECT_EQ(1, obj6.size()); EXPECT_EQ(1, obj6.count("key2")); EXPECT_EQ(6, obj6.at("key2")); }
int main() { plusminus obj1(4, 7) ; std::cout << "Printing obj1" << std::endl ; obj1.print(); // -obj1 ; // std::cout << "Printing obj1" << std::endl ; // std::cout << obj1.getter1() << " " << obj1.getter2() << " " << std::endl ; // obj1.print(); plusminus obj2(5, 1) ; std::cout << "Printing obj2" << std::endl ; obj2.print(); std::cout << "Printing obj1 + obj2" << std::endl ; (obj1 + obj2).print(); std::cout << "Printing obj1" << std::endl ; (obj1).print(); // std::cout << "Printing obj3 - obj4" << std::endl ; // plusminus obj3(5 , 10); // plusminus obj4(10 , 10); // (obj3 - obj4).print() ; plusminus obj5(44, 23); plusminus obj6(11, 22); plusminus obj7(0, 0); obj7 = (obj5 - obj6) ; std::cout << "Printing obj7" << std::endl ; obj7.print(); plusminus obj8 = -obj6 ; std::cout << "Printing obj8" << std::endl ; obj8.print(); // std::cout << "Printing -obj1" << std::endl ; // std::cout << -obj1.getter1() << " " << -obj1.getter2() << std::endl ; // (-obj1).print(); // std::cout << std::endl ; // plusminus obj2 ; // obj2 = -obj1 ; // plusminus obj3 = -obj1 ; // std::cout << "Printing obj1" << std::endl ; // std::cout << obj1.getter1() << " " << obj1.getter2() << std::endl ; // std::cout << std::endl ; // std::cout << "Printing obj3" << std::endl ; // std::cout << obj3.getter1() << " " << obj.getter2() << std::endl ; // std::cout << std::endl ; }
void tst_QSqlError::construction() { QSqlError obj1("drivertext", "databasetext", QSqlError::UnknownError, 123); QCOMPARE(obj1.driverText(), QString("drivertext")); QCOMPARE(obj1.databaseText(), QString("databasetext")); QCOMPARE(obj1.type(), QSqlError::UnknownError); QCOMPARE(obj1.number(), 123); QCOMPARE(obj1.nativeErrorCode(), QStringLiteral("123")); QVERIFY(obj1.isValid()); QSqlError obj2(obj1); QCOMPARE(obj2.driverText(), obj1.driverText()); QCOMPARE(obj2.databaseText(), obj1.databaseText()); QCOMPARE(obj2.type(), obj1.type()); QCOMPARE(obj2.number(), obj1.number()); QCOMPARE(obj2.nativeErrorCode(), obj1.nativeErrorCode()); QVERIFY(obj2.isValid()); QSqlError obj3 = obj2; QCOMPARE(obj3.driverText(), obj2.driverText()); QCOMPARE(obj3.databaseText(), obj2.databaseText()); QCOMPARE(obj3.type(), obj2.type()); QCOMPARE(obj3.number(), obj2.number()); QCOMPARE(obj3.nativeErrorCode(), obj2.nativeErrorCode()); QVERIFY(obj3.isValid()); QSqlError obj4; QVERIFY(!obj4.isValid()); QCOMPARE(obj4.driverText(), QString()); QCOMPARE(obj4.databaseText(), QString()); QCOMPARE(obj4.type(), QSqlError::NoError); QCOMPARE(obj4.number(), -1); QCOMPARE(obj4.nativeErrorCode(), QString()); QSqlError obj5(QStringLiteral("drivertext"), QStringLiteral("databasetext"), QSqlError::UnknownError, QStringLiteral("123")); QCOMPARE(obj5.driverText(), QString("drivertext")); QCOMPARE(obj5.databaseText(), QString("databasetext")); QCOMPARE(obj5.type(), QSqlError::UnknownError); QCOMPARE(obj5.number(), 123); QCOMPARE(obj5.nativeErrorCode(), QStringLiteral("123")); QVERIFY(obj5.isValid()); QSqlError obj6(QStringLiteral("drivertext"), QStringLiteral("databasetext"), QSqlError::UnknownError, QStringLiteral("Err123")); QCOMPARE(obj6.driverText(), QString("drivertext")); QCOMPARE(obj6.databaseText(), QString("databasetext")); QCOMPARE(obj6.type(), QSqlError::UnknownError); QCOMPARE(obj6.number(), 0); QCOMPARE(obj6.nativeErrorCode(), QStringLiteral("Err123")); QVERIFY(obj6.isValid()); // Default constructed object as constructed before Qt 5.3 QSqlError obj7(QString(), QString(), QSqlError::NoError, -1); QVERIFY(!obj7.isValid()); QCOMPARE(obj7.driverText(), QString()); QCOMPARE(obj7.databaseText(), QString()); QCOMPARE(obj7.type(), QSqlError::NoError); QCOMPARE(obj7.number(), -1); QCOMPARE(obj7.nativeErrorCode(), QString()); }
int main() { srand(static_cast<unsigned int>(time(NULL))); std::vector<int> set1(10,0); set1[9] = 31; set1[8] = 30; set1[7] = 24; set1[6] = 15; set1[5] = 13; set1[4] = 10; set1[3] = 9; set1[2] = 5; set1[1] = 4; set1[0] = 2; MySet obj1(set1); std::cout << "Set 1: " << obj1 << std::endl << std::endl; //Insert for (int i = 0; i < 20; i++) { int randNum = rand() % 1000; std::cout << "Lets insert " << randNum << " into the set"; obj1.insert(randNum); std::cout << obj1 << std::endl << std::endl; } //Remove for (int i = 0; i < 20; i++) { int randNum = rand() % 20; std::cout << "Lets remove " << randNum << " into the set"; obj1.remove(randNum); std::cout << obj1 << std::endl << std::endl; } std::cout << std::endl << std::endl; //New Set std::vector<int> set2(30,0); for (int i = 0; i < set2.size(); i++) { set2[i] = rand() % 1000; } MySet obj2(set2); std::cout << "Set 2: " << obj2 << std::endl; std::vector<int> set3(30, 0); for (int i = 0; i < set3.size(); i++) { set3[i] = rand() % 1000; } MySet obj3(set3); std::cout << "Set 3: " << obj3 << std::endl; //Add std::cout << "Set 3 + Set 2: "; std::cout << (obj3 + obj2) << std::endl << std::endl; //Sub std::cout << "Set 3 - Set 2: "; std::cout << (obj3 - obj2) << std::endl << std::endl; //Intersect std::cout << "Set 3 & Set 2: "; std::cout << (obj3 & obj2) << std::endl << std::endl; //Equals std::cout << "Set 3 == Set 2: "; std::cout << (obj3 == obj2 ? "Yes" : "No") << std::endl << std::endl << std::endl; //New Set std::vector<int> set4(30, 0); for (int i = 0; i < set4.size(); i++) { set4[i] = rand() % 1000; } MySet obj4(set4); std::cout << "Set 4: " << obj4 << std::endl; MySet obj5(set4); std::cout << "Set 5: " << obj5 << std::endl; //Equals std::cout << "Set 4 == Set 5: "; std::cout << (obj4 == obj5 ? "Yes" : "No") << std::endl; return 0; }