aboutsummaryrefslogtreecommitdiff
path: root/tests/test_binding_clash.py
diff options
context:
space:
mode:
authorMarco Poletti <poletti.marco@gmail.com>2016-12-21 17:37:54 +0000
committerMarco Poletti <poletti.marco@gmail.com>2016-12-21 17:37:54 +0000
commitbdf5dc0e67993c8fd475fda1839d2b4dd4a202c3 (patch)
treebe74d94d44c9e313850ab307ba33ab9dd25ca585 /tests/test_binding_clash.py
parent4b210eb62ca4f7d75a4c77207ea86a05e5b55f34 (diff)
downloadgoogle-fruit-bdf5dc0e67993c8fd475fda1839d2b4dd4a202c3.tar.gz
Introduce a ConstructionTracker helper class for tests, avoiding some repetition and making tests more concise.
Diffstat (limited to 'tests/test_binding_clash.py')
-rwxr-xr-xtests/test_binding_clash.py15
1 files changed, 4 insertions, 11 deletions
diff --git a/tests/test_binding_clash.py b/tests/test_binding_clash.py
index 66204d5..d75e867 100755
--- a/tests/test_binding_clash.py
+++ b/tests/test_binding_clash.py
@@ -21,6 +21,7 @@ COMMON_DEFINITIONS = '''
#include <fruit/fruit.h>
#include <vector>
#include "test_macros.h"
+ #include "class_construction_tracker.h"
struct X;
struct Y;
@@ -317,18 +318,10 @@ def test_bind_instance_and_binding_runtime(XAnnot):
@params('X', 'fruit::Annotated<Annotation1, X>')
def test_during_component_merge_consistent_ok(XAnnot):
source = '''
- struct X {
+ struct X : public ConstructionTracker<X> {
using Inject = X();
- X() {
- Assert(!constructed);
- constructed = true;
- }
-
- static bool constructed;
};
- bool X::constructed = false;
-
fruit::Component<XAnnot> getComponent() {
return fruit::createComponent();
}
@@ -337,9 +330,9 @@ def test_during_component_merge_consistent_ok(XAnnot):
fruit::NormalizedComponent<> normalizedComponent(getComponent());
fruit::Injector<XAnnot> injector(normalizedComponent, getComponent());
- Assert(!X::constructed);
+ Assert(X::num_objects_constructed == 0);
injector.get<XAnnot>();
- Assert(X::constructed);
+ Assert(X::num_objects_constructed == 1);
}
'''
expect_success(