1 |
commit: ea0497dffc5d63c002ca239aaf815426fbc40fc8 |
2 |
Author: Mu Qiao <qiaomuf <AT> gentoo <DOT> org> |
3 |
AuthorDate: Thu May 26 08:44:26 2011 +0000 |
4 |
Commit: Petteri Räty <betelgeuse <AT> gentoo <DOT> org> |
5 |
CommitDate: Thu May 26 14:56:49 2011 +0000 |
6 |
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/libbash.git;a=commit;h=ea0497df |
7 |
|
8 |
Test: improve test coverage for shopt built-in |
9 |
|
10 |
--- |
11 |
src/builtins/tests/shopt_tests.cpp | 16 ++++++++++++++++ |
12 |
1 files changed, 16 insertions(+), 0 deletions(-) |
13 |
|
14 |
diff --git a/src/builtins/tests/shopt_tests.cpp b/src/builtins/tests/shopt_tests.cpp |
15 |
index 14b99d0..e8cd013 100644 |
16 |
--- a/src/builtins/tests/shopt_tests.cpp |
17 |
+++ b/src/builtins/tests/shopt_tests.cpp |
18 |
@@ -46,3 +46,19 @@ TEST(shopt_builtin_test, enable_extglob) |
19 |
EXPECT_TRUE(walker.get_option("autocd")); |
20 |
EXPECT_TRUE(walker.get_option("cdspell")); |
21 |
} |
22 |
+ |
23 |
+static void test_shopt_builtin(const std::string& expected, const std::vector<std::string>& args, int status) |
24 |
+{ |
25 |
+ std::stringstream output; |
26 |
+ interpreter walker; |
27 |
+ EXPECT_EQ(status, cppbash_builtin::exec("shopt", args, std::cout, output, std::cin, walker)); |
28 |
+ EXPECT_STREQ(expected.c_str(), output.str().c_str()); |
29 |
+} |
30 |
+ |
31 |
+TEST(shopt_builtin_test, invalid_argument) |
32 |
+{ |
33 |
+ test_shopt_builtin("Arguments required for shopt\n", {}, 1); |
34 |
+ test_shopt_builtin("Multiple arguments are not supported\n", {"-so"}, 1); |
35 |
+ test_shopt_builtin("shopt -q is not supported yet\n", {"-q"}, 1); |
36 |
+ test_shopt_builtin("Unrecognized option for shopt: -d\n", {"-d"}, 1); |
37 |
+} |