+void GetOptTests::positional()
+{
+ static const char *argv[] = { "test", "foo", "42", "bar", 0 };
+
+ string first;
+ unsigned second = 0;
+ string third;
+ unsigned fourth = 13;
+
+ GetOpt getopt;
+ getopt.add_argument("first", first);
+ getopt.add_argument("second", second);
+ getopt.add_argument("third", third);
+ getopt.add_argument("fourth", fourth, GetOpt::OPTIONAL_ARG);
+ getopt(4, argv);
+
+ EXPECT_EQUAL(first, "foo");
+ EXPECT_EQUAL(second, 42);
+ EXPECT_EQUAL(third, "bar");
+ EXPECT_EQUAL(fourth, 13);
+}
+
+void GetOptTests::positional_list()
+{
+ static const char *argv[] = { "test", "x", "y", "z", "foo", 0 };
+
+ list<string> args;
+ string tail;
+
+ GetOpt getopt;
+ getopt.add_argument("arg", args);
+ getopt.add_argument("tail", tail);
+ getopt(5, argv);
+
+ EXPECT_EQUAL(args.size(), 3U);
+ EXPECT_EQUAL(args.front(), "x");
+ EXPECT_EQUAL(args.back(), "z");
+ EXPECT_EQUAL(tail, "foo");
+}
+
+void GetOptTests::empty_list()
+{
+ static const char *argv[] = { "test", "foo", "bar", 0 };
+
+ string head;
+ list<string> mid;
+ string tail;
+
+ GetOpt getopt;
+ getopt.add_argument("head", head);
+ getopt.add_argument("mid", mid, GetOpt::OPTIONAL_ARG);
+ getopt.add_argument("tail", tail);
+ getopt(3, argv);
+
+ EXPECT_EQUAL(head, "foo");
+ EXPECT(mid.empty());
+ EXPECT_EQUAL(tail, "bar");
+}
+
+void GetOptTests::mixed()