/*
- * Copyright 2017 Facebook, Inc.
+ * Copyright 2015-present Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
callHelper({"--help"});
callHelper({"--help", "foo"});
callHelper({"--help", "bar"});
+ callHelper({"--help", "--", "bar"});
callHelper({"help"});
callHelper({"help", "foo"});
callHelper({"help", "bar"});
// wrong command name
callHelper({"--help", "qux"}, 1);
callHelper({"help", "qux"}, 1);
+
+ // anything after -- is parsed as arguments
+ callHelper({"--", "help", "bar"}, 1);
}
TEST(ProgramOptionsTest, DevFull) {
callHelper({"--help"}, 1, full.fd());
}
+TEST(ProgramOptionsTest, CutArguments) {
+ // anything after -- is parsed as arguments
+ EXPECT_EQ(
+ "running foo\n"
+ "foo global-foo 43\n"
+ "foo local-foo 42\n"
+ "foo arg b\n"
+ "foo arg --local-foo\n"
+ "foo arg 44\n"
+ "foo arg a\n",
+ callHelper(
+ {"foo", "--global-foo", "43", "--", "b", "--local-foo", "44", "a"}));
+}
+
TEST(ProgramOptionsTest, Success) {
EXPECT_EQ(
"running foo\n"
"a", "b"}));
}
-}} // namespaces
+} // namespace test
+} // namespace folly