aboutsummaryrefslogtreecommitdiff
path: root/tests/project-name/driver.cxx
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2018-07-30 13:02:13 +0300
committerKaren Arutyunov <karen@codesynthesis.com>2018-07-30 13:02:13 +0300
commit143d2f473fb92256d33f91266aa9d1829bc9fce1 (patch)
tree8058d26dea5404ec65a820d7d0b4e63bd7fa8f93 /tests/project-name/driver.cxx
parent6f120d5f670694a0d1bd8d9dd2a972c295e5daeb (diff)
Add test for project_name::base()
Diffstat (limited to 'tests/project-name/driver.cxx')
-rw-r--r--tests/project-name/driver.cxx9
1 files changed, 6 insertions, 3 deletions
diff --git a/tests/project-name/driver.cxx b/tests/project-name/driver.cxx
index 51c8782..3535ba2 100644
--- a/tests/project-name/driver.cxx
+++ b/tests/project-name/driver.cxx
@@ -45,7 +45,7 @@ name (const string& s)
return r;
}
-// Usage: argv[0] (string|base|extension|variable)
+// Usage: argv[0] (string|base [ext]|extension|variable)
//
// Create project names from stdin lines, and for each of them print the
// result of the specified member function to stdout, one per line.
@@ -54,21 +54,24 @@ int
main (int argc, char* argv[])
try
{
- assert (argc == 2);
+ assert (argc <= 3);
string m (argv[1]);
assert (m == "string" || m == "base" || m == "extension" || m == "variable");
+ assert (m == "base" ? argc <= 3 : argc == 2);
cin.exceptions (ios::badbit);
cout.exceptions (ios::failbit | ios::badbit);
+ const char* ext (argc == 3 ? argv[2] : nullptr);
+
string l;
while (!eof (getline (cin, l)))
{
project_name n (name (l));
const string& s (m == "string" ? n.string () :
- m == "base" ? n.base () :
+ m == "base" ? n.base (ext) :
m == "extension" ? n.extension () :
n.variable ());