summaryrefslogtreecommitdiff
path: root/cli-tests/group/driver.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'cli-tests/group/driver.cxx')
-rw-r--r--cli-tests/group/driver.cxx43
1 files changed, 39 insertions, 4 deletions
diff --git a/cli-tests/group/driver.cxx b/cli-tests/group/driver.cxx
index 68f6107..9a3c710 100644
--- a/cli-tests/group/driver.cxx
+++ b/cli-tests/group/driver.cxx
@@ -5,10 +5,14 @@
// Test group_scanner.
//
+#include <string>
#include <iostream>
#include "test.hxx"
+#undef NDEBUG
+#include <cassert>
+
using namespace std;
int
@@ -25,27 +29,58 @@ main (int argc, char* argv[])
//
string m (argv[1]);
+ bool sa (m.find ('s') != string::npos);
+ bool sg (m.find ('g') != string::npos);
+
argv_scanner as (--argc, ++argv);
group_scanner s (as);
+ // Verify previous two args are still valid for good measure.
+ //
+ const char* prev_a (0);
+ string prev_s;
+
+ // Verify position.
+ //
+ size_t pos (0); // argv_scanner starts from 1.
+
while (s.more ())
{
- if (m.find ('s') == string::npos)
+ assert (pos < s.position ());
+ pos = s.position ();
+
+ s.peek ();
+ assert (pos == s.position ());
+
+ const char* a (0);
+ if (!sa)
{
- const char* a (s.next ());
+ a = s.next ();
cout << "'" << a << "'";
}
else
s.skip ();
- if (m.find ('g') == string::npos)
+ if (!sg)
{
scanner& gs (s.group ());
while (gs.more ())
cout << " '" << gs.next () << "'";
}
- cout << endl;
+ if (!sa || !sg)
+ cout << endl;
+
+ if (!sa && !sg)
+ {
+ s.more ();
+
+ if (prev_a != 0)
+ assert (prev_a == prev_s);
+
+ prev_a = a;
+ prev_s = a;
+ }
}
return 0;