Skip to content

Commit

Permalink
test: add function check test case
Browse files Browse the repository at this point in the history
  • Loading branch information
Dup4 committed Jun 29, 2022
1 parent ab7d22b commit cb5b635
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions test/autowired_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,10 @@ class F {
E *e_{nullptr};
};

class G {
public:
};

class AutoWiredTest : public testing::Test {
protected:
virtual void SetUp() override {
Expand Down Expand Up @@ -129,3 +133,11 @@ TEST_F(AutoWiredTest, need_init_test) {
EXPECT_EQ(2, auto_wired::DefaultAutoWired().GetInstance<E>()->GetValue());
EXPECT_EQ(3, auto_wired::DefaultAutoWired().GetInstance<F>()->GetValue());
}

TEST_F(AutoWiredTest, function_check_test) {
auto_wired::AutoWired a;

EXPECT_THROW(a.Register<G>(auto_wired::AutoWired::RegisterOptions::WithNeedAutoWired()), std::runtime_error);
EXPECT_THROW(a.Register<G>(auto_wired::AutoWired::RegisterOptions::WithNeedInit()), std::runtime_error);
EXPECT_THROW(a.Register<G>(auto_wired::AutoWired::RegisterOptions::WithNeedDeInit()), std::runtime_error);
}

0 comments on commit cb5b635

Please sign in to comment.