Skip to content

Commit

Permalink
Add a new tests for copying components.
Browse files Browse the repository at this point in the history
  • Loading branch information
poletti-marco committed Aug 21, 2014
1 parent 938a662 commit 82216c4
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
1 change: 1 addition & 0 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
set(TEST_SOURCES
component_copy.cpp
dep_canonicalization.cpp
dependency_loop.cpp
explicit_provider_injection.cpp
Expand Down
39 changes: 39 additions & 0 deletions tests/component_copy.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// expect-success
/*
* Copyright 2014 Google Inc. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#include <fruit/fruit.h>

using fruit::Component;
using fruit::Injector;

struct X {
INJECT(X()) = default;
};

fruit::Component<X> getComponent() {
auto c = fruit::createComponent();
auto copy = c;
return copy;
}

int main() {
Component<X> component = getComponent();
Injector<X> injector(component);
injector.get<X*>();

return 0;
}

0 comments on commit 82216c4

Please sign in to comment.