aboutsummaryrefslogtreecommitdiff
path: root/tests/test_bind_interface.py
diff options
context:
space:
mode:
authorMarco Poletti <poletti.marco@gmail.com>2016-10-08 18:49:04 +0100
committerMarco Poletti <poletti.marco@gmail.com>2016-10-08 18:52:56 +0100
commitf9b2c6f586a84610890a1917f7c6cf84d3070271 (patch)
treefc49e5a3ef9d53ca45d8e1367b758c55bc565971 /tests/test_bind_interface.py
parent2d34eacda3bef73b75d640c712c262ddc34f5ccd (diff)
downloadgoogle-fruit-f9b2c6f586a84610890a1917f7c6cf84d3070271.tar.gz
Port all end-to-end C++ tests to be nose2-based python tests, so that:
* A single file can contain multiple testcases (also making it easier to share common setup between testcases). * The CMakeLists.txt file doesn't need to be updated for each test case. * It will be possible to introduce parameterized tests in the future. Running these tests under Bazel is no longer supported (support might however be re-introduced in the future).
Diffstat (limited to 'tests/test_bind_interface.py')
-rwxr-xr-xtests/test_bind_interface.py60
1 files changed, 60 insertions, 0 deletions
diff --git a/tests/test_bind_interface.py b/tests/test_bind_interface.py
new file mode 100755
index 0000000..f023700
--- /dev/null
+++ b/tests/test_bind_interface.py
@@ -0,0 +1,60 @@
+#!/usr/bin/env python3
+# Copyright 2016 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.
+
+from fruit_test_common import *
+
+def test_error_not_base():
+ expect_compile_error(
+ 'NotABaseClassOfError<X,int>',
+ 'I is not a base class of C.',
+ '''
+struct X {};
+
+Component<int> getComponent() {
+ return fruit::createComponent()
+ .bind<X, int>();
+}
+''')
+
+def test_error_not_base_with_annotations():
+ expect_compile_error(
+ 'NotABaseClassOfError<X,int>',
+ 'I is not a base class of C.',
+ '''
+struct Annotation {};
+struct X {};
+
+Component<fruit::Annotated<Annotation, int>> getComponent() {
+ return fruit::createComponent()
+ .bind<fruit::Annotated<Annotation, X>, fruit::Annotated<Annotation, int>>();
+}
+''')
+
+def test_error_bound_to_itself():
+ expect_compile_error(
+ 'InterfaceBindingToSelfError<X>',
+ 'The type C was bound to itself.',
+ '''
+struct X {};
+
+Component<int> getComponent() {
+ return fruit::createComponent()
+ .bind<X, X>();
+}
+''')
+
+if __name__ == '__main__':
+ import nose2
+ nose2.main()