diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index fe2b6cf8..2262a439 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -1,4 +1,5 @@ set(TEST_SOURCES +component_copy.cpp dep_canonicalization.cpp dependency_loop.cpp explicit_provider_injection.cpp diff --git a/tests/component_copy.cpp b/tests/component_copy.cpp new file mode 100644 index 00000000..a4e355f2 --- /dev/null +++ b/tests/component_copy.cpp @@ -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 + +using fruit::Component; +using fruit::Injector; + +struct X { + INJECT(X()) = default; +}; + +fruit::Component getComponent() { + auto c = fruit::createComponent(); + auto copy = c; + return copy; +} + +int main() { + Component component = getComponent(); + Injector injector(component); + injector.get(); + + return 0; +}