mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-08-20 04:13:07 +02:00
C++11: N2672 Initializer lists
- Modified code to use the more compact and readable initializer lists.
This commit is contained in:
parent
49f7612704
commit
7bbc794d3a
25 changed files with 136 additions and 231 deletions
|
@ -534,13 +534,8 @@ bool Context::verbose (const std::string& token)
|
||||||
verbosity[0] != "sync" && //
|
verbosity[0] != "sync" && //
|
||||||
verbosity[0] != "filter") //
|
verbosity[0] != "filter") //
|
||||||
{
|
{
|
||||||
verbosity.clear ();
|
|
||||||
|
|
||||||
// This list emulates rc.verbose=off in version 1.9.4.
|
// This list emulates rc.verbose=off in version 1.9.4.
|
||||||
verbosity.push_back ("blank");
|
verbosity = {"blank", "label", "new-id", "edit"};
|
||||||
verbosity.push_back ("label");
|
|
||||||
verbosity.push_back ("new-id");
|
|
||||||
verbosity.push_back ("edit");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -765,8 +760,7 @@ void Context::updateVerbosity ()
|
||||||
if (command != "" &&
|
if (command != "" &&
|
||||||
command[0] == '_')
|
command[0] == '_')
|
||||||
{
|
{
|
||||||
verbosity.clear ();
|
verbosity = {"nothing"};
|
||||||
verbosity.push_back ("nothing");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
16
src/DOM.cpp
16
src/DOM.cpp
|
@ -52,16 +52,12 @@ DOM::~DOM ()
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
const std::vector <std::string> DOM::get_references () const
|
const std::vector <std::string> DOM::get_references () const
|
||||||
{
|
{
|
||||||
std::vector <std::string> refs;
|
return {"context.program",
|
||||||
|
"context.args",
|
||||||
refs.push_back ("context.program");
|
"context.width",
|
||||||
refs.push_back ("context.args");
|
"context.height",
|
||||||
refs.push_back ("context.width");
|
"system.version",
|
||||||
refs.push_back ("context.height");
|
"system.os"};
|
||||||
refs.push_back ("system.version");
|
|
||||||
refs.push_back ("system.os");
|
|
||||||
|
|
||||||
return refs;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
|
@ -43,23 +43,23 @@ ColumnDate::ColumnDate ()
|
||||||
_style = "formatted";
|
_style = "formatted";
|
||||||
_label = "";
|
_label = "";
|
||||||
|
|
||||||
_styles.push_back ("formatted");
|
_styles = {"formatted",
|
||||||
_styles.push_back ("julian");
|
"julian",
|
||||||
_styles.push_back ("epoch");
|
"epoch",
|
||||||
_styles.push_back ("iso");
|
"iso",
|
||||||
_styles.push_back ("age");
|
"age",
|
||||||
_styles.push_back ("remaining");
|
"remaining",
|
||||||
_styles.push_back ("countdown");
|
"countdown"};
|
||||||
|
|
||||||
Date now;
|
Date now;
|
||||||
now -= 125; // So that "age" is non-zero.
|
now -= 125; // So that "age" is non-zero.
|
||||||
_examples.push_back (now.toString (context.config.get ("dateformat")));
|
_examples = {now.toString (context.config.get ("dateformat")),
|
||||||
_examples.push_back (format (now.toJulian (), 13, 12));
|
format (now.toJulian (), 13, 12),
|
||||||
_examples.push_back (now.toEpochString ());
|
now.toEpochString (),
|
||||||
_examples.push_back (now.toISO ());
|
now.toISO (),
|
||||||
_examples.push_back (Duration (Date () - now).formatCompact ());
|
Duration (Date () - now).formatCompact (),
|
||||||
_examples.push_back ("");
|
"",
|
||||||
_examples.push_back (Duration (Date () - now).format ());
|
Duration (Date () - now).format ()};
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
|
@ -43,13 +43,13 @@ ColumnDepends::ColumnDepends ()
|
||||||
_style = "list";
|
_style = "list";
|
||||||
_label = STRING_COLUMN_LABEL_DEP;
|
_label = STRING_COLUMN_LABEL_DEP;
|
||||||
|
|
||||||
_styles.push_back ("list");
|
_styles = {"list",
|
||||||
_styles.push_back ("count");
|
"count",
|
||||||
_styles.push_back ("indicator");
|
"indicator"};
|
||||||
|
|
||||||
_examples.push_back ("1 2 10");
|
_examples = {"1 2 10",
|
||||||
_examples.push_back ("[3]");
|
"[3]",
|
||||||
_examples.push_back (context.config.get ("dependency.indicator"));
|
context.config.get ("dependency.indicator")};
|
||||||
|
|
||||||
_hyphenate = context.config.getBoolean ("hyphenate");
|
_hyphenate = context.config.getBoolean ("hyphenate");
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,12 +44,12 @@ ColumnDescription::ColumnDescription ()
|
||||||
_style = "combined";
|
_style = "combined";
|
||||||
_label = STRING_COLUMN_LABEL_DESC;
|
_label = STRING_COLUMN_LABEL_DESC;
|
||||||
|
|
||||||
_styles.push_back ("combined");
|
_styles = {"combined",
|
||||||
_styles.push_back ("desc");
|
"desc",
|
||||||
_styles.push_back ("oneline");
|
"oneline",
|
||||||
_styles.push_back ("truncated");
|
"truncated",
|
||||||
_styles.push_back ("count");
|
"count",
|
||||||
_styles.push_back ("truncated_count");
|
"truncated_count"};
|
||||||
|
|
||||||
_dateformat = context.config.get ("dateformat.annotation");
|
_dateformat = context.config.get ("dateformat.annotation");
|
||||||
if (_dateformat == "")
|
if (_dateformat == "")
|
||||||
|
@ -62,20 +62,18 @@ ColumnDescription::ColumnDescription ()
|
||||||
std::string a3 = STRING_COLUMN_EXAMPLES_ANNO3;
|
std::string a3 = STRING_COLUMN_EXAMPLES_ANNO3;
|
||||||
std::string a4 = STRING_COLUMN_EXAMPLES_ANNO4;
|
std::string a4 = STRING_COLUMN_EXAMPLES_ANNO4;
|
||||||
|
|
||||||
_examples.push_back (d
|
_examples = {d + "\n " + t + " " + a1
|
||||||
+ "\n " + t + " " + a1
|
|
||||||
+ "\n " + t + " " + a2
|
+ "\n " + t + " " + a2
|
||||||
+ "\n " + t + " " + a3
|
+ "\n " + t + " " + a3
|
||||||
+ "\n " + t + " " + a4);
|
+ "\n " + t + " " + a4,
|
||||||
_examples.push_back (d);
|
d,
|
||||||
_examples.push_back (d
|
d + " " + t + " " + a1
|
||||||
+ " " + t + " " + a1
|
|
||||||
+ " " + t + " " + a2
|
+ " " + t + " " + a2
|
||||||
+ " " + t + " " + a3
|
+ " " + t + " " + a3
|
||||||
+ " " + t + " " + a4);
|
+ " " + t + " " + a4,
|
||||||
_examples.push_back (d.substr (0, 20) + "...");
|
d.substr (0, 20) + "...",
|
||||||
_examples.push_back (d + " [4]");
|
d + " [4]",
|
||||||
_examples.push_back (d.substr (0, 20) + "... [4]");
|
d.substr (0, 20) + "... [4]"};
|
||||||
|
|
||||||
_hyphenate = context.config.getBoolean ("hyphenate");
|
_hyphenate = context.config.getBoolean ("hyphenate");
|
||||||
|
|
||||||
|
|
|
@ -43,7 +43,7 @@ ColumnDue::ColumnDue ()
|
||||||
|
|
||||||
Date now;
|
Date now;
|
||||||
now += 125;
|
now += 125;
|
||||||
_examples.push_back (Duration (now - Date ()).formatCompact ());
|
_examples = {Duration (now - Date ()).formatCompact ()};
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
|
@ -41,10 +41,8 @@ ColumnID::ColumnID ()
|
||||||
_style = "number";
|
_style = "number";
|
||||||
_label = STRING_COLUMN_LABEL_ID;
|
_label = STRING_COLUMN_LABEL_ID;
|
||||||
_modifiable = false;
|
_modifiable = false;
|
||||||
|
_styles = {"number"};
|
||||||
_styles.push_back ("number");
|
_examples = {"123"};
|
||||||
|
|
||||||
_examples.push_back ("123");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
|
@ -41,10 +41,8 @@ ColumnIMask::ColumnIMask ()
|
||||||
_style = "number";
|
_style = "number";
|
||||||
_label = STRING_COLUMN_LABEL_MASK_IDX;
|
_label = STRING_COLUMN_LABEL_MASK_IDX;
|
||||||
_modifiable = false;
|
_modifiable = false;
|
||||||
|
_styles = {"number"};
|
||||||
_styles.push_back ("number");
|
_examples = {"12"};
|
||||||
|
|
||||||
_examples.push_back ("12");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
|
@ -41,10 +41,8 @@ ColumnMask::ColumnMask ()
|
||||||
_style = "default";
|
_style = "default";
|
||||||
_label = STRING_COLUMN_LABEL_MASK;
|
_label = STRING_COLUMN_LABEL_MASK;
|
||||||
_modifiable = false;
|
_modifiable = false;
|
||||||
|
_styles = {"default"};
|
||||||
_styles.push_back ("default");
|
_examples = {"++++---"};
|
||||||
|
|
||||||
_examples.push_back ("++++---");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
|
@ -41,12 +41,8 @@ ColumnParent::ColumnParent ()
|
||||||
_style = "long";
|
_style = "long";
|
||||||
_label = STRING_COLUMN_LABEL_PARENT;
|
_label = STRING_COLUMN_LABEL_PARENT;
|
||||||
_modifiable = false;
|
_modifiable = false;
|
||||||
|
_styles = {"long", "short"};
|
||||||
_styles.push_back ("long");
|
_examples = {"f30cb9c3-3fc0-483f-bfb2-3bf134f00694", "34f00694"};
|
||||||
_styles.push_back ("short");
|
|
||||||
|
|
||||||
_examples.push_back ("f30cb9c3-3fc0-483f-bfb2-3bf134f00694");
|
|
||||||
_examples.push_back ("34f00694");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
|
@ -41,15 +41,10 @@ ColumnProject::ColumnProject ()
|
||||||
_type = "string";
|
_type = "string";
|
||||||
_style = "full";
|
_style = "full";
|
||||||
_label = STRING_COLUMN_LABEL_PROJECT;
|
_label = STRING_COLUMN_LABEL_PROJECT;
|
||||||
|
_styles = {"full", "parent", "indented"};
|
||||||
_styles.push_back ("full");
|
_examples = {STRING_COLUMN_EXAMPLES_PROJ,
|
||||||
_styles.push_back ("parent");
|
STRING_COLUMN_EXAMPLES_PAR,
|
||||||
_styles.push_back ("indented");
|
STRING_COLUMN_EXAMPLES_IND};
|
||||||
|
|
||||||
_examples.push_back (STRING_COLUMN_EXAMPLES_PROJ);
|
|
||||||
_examples.push_back (STRING_COLUMN_EXAMPLES_PAR);
|
|
||||||
_examples.push_back (STRING_COLUMN_EXAMPLES_IND);
|
|
||||||
|
|
||||||
_hyphenate = context.config.getBoolean ("hyphenate");
|
_hyphenate = context.config.getBoolean ("hyphenate");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -45,12 +45,8 @@ ColumnRecur::ColumnRecur ()
|
||||||
|
|
||||||
_style = "duration";
|
_style = "duration";
|
||||||
_label = STRING_COLUMN_LABEL_RECUR;
|
_label = STRING_COLUMN_LABEL_RECUR;
|
||||||
|
_styles = {"duration", "indicator"};
|
||||||
_styles.push_back ("duration");
|
_examples = {"weekly", context.config.get ("recurrence.indicator")};
|
||||||
_styles.push_back ("indicator");
|
|
||||||
|
|
||||||
_examples.push_back ("weekly");
|
|
||||||
_examples.push_back (context.config.get ("recurrence.indicator"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
|
@ -40,12 +40,11 @@ ColumnScheduled::ColumnScheduled ()
|
||||||
{
|
{
|
||||||
_name = "scheduled";
|
_name = "scheduled";
|
||||||
_label = STRING_COLUMN_LABEL_SCHED;
|
_label = STRING_COLUMN_LABEL_SCHED;
|
||||||
|
_styles = {"countdown"};
|
||||||
_styles.push_back ("countdown");
|
|
||||||
|
|
||||||
Date now;
|
Date now;
|
||||||
now += 125;
|
now += 125;
|
||||||
_examples.push_back (Duration (now - Date ()).formatCompact ());
|
_examples = {Duration (now - Date ()).formatCompact ()};
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
|
@ -38,10 +38,8 @@ ColumnStart::ColumnStart ()
|
||||||
{
|
{
|
||||||
_name = "start";
|
_name = "start";
|
||||||
_label = STRING_COLUMN_LABEL_STARTED;
|
_label = STRING_COLUMN_LABEL_STARTED;
|
||||||
|
_styles = {"active"};
|
||||||
_styles.push_back ("active");
|
_examples = {context.config.get ("active.indicator")};
|
||||||
|
|
||||||
_examples.push_back (context.config.get ("active.indicator"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
|
@ -40,12 +40,9 @@ ColumnStatus::ColumnStatus ()
|
||||||
_type = "string";
|
_type = "string";
|
||||||
_style = "long";
|
_style = "long";
|
||||||
_label = STRING_COLUMN_LABEL_STATUS;
|
_label = STRING_COLUMN_LABEL_STATUS;
|
||||||
|
_styles = {"long", "short"};
|
||||||
_styles.push_back ("long");
|
_examples = {STRING_COLUMN_LABEL_STAT_PE,
|
||||||
_styles.push_back ("short");
|
STRING_COLUMN_LABEL_STAT_P};
|
||||||
|
|
||||||
_examples.push_back (STRING_COLUMN_LABEL_STAT_PE);
|
|
||||||
_examples.push_back (STRING_COLUMN_LABEL_STAT_P);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
|
@ -39,17 +39,14 @@ ColumnString::ColumnString ()
|
||||||
_type = "string";
|
_type = "string";
|
||||||
_style = "left";
|
_style = "left";
|
||||||
_label = "";
|
_label = "";
|
||||||
|
_styles = {"left",
|
||||||
_styles.push_back ("left");
|
"right",
|
||||||
_styles.push_back ("right");
|
"left_fixed",
|
||||||
_styles.push_back ("left_fixed");
|
"right_fixed"};
|
||||||
_styles.push_back ("right_fixed");
|
_examples = {"Hello (wrapped) ",
|
||||||
|
" Hello (wrapped)",
|
||||||
_styles.push_back ("Hello (wrapped) ");
|
"Hello (no-wrap) ",
|
||||||
_styles.push_back (" Hello (wrapped)");
|
" Hello (no-wrap)"};
|
||||||
_styles.push_back ("Hello (no-wrap) ");
|
|
||||||
_styles.push_back (" Hello (no-wrap)");
|
|
||||||
|
|
||||||
_hyphenate = context.config.getBoolean ("hyphenate");
|
_hyphenate = context.config.getBoolean ("hyphenate");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -41,15 +41,10 @@ ColumnTags::ColumnTags ()
|
||||||
_type = "string";
|
_type = "string";
|
||||||
_style = "list";
|
_style = "list";
|
||||||
_label = STRING_COLUMN_LABEL_TAGS;
|
_label = STRING_COLUMN_LABEL_TAGS;
|
||||||
|
_styles = {"list", "indicator", "count"};
|
||||||
_styles.push_back ("list");
|
_examples = {STRING_COLUMN_EXAMPLES_TAGS,
|
||||||
_styles.push_back ("indicator");
|
context.config.get ("tag.indicator"),
|
||||||
_styles.push_back ("count");
|
"[2]"};
|
||||||
|
|
||||||
_examples.push_back (STRING_COLUMN_EXAMPLES_TAGS);
|
|
||||||
_examples.push_back (context.config.get ("tag.indicator"));
|
|
||||||
_examples.push_back ("[2]");
|
|
||||||
|
|
||||||
_hyphenate = context.config.getBoolean ("hyphenate");
|
_hyphenate = context.config.getBoolean ("hyphenate");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -44,11 +44,8 @@ ColumnUDA::ColumnUDA ()
|
||||||
_style = "default";
|
_style = "default";
|
||||||
_label = "";
|
_label = "";
|
||||||
_uda = true;
|
_uda = true;
|
||||||
|
|
||||||
_hyphenate = (_type == "string") ? true : false;
|
_hyphenate = (_type == "string") ? true : false;
|
||||||
|
_styles = {_style, "indicator"};
|
||||||
_styles.push_back (_style);
|
|
||||||
_styles.push_back ("indicator");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
|
@ -41,12 +41,8 @@ ColumnUUID::ColumnUUID ()
|
||||||
_style = "long";
|
_style = "long";
|
||||||
_label = STRING_COLUMN_LABEL_UUID;
|
_label = STRING_COLUMN_LABEL_UUID;
|
||||||
_modifiable = false;
|
_modifiable = false;
|
||||||
|
_styles = {"long", "short"};
|
||||||
_styles.push_back ("long");
|
_examples = {"f30cb9c3-3fc0-483f-bfb2-3bf134f00694", "f30cb9c3"};
|
||||||
_styles.push_back ("short");
|
|
||||||
|
|
||||||
_examples.push_back ("f30cb9c3-3fc0-483f-bfb2-3bf134f00694");
|
|
||||||
_examples.push_back ("f30cb9c3");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
|
@ -39,12 +39,8 @@ ColumnUrgency::ColumnUrgency ()
|
||||||
_type = "numeric";
|
_type = "numeric";
|
||||||
_style = "real";
|
_style = "real";
|
||||||
_label = STRING_COLUMN_LABEL_URGENCY;
|
_label = STRING_COLUMN_LABEL_URGENCY;
|
||||||
|
_styles = {"real", "integer"};
|
||||||
_styles.push_back ("real");
|
_examples = {"4.6", "4"};
|
||||||
_styles.push_back ("integer");
|
|
||||||
|
|
||||||
_examples.push_back ("4.6");
|
|
||||||
_examples.push_back ("4");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
18
src/util.cpp
18
src/util.cpp
|
@ -65,9 +65,8 @@ extern Context context;
|
||||||
// std::getline, the newline can be detected, and the prompt re-written.
|
// std::getline, the newline can be detected, and the prompt re-written.
|
||||||
bool confirm (const std::string& question)
|
bool confirm (const std::string& question)
|
||||||
{
|
{
|
||||||
std::vector <std::string> options;
|
std::vector <std::string> options {STRING_UTIL_CONFIRM_YES,
|
||||||
options.push_back (STRING_UTIL_CONFIRM_YES);
|
STRING_UTIL_CONFIRM_NO};
|
||||||
options.push_back (STRING_UTIL_CONFIRM_NO);
|
|
||||||
|
|
||||||
std::string answer;
|
std::string answer;
|
||||||
std::vector <std::string> matches;
|
std::vector <std::string> matches;
|
||||||
|
@ -94,13 +93,12 @@ bool confirm (const std::string& question)
|
||||||
// 3 = quit
|
// 3 = quit
|
||||||
int confirm4 (const std::string& question)
|
int confirm4 (const std::string& question)
|
||||||
{
|
{
|
||||||
std::vector <std::string> options;
|
std::vector <std::string> options {STRING_UTIL_CONFIRM_YES_U,
|
||||||
options.push_back (STRING_UTIL_CONFIRM_YES_U);
|
STRING_UTIL_CONFIRM_YES,
|
||||||
options.push_back (STRING_UTIL_CONFIRM_YES);
|
STRING_UTIL_CONFIRM_NO,
|
||||||
options.push_back (STRING_UTIL_CONFIRM_NO);
|
STRING_UTIL_CONFIRM_ALL_U,
|
||||||
options.push_back (STRING_UTIL_CONFIRM_ALL_U);
|
STRING_UTIL_CONFIRM_ALL,
|
||||||
options.push_back (STRING_UTIL_CONFIRM_ALL);
|
STRING_UTIL_CONFIRM_QUIT};
|
||||||
options.push_back (STRING_UTIL_CONFIRM_QUIT);
|
|
||||||
|
|
||||||
std::string answer;
|
std::string answer;
|
||||||
std::vector <std::string> matches;
|
std::vector <std::string> matches;
|
||||||
|
|
|
@ -42,13 +42,7 @@ int main (int argc, char** argv)
|
||||||
unsetenv ("TASKDATA");
|
unsetenv ("TASKDATA");
|
||||||
unsetenv ("TASKRC");
|
unsetenv ("TASKRC");
|
||||||
|
|
||||||
std::vector <std::string> options;
|
std::vector <std::string> options {"abc", "abcd", "abcde", "bcdef", "cdefg"};
|
||||||
options.push_back ("abc");
|
|
||||||
options.push_back ("abcd");
|
|
||||||
options.push_back ("abcde");
|
|
||||||
options.push_back ("bcdef");
|
|
||||||
options.push_back ("cdefg");
|
|
||||||
|
|
||||||
std::vector <std::string> matches;
|
std::vector <std::string> matches;
|
||||||
int result = autoComplete ("", options, matches);
|
int result = autoComplete ("", options, matches);
|
||||||
t.is (result, 0, "no match on empty string");
|
t.is (result, 0, "no match on empty string");
|
||||||
|
|
|
@ -43,21 +43,9 @@ int main (int argc, char** argv)
|
||||||
unsetenv ("TASKRC");
|
unsetenv ("TASKRC");
|
||||||
|
|
||||||
// 1,2,3 <=> 2,3,4
|
// 1,2,3 <=> 2,3,4
|
||||||
std::vector <std::string> string_one;
|
std::vector <std::string> string_one {"1", "2", "3"};
|
||||||
string_one.push_back ("1");
|
std::vector <std::string> string_two {"2", "3", "4"};
|
||||||
string_one.push_back ("2");
|
std::vector <std::string> string_three {"2", "3", "4"};
|
||||||
string_one.push_back ("3");
|
|
||||||
|
|
||||||
std::vector <std::string> string_two;
|
|
||||||
string_two.push_back ("2");
|
|
||||||
string_two.push_back ("3");
|
|
||||||
string_two.push_back ("4");
|
|
||||||
|
|
||||||
std::vector <std::string> string_three;
|
|
||||||
string_three.push_back ("2");
|
|
||||||
string_three.push_back ("3");
|
|
||||||
string_three.push_back ("4");
|
|
||||||
|
|
||||||
std::vector <std::string> string_four;
|
std::vector <std::string> string_four;
|
||||||
|
|
||||||
// Differences?
|
// Differences?
|
||||||
|
@ -87,21 +75,9 @@ int main (int argc, char** argv)
|
||||||
// Now do it all again, with integers.
|
// Now do it all again, with integers.
|
||||||
|
|
||||||
// 1,2,3 <=> 2,3,4
|
// 1,2,3 <=> 2,3,4
|
||||||
std::vector <int> int_one;
|
std::vector <int> int_one {1, 2, 3};
|
||||||
int_one.push_back (1);
|
std::vector <int> int_two {2, 3, 4};
|
||||||
int_one.push_back (2);
|
std::vector <int> int_three {2, 3, 4};
|
||||||
int_one.push_back (3);
|
|
||||||
|
|
||||||
std::vector <int> int_two;
|
|
||||||
int_two.push_back (2);
|
|
||||||
int_two.push_back (3);
|
|
||||||
int_two.push_back (4);
|
|
||||||
|
|
||||||
std::vector <int> int_three;
|
|
||||||
int_three.push_back (2);
|
|
||||||
int_three.push_back (3);
|
|
||||||
int_three.push_back (4);
|
|
||||||
|
|
||||||
std::vector <int> int_four;
|
std::vector <int> int_four;
|
||||||
|
|
||||||
// Differences?
|
// Differences?
|
||||||
|
|
|
@ -634,9 +634,7 @@ int main (int argc, char** argv)
|
||||||
|
|
||||||
// bool getOneOf (const std::vector <std::string>&, std::string&);
|
// bool getOneOf (const std::vector <std::string>&, std::string&);
|
||||||
t.diag ("Nibbler::getOneOf");
|
t.diag ("Nibbler::getOneOf");
|
||||||
options.push_back ("one");
|
options = {"one", "two", "three"};
|
||||||
options.push_back ("two");
|
|
||||||
options.push_back ("three");
|
|
||||||
n = Nibbler ("onetwothreefour");
|
n = Nibbler ("onetwothreefour");
|
||||||
t.ok (n.getOneOf (options, s), "'onetwothreefour': getOneOf () -> true");
|
t.ok (n.getOneOf (options, s), "'onetwothreefour': getOneOf () -> true");
|
||||||
t.is (s, "one", "'onetwothreefour': getOneOf () -> one");
|
t.is (s, "one", "'onetwothreefour': getOneOf () -> one");
|
||||||
|
|
|
@ -171,10 +171,7 @@ int main (int argc, char** argv)
|
||||||
t.is (joined.length (), (size_t) 0, "join -> length 0");
|
t.is (joined.length (), (size_t) 0, "join -> length 0");
|
||||||
t.is (joined, "", "join -> ''");
|
t.is (joined, "", "join -> ''");
|
||||||
|
|
||||||
unjoined.push_back ("");
|
unjoined = {"", "a", "bc", "def"};
|
||||||
unjoined.push_back ("a");
|
|
||||||
unjoined.push_back ("bc");
|
|
||||||
unjoined.push_back ("def");
|
|
||||||
join (joined, "", unjoined);
|
join (joined, "", unjoined);
|
||||||
t.is (joined.length (), (size_t) 6, "join '' 'a' 'bc' 'def' -> length 6");
|
t.is (joined.length (), (size_t) 6, "join '' 'a' 'bc' 'def' -> length 6");
|
||||||
t.is (joined, "abcdef", "join '' 'a' 'bc' 'def' -> 'abcdef'");
|
t.is (joined, "abcdef", "join '' 'a' 'bc' 'def' -> 'abcdef'");
|
||||||
|
@ -190,9 +187,7 @@ int main (int argc, char** argv)
|
||||||
t.is (joined.length (), (size_t) 0, "join -> length 0");
|
t.is (joined.length (), (size_t) 0, "join -> length 0");
|
||||||
t.is (joined, "", "join -> ''");
|
t.is (joined, "", "join -> ''");
|
||||||
|
|
||||||
unjoined2.push_back (0);
|
unjoined2 = {0, 1, 2};
|
||||||
unjoined2.push_back (1);
|
|
||||||
unjoined2.push_back (2);
|
|
||||||
join (joined, "", unjoined2);
|
join (joined, "", unjoined2);
|
||||||
t.is (joined.length (), (size_t) 3, "join 0 1 2 -> length 3");
|
t.is (joined.length (), (size_t) 3, "join 0 1 2 -> length 3");
|
||||||
t.is (joined, "012", "join 0 1 2 -> '012'");
|
t.is (joined, "012", "join 0 1 2 -> '012'");
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue