mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-07-07 20:06:36 +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
|
@ -42,13 +42,7 @@ int main (int argc, char** argv)
|
|||
unsetenv ("TASKDATA");
|
||||
unsetenv ("TASKRC");
|
||||
|
||||
std::vector <std::string> options;
|
||||
options.push_back ("abc");
|
||||
options.push_back ("abcd");
|
||||
options.push_back ("abcde");
|
||||
options.push_back ("bcdef");
|
||||
options.push_back ("cdefg");
|
||||
|
||||
std::vector <std::string> options {"abc", "abcd", "abcde", "bcdef", "cdefg"};
|
||||
std::vector <std::string> matches;
|
||||
int result = autoComplete ("", options, matches);
|
||||
t.is (result, 0, "no match on empty string");
|
||||
|
|
|
@ -43,21 +43,9 @@ int main (int argc, char** argv)
|
|||
unsetenv ("TASKRC");
|
||||
|
||||
// 1,2,3 <=> 2,3,4
|
||||
std::vector <std::string> string_one;
|
||||
string_one.push_back ("1");
|
||||
string_one.push_back ("2");
|
||||
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_one {"1", "2", "3"};
|
||||
std::vector <std::string> string_two {"2", "3", "4"};
|
||||
std::vector <std::string> string_three {"2", "3", "4"};
|
||||
std::vector <std::string> string_four;
|
||||
|
||||
// Differences?
|
||||
|
@ -87,21 +75,9 @@ int main (int argc, char** argv)
|
|||
// Now do it all again, with integers.
|
||||
|
||||
// 1,2,3 <=> 2,3,4
|
||||
std::vector <int> int_one;
|
||||
int_one.push_back (1);
|
||||
int_one.push_back (2);
|
||||
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_one {1, 2, 3};
|
||||
std::vector <int> int_two {2, 3, 4};
|
||||
std::vector <int> int_three {2, 3, 4};
|
||||
std::vector <int> int_four;
|
||||
|
||||
// Differences?
|
||||
|
|
|
@ -634,9 +634,7 @@ int main (int argc, char** argv)
|
|||
|
||||
// bool getOneOf (const std::vector <std::string>&, std::string&);
|
||||
t.diag ("Nibbler::getOneOf");
|
||||
options.push_back ("one");
|
||||
options.push_back ("two");
|
||||
options.push_back ("three");
|
||||
options = {"one", "two", "three"};
|
||||
n = Nibbler ("onetwothreefour");
|
||||
t.ok (n.getOneOf (options, s), "'onetwothreefour': getOneOf () -> true");
|
||||
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, "", "join -> ''");
|
||||
|
||||
unjoined.push_back ("");
|
||||
unjoined.push_back ("a");
|
||||
unjoined.push_back ("bc");
|
||||
unjoined.push_back ("def");
|
||||
unjoined = {"", "a", "bc", "def"};
|
||||
join (joined, "", unjoined);
|
||||
t.is (joined.length (), (size_t) 6, "join '' 'a' 'bc' 'def' -> length 6");
|
||||
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, "", "join -> ''");
|
||||
|
||||
unjoined2.push_back (0);
|
||||
unjoined2.push_back (1);
|
||||
unjoined2.push_back (2);
|
||||
unjoined2 = {0, 1, 2};
|
||||
join (joined, "", unjoined2);
|
||||
t.is (joined.length (), (size_t) 3, "join 0 1 2 -> length 3");
|
||||
t.is (joined, "012", "join 0 1 2 -> '012'");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue