|
|
@@ -8,21 +8,7 @@
|
|
|
|
|
|
#include "cli/cli.h"
|
|
|
|
|
|
-#include <gmock/gmock.h>
|
|
|
-#include <gtest/gtest.h>
|
|
|
-
|
|
|
-#if XCODE_UNIT_TEST
|
|
|
-// This is a hack to allow XCode to properly display failures when running
|
|
|
-// unit tests.
|
|
|
-#undef EXPECT_THAT
|
|
|
-#define EXPECT_THAT ASSERT_THAT
|
|
|
-#undef EXPECT_THROW
|
|
|
-#define EXPECT_THROW ASSERT_THROW
|
|
|
-#undef EXPECT_TRUE
|
|
|
-#define EXPECT_TRUE ASSERT_TRUE
|
|
|
-#undef EXPECT_FALSE
|
|
|
-#define EXPECT_FALSE ASSERT_FALSE
|
|
|
-#endif
|
|
|
+#include "xcode_gtest_helper.h"
|
|
|
|
|
|
TEST(CliTest, EndsOnQuit) {
|
|
|
std::stringstream input{R"(quit)"};
|
|
|
@@ -43,6 +29,24 @@ TEST(CliTest, WillSkipCallbackIfNotEnoughArgs) {
|
|
|
EXPECT_FALSE(was_hit);
|
|
|
}
|
|
|
|
|
|
+TEST(CliTest, CanEscapeSpaces) {
|
|
|
+ std::string data{};
|
|
|
+ std::stringstream input{R"(act A\ B)"};
|
|
|
+ cli::cli(input).register_callback("act", [&](std::string const &str){
|
|
|
+ data = str;
|
|
|
+ }).run();
|
|
|
+ EXPECT_THAT(data, "A B");
|
|
|
+}
|
|
|
+
|
|
|
+TEST(CliTest, CanQuoteWrapArgs) {
|
|
|
+ std::string data{};
|
|
|
+ std::stringstream input{R"(act "A B")"};
|
|
|
+ cli::cli(input).register_callback("act", [&](std::string const &str){
|
|
|
+ data = str;
|
|
|
+ }).run();
|
|
|
+ EXPECT_THAT(data, "A B");
|
|
|
+}
|
|
|
+
|
|
|
struct example {};
|
|
|
void cli_print(example const &) { throw example{}; }
|
|
|
|