aboutsummaryrefslogtreecommitdiffstats
path: root/vespalib/src/tests/testapp-state
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 /vespalib/src/tests/testapp-state
Publish
Diffstat (limited to 'vespalib/src/tests/testapp-state')
-rw-r--r--vespalib/src/tests/testapp-state/.cvsignore3
-rw-r--r--vespalib/src/tests/testapp-state/.gitignore8
-rw-r--r--vespalib/src/tests/testapp-state/CMakeLists.txt14
-rw-r--r--vespalib/src/tests/testapp-state/DESC1
-rw-r--r--vespalib/src/tests/testapp-state/FILES1
-rw-r--r--vespalib/src/tests/testapp-state/expect.txt22
-rw-r--r--vespalib/src/tests/testapp-state/statetest.cpp54
-rw-r--r--vespalib/src/tests/testapp-state/testapp-state.cpp11
8 files changed, 114 insertions, 0 deletions
diff --git a/vespalib/src/tests/testapp-state/.cvsignore b/vespalib/src/tests/testapp-state/.cvsignore
new file mode 100644
index 00000000000..6beefaa8e76
--- /dev/null
+++ b/vespalib/src/tests/testapp-state/.cvsignore
@@ -0,0 +1,3 @@
+.depend
+Makefile
+testapp-state_test
diff --git a/vespalib/src/tests/testapp-state/.gitignore b/vespalib/src/tests/testapp-state/.gitignore
new file mode 100644
index 00000000000..db6a3e3e414
--- /dev/null
+++ b/vespalib/src/tests/testapp-state/.gitignore
@@ -0,0 +1,8 @@
+.depend
+Makefile
+actual.txt
+out.txt
+state_test
+testapp-state_test
+vespalib_state_test_app
+vespalib_testapp-state_test_app
diff --git a/vespalib/src/tests/testapp-state/CMakeLists.txt b/vespalib/src/tests/testapp-state/CMakeLists.txt
new file mode 100644
index 00000000000..0fa88d7ddd2
--- /dev/null
+++ b/vespalib/src/tests/testapp-state/CMakeLists.txt
@@ -0,0 +1,14 @@
+# Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+vespa_add_executable(vespalib_testapp-state_test_app
+ SOURCES
+ testapp-state.cpp
+ DEPENDS
+ vespalib
+)
+vespa_add_test(NAME vespalib_testapp-state_test_app COMMAND vespalib_testapp-state_test_app)
+vespa_add_executable(vespalib_state_test_app
+ SOURCES
+ statetest.cpp
+ DEPENDS
+ vespalib
+)
diff --git a/vespalib/src/tests/testapp-state/DESC b/vespalib/src/tests/testapp-state/DESC
new file mode 100644
index 00000000000..3f29b94f72d
--- /dev/null
+++ b/vespalib/src/tests/testapp-state/DESC
@@ -0,0 +1 @@
+testapp-state test. Take a look at testapp-state.cpp for details.
diff --git a/vespalib/src/tests/testapp-state/FILES b/vespalib/src/tests/testapp-state/FILES
new file mode 100644
index 00000000000..ef2eb9303fc
--- /dev/null
+++ b/vespalib/src/tests/testapp-state/FILES
@@ -0,0 +1 @@
+testapp-state.cpp
diff --git a/vespalib/src/tests/testapp-state/expect.txt b/vespalib/src/tests/testapp-state/expect.txt
new file mode 100644
index 00000000000..87b7721907e
--- /dev/null
+++ b/vespalib/src/tests/testapp-state/expect.txt
@@ -0,0 +1,22 @@
+ STATE[0]: 'foo' (statetest.cpp:26)
+ STATE[1]: 'bar' (statetest.cpp:29)
+ STATE[0]: 'foo' (statetest.cpp:26)
+ STATE[2]: 'baz' (statetest.cpp:32)
+ STATE[1]: 'bar' (statetest.cpp:29)
+ STATE[0]: 'foo' (statetest.cpp:26)
+ STATE[1]: 'bar' (statetest.cpp:29)
+ STATE[0]: 'foo' (statetest.cpp:26)
+ STATE[0]: 'foo' (statetest.cpp:26)
+ STATE[0]: 'testSomething()' (statetest.cpp:42)
+ STATE[1]: 'testInner()' (statetest.cpp:13)
+ STATE[0]: 'testSomething()' (statetest.cpp:42)
+ STATE[0]: 'testSomething()' (statetest.cpp:42)
+ STATE[0]: 'something else' (statetest.cpp:45)
+ STATE[1]: 'testSomethingElse()' (statetest.cpp:47)
+ STATE[0]: 'something else' (statetest.cpp:45)
+ STATE[2]: 'testInner()' (statetest.cpp:19)
+ STATE[1]: 'testSomethingElse()' (statetest.cpp:47)
+ STATE[0]: 'something else' (statetest.cpp:45)
+ STATE[1]: 'testSomethingElse()' (statetest.cpp:47)
+ STATE[0]: 'something else' (statetest.cpp:45)
+ STATE[0]: 'something else' (statetest.cpp:45)
diff --git a/vespalib/src/tests/testapp-state/statetest.cpp b/vespalib/src/tests/testapp-state/statetest.cpp
new file mode 100644
index 00000000000..4ca9fc4259e
--- /dev/null
+++ b/vespalib/src/tests/testapp-state/statetest.cpp
@@ -0,0 +1,54 @@
+// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+#include <vespa/fastos/fastos.h>
+#include <vespa/vespalib/testkit/test_kit.h>
+
+using namespace vespalib;
+
+void testInner() {
+ EXPECT_TRUE(false);
+}
+
+void testSomething() {
+ EXPECT_TRUE(false);
+ TEST_DO(testInner());
+ EXPECT_TRUE(false);
+}
+
+void testSomethingElse() {
+ EXPECT_TRUE(false);
+ TEST_DO(testInner());
+ EXPECT_TRUE(false);
+}
+
+void testState() {
+ EXPECT_TRUE(false);
+ {
+ TEST_STATE("foo");
+ EXPECT_TRUE(false);
+ {
+ TEST_STATE("bar");
+ EXPECT_TRUE(false);
+ {
+ TEST_STATE("baz");
+ EXPECT_TRUE(false);
+ }
+ EXPECT_TRUE(false);
+ }
+ EXPECT_TRUE(false);
+ }
+ EXPECT_TRUE(false);
+ EXPECT_TRUE(false);
+ {
+ TEST_DO(testSomething());
+ }
+ {
+ TEST_STATE("something else");
+ EXPECT_TRUE(false);
+ TEST_DO(testSomethingElse());
+ EXPECT_TRUE(false);
+ }
+}
+
+TEST_MAIN() {
+ testState();
+}
diff --git a/vespalib/src/tests/testapp-state/testapp-state.cpp b/vespalib/src/tests/testapp-state/testapp-state.cpp
new file mode 100644
index 00000000000..016ad90dd50
--- /dev/null
+++ b/vespalib/src/tests/testapp-state/testapp-state.cpp
@@ -0,0 +1,11 @@
+// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+#include <vespa/fastos/fastos.h>
+#include <vespa/vespalib/testkit/test_kit.h>
+
+using namespace vespalib;
+
+TEST_MAIN() {
+ system("./vespalib_state_test_app > out.txt 2>&1 out.txt");
+ system("cat out.txt | grep STATE | sed 's/([^)].*\\//(/' > actual.txt");
+ EXPECT_EQUAL(system("diff -u expect.txt actual.txt"), 0);
+}