Exemple #1
0
int main(int argc, const char * argv[]) {
    // insert code here...
    std::cout << "Hello, World!\n";
    
    // now start tutorial
    
    MyClass m;
    m.x = 10;
    m.y = 20;
    m.foo();
    
    return 0;
}
Exemple #2
0
/**
 * Bascially a compilation test, to ensure that the interfaces
 * are correct and tracked_ptr<T> can be used substituting T*
 */
TEST(TrackedPointer, DesignTest) {
  MyClass* bar = new MyClass();

  EXPECT_EQ(42, bar->foo());
  EXPECT_EQ(42, (*bar).foo());
  
  tracked_ptr<MyClass> bar_p(bar);
  
  ASSERT_EQ(42, bar_p->foo());
  ASSERT_EQ(42, (*bar_p).foo());
  
  // Can I get the wrapped pointer out of the address in the same way
  // I can get it from a standard pointer?
  ASSERT_EQ(&(*bar), &(*bar_p));
  ASSERT_EQ(&(*bar), bar);
  ASSERT_EQ(&(*bar_p), bar);
  ASSERT_TRUE(&(*bar_p) == bar);
  
  delete bar;
}