Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Relaxing rules on CoreContext::Construct, adding unit test
There are use cases where a type will need to be constructed in a context even if it also provides a default ctor. We're just going to have to live with these cases, and allow clients to deal with the ambiguity that might result if they construct a type with varying args in the same context.
- Loading branch information
1 parent
49e3596
commit e95ea69
Showing
5 changed files
with
38 additions
and
22 deletions.
There are no files selected for viewing
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#include "stdafx.h" | ||
|
||
class AutoConstructTest: | ||
public testing::Test | ||
{}; | ||
|
||
class HasDefaultCtorAndOthers { | ||
public: | ||
HasDefaultCtorAndOthers(void) : | ||
v(101) | ||
{} | ||
HasDefaultCtorAndOthers(int v) : | ||
v(v) | ||
{} | ||
|
||
const int v; | ||
}; | ||
|
||
TEST_F(AutoConstructTest, AutoConstructNoArgs) { | ||
AutoConstruct<HasDefaultCtorAndOthers> hdcao; | ||
ASSERT_EQ(101, hdcao->v) << "Default constructor was not called as expected"; | ||
} | ||
|
||
TEST_F(AutoConstructTest, AutoConstructWithArgs) { | ||
AutoConstruct<HasDefaultCtorAndOthers> hdcao(495); | ||
ASSERT_EQ(495, hdcao->v) << "Constructor call was not made as expected"; | ||
} |
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