Created
January 23, 2012 16:05
-
-
Save TyounanMOTI/1663990 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <gtest/gtest.h> | |
enum { | |
CONSTRUCTOR, | |
COPY_CONSTRUCTOR, | |
}; | |
class Bar | |
{ | |
public: | |
explicit Bar(const int b) : a(CONSTRUCTOR) {}; | |
int a; | |
private: | |
Bar(const Bar& bar) : a(COPY_CONSTRUCTOR) {}; | |
}; | |
class Foo | |
{ | |
public: | |
Foo() : bar(0) {}; | |
Bar bar; | |
}; | |
TEST(ConstructorTest, FooCallsConstructorOfBar) { | |
Foo foo; | |
EXPECT_EQ(CONSTRUCTOR, foo.bar.a); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
in following case, compile fails because Foo calls Bar's private copy constructor.
line 22: Foo() : bar(Bar(0)) {}