summaryrefslogtreecommitdiffstats
path: root/vbench/src/tests/taint
diff options
context:
space:
mode:
authorJon Bratseth <bratseth@yahoo-inc.com>2016-06-15 23:09:44 +0200
committerJon Bratseth <bratseth@yahoo-inc.com>2016-06-15 23:09:44 +0200
commit72231250ed81e10d66bfe70701e64fa5fe50f712 (patch)
tree2728bba1131a6f6e5bdf95afec7d7ff9358dac50 /vbench/src/tests/taint
Publish
Diffstat (limited to 'vbench/src/tests/taint')
-rw-r--r--vbench/src/tests/taint/.gitignore1
-rw-r--r--vbench/src/tests/taint/CMakeLists.txt9
-rw-r--r--vbench/src/tests/taint/FILES1
-rw-r--r--vbench/src/tests/taint/taint_test.cpp43
4 files changed, 54 insertions, 0 deletions
diff --git a/vbench/src/tests/taint/.gitignore b/vbench/src/tests/taint/.gitignore
new file mode 100644
index 00000000000..ed8a6bdc417
--- /dev/null
+++ b/vbench/src/tests/taint/.gitignore
@@ -0,0 +1 @@
+vbench_taint_test_app
diff --git a/vbench/src/tests/taint/CMakeLists.txt b/vbench/src/tests/taint/CMakeLists.txt
new file mode 100644
index 00000000000..7dd23e62020
--- /dev/null
+++ b/vbench/src/tests/taint/CMakeLists.txt
@@ -0,0 +1,9 @@
+# Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+vespa_add_executable(vbench_taint_test_app
+ SOURCES
+ taint_test.cpp
+ DEPENDS
+ vbench_test
+ vbench
+)
+vespa_add_test(NAME vbench_taint_test_app COMMAND vbench_taint_test_app)
diff --git a/vbench/src/tests/taint/FILES b/vbench/src/tests/taint/FILES
new file mode 100644
index 00000000000..448832fd7dc
--- /dev/null
+++ b/vbench/src/tests/taint/FILES
@@ -0,0 +1 @@
+taint_test.cpp
diff --git a/vbench/src/tests/taint/taint_test.cpp b/vbench/src/tests/taint/taint_test.cpp
new file mode 100644
index 00000000000..1d7c1cb0ef0
--- /dev/null
+++ b/vbench/src/tests/taint/taint_test.cpp
@@ -0,0 +1,43 @@
+// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+#include <vespa/vespalib/testkit/testapp.h>
+#include <vbench/test/all.h>
+
+using namespace vbench;
+
+TEST("untainted") {
+ Taint t;
+ bool fail = t;
+ EXPECT_FALSE(fail);
+ EXPECT_FALSE(t.taint());
+ EXPECT_EQUAL("", t.reason());
+}
+
+TEST("Taintable::nil") {
+ const Taint &t = Taintable::nil().tainted();
+ bool fail = t;
+ EXPECT_FALSE(fail);
+ EXPECT_FALSE(t.taint());
+ EXPECT_EQUAL("", t.reason());
+}
+
+TEST("tainted") {
+ Taint t("argh");
+ bool fail = t;
+ EXPECT_TRUE(fail);
+ EXPECT_TRUE(t.taint());
+ EXPECT_EQUAL("argh", t.reason());
+}
+
+TEST("reset taint") {
+ Taint t;
+ EXPECT_FALSE(t.taint());
+ EXPECT_EQUAL("", t.reason());
+ t.reset("argh");
+ EXPECT_TRUE(t.taint());
+ EXPECT_EQUAL("argh", t.reason());
+ t.reset();
+ EXPECT_FALSE(t.taint());
+ EXPECT_EQUAL("", t.reason());
+}
+
+TEST_MAIN() { TEST_RUN_ALL(); }