aboutsummaryrefslogtreecommitdiff
path: root/tests/test_bind_interface.py
diff options
context:
space:
mode:
authorMarco Poletti <poletti.marco@gmail.com>2016-11-19 17:49:14 +0000
committerMarco Poletti <poletti.marco@gmail.com>2016-11-19 17:49:14 +0000
commitef4bc1fddc438276708917e2341b80c37a76100f (patch)
treeeed2db89595940f5d9342c73fd996f95658074e4 /tests/test_bind_interface.py
parente7ac9ba46ecf355d7becd4a6f85ad6a7bef5c51e (diff)
downloadgoogle-fruit-ef4bc1fddc438276708917e2341b80c37a76100f.tar.gz
Replace tests that have a non-annotated and an annotated variant with a single parameterized test (per pair).
Diffstat (limited to 'tests/test_bind_interface.py')
-rwxr-xr-xtests/test_bind_interface.py40
1 files changed, 16 insertions, 24 deletions
diff --git a/tests/test_bind_interface.py b/tests/test_bind_interface.py
index 6b8accc..c3ca207 100755
--- a/tests/test_bind_interface.py
+++ b/tests/test_bind_interface.py
@@ -12,6 +12,7 @@
# 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 nose2.tools import params
from fruit_test_common import *
@@ -20,27 +21,14 @@ COMMON_DEFINITIONS = '''
#include <vector>
#include "test_macros.h"
-struct X;
-
-struct Annotation {};
-using XAnnot = fruit::Annotated<Annotation, X>;
-using intAnnot = fruit::Annotated<Annotation, int>;
+struct Annotation1 {};
+struct Annotation2 {};
'''
-def test_error_not_base():
- expect_compile_error(
- 'NotABaseClassOfError<X,int>',
- 'I is not a base class of C.',
- COMMON_DEFINITIONS + '''
-struct X {};
-
-fruit::Component<int> getComponent() {
- return fruit::createComponent()
- .bind<X, int>();
-}
-''')
-
-def test_error_not_base_with_annotations():
+@params(
+ ('X', 'int'),
+ ('fruit::Annotated<Annotation1, X>', 'fruit::Annotated<Annotation2, int>'))
+def test_error_not_base(XAnnot, intAnnot):
expect_compile_error(
'NotABaseClassOfError<X,int>',
'I is not a base class of C.',
@@ -51,20 +39,24 @@ fruit::Component<intAnnot> getComponent() {
return fruit::createComponent()
.bind<XAnnot, intAnnot>();
}
-''')
+''',
+ locals())
-def test_error_bound_to_itself():
+# TODO: maybe the error should include the annotation here.
+@params('X', 'fruit::Annotated<Annotation1, X>')
+def test_error_bound_to_itself(XAnnot):
expect_compile_error(
'InterfaceBindingToSelfError<X>',
'The type C was bound to itself.',
COMMON_DEFINITIONS + '''
struct X {};
-fruit::Component<int> getComponent() {
+fruit::Component<X> getComponent() {
return fruit::createComponent()
- .bind<X, X>();
+ .bind<XAnnot, XAnnot>();
}
-''')
+''',
+ locals())
if __name__ == '__main__':
import nose2