void PropertyTest::testCanCreatePropertiesOfDifferentTypes() { string name1("prop1"); string name2("prop2"); string name3("prop3"); string name4("prop4"); string name5("prop5"); bool ok = true; string someValue("name"); int integer = 34; double d = 45.24; DateTime now; Property<string, bool> prop1(name1, ok); CPPUNIT_ASSERT_EQUAL(ok, prop1()); CPPUNIT_ASSERT_EQUAL(ok, prop1.getValue()); CPPUNIT_ASSERT_EQUAL(name1, prop1.getName()); Property<string, string> prop2(name2, someValue); CPPUNIT_ASSERT_EQUAL(someValue, prop2()); CPPUNIT_ASSERT_EQUAL(someValue, prop2.getValue()); CPPUNIT_ASSERT_EQUAL(name2, prop2.getName()); Property<string, int> prop3(name3, integer); CPPUNIT_ASSERT_EQUAL(integer, prop3()); CPPUNIT_ASSERT_EQUAL(integer, prop3.getValue()); CPPUNIT_ASSERT_EQUAL(name3, prop3.getName()); Property<string, double> prop4(name4, d); CPPUNIT_ASSERT_EQUAL(d, prop4()); CPPUNIT_ASSERT_EQUAL(d, prop4.getValue()); CPPUNIT_ASSERT_EQUAL(name4, prop4.getName()); Property<string, DateTime> prop5(name5, now); CPPUNIT_ASSERT_EQUAL(now.utcTime(), prop5().utcTime()); CPPUNIT_ASSERT_EQUAL(now.utcTime(), prop5.getValue().utcTime()); CPPUNIT_ASSERT_EQUAL(name5, prop5.getName()); }
int main() { Room* B111 = new Room("B111"); Time atime; atime.d_year = 2015; atime.d_month = 9; atime.d_day = 14; atime.d_hour = 4; atime.d_minutes = 10; const char *names[] = { "Rodger", "Kate", "Willie", "Ben", "Brian" }; vector<string> name1(names, end(names)); vector<string> name2(names, end(names)); vector<string> name3(names, end(names)); vector<string> name4(names, end(names)); vector<string> name5(names, end(names)); B111->add(new Meeting(true, name1, "Assignment1", atime, 56, 5)); B111->print(); B111->add(new Meeting(true, name2, "Midtern" , atime, 66, 0)); B111->print(); B111->add(new Meeting(true, name3, "FinalExam ", atime, 67, 7)); B111->print(); B111->add(new Meeting(true, name4, "Faculty Meeting", atime, 69, 3)); B111->print(); B111->add(new Meeting(true, name5, "TA Meeting ", atime, 70, 0)); B111->print(); Room* A111 = new Room("A111"); B111 = new Room(*A111); B111->setName("B111"); Meeting* getTogether = new Meeting(true, name2, "Assigment2", atime, 34, 0); B111->add(getTogether); B111->print(); A111->print(); delete A111; B111->print(); delete B111; system("pause"); }
int test_pair3() { std::pair<std::string, int> name1("Som", 15); std::pair<std::string, int> name2(name1); std::cout << "name2: " << name2.first << " " << name2.second << std::endl; std::pair<std::string, int> name3 = std::make_pair("Som", 15); if (name1 == name3) { std::cout << "they are the same people" << std::endl; } else { std::cout << "they are not the same people" << std::endl; } std::pair<std::string, int> name4; name4 = name1; std::cout << "name4: " << name4.first << " " << name4.second << std::endl; std::pair<std::string, int> name5("Som", 16); if (name1 > name5) { std::cout << "name1 > name5" << std::endl; } else if (name1 < name5) { std::cout << "name1 < name5" << std::endl; } else { std::cout << "name1 == name5" << std::endl; } std::pair<std::string, int> name6("Take", 11); std::cout << "name1: " << name1.first << " " << name1.second << std::endl; std::cout << "name6: " << name6.first << " " << name6.second << std::endl; std::swap(name1, name6); // C++11::endl; std::cout << "after std::swap: " << std::endl; std::cout << "name1: " << name1.first << " " << name1.second << std::endl; std::cout << "name6: " << name6.first << " " << name6.second << std::endl; return 0; }