mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-08-20 13:23:08 +02:00
Utils - combine
- Implemented combine, which takes two integer vectors and combines them resulting in a single vector contianing the unique values of both.
This commit is contained in:
parent
8fabffe18c
commit
8f85b0e194
3 changed files with 50 additions and 1 deletions
|
@ -34,7 +34,7 @@ Context context;
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
int main (int argc, char** argv)
|
||||
{
|
||||
UnitTest t (19);
|
||||
UnitTest t (30);
|
||||
|
||||
// TODO bool confirm (const std::string&);
|
||||
// TODO int confirm3 (const std::string&);
|
||||
|
@ -85,6 +85,33 @@ int main (int argc, char** argv)
|
|||
output = taskDifferences (right, rightAgain);
|
||||
t.ok (output.find ("No changes will be made") != std::string::npos, "No changes detected");
|
||||
|
||||
// void combine (std::vector <int>&, const std::vector <int>&);
|
||||
std::vector <int> vleft;
|
||||
vleft.push_back (1);
|
||||
vleft.push_back (2);
|
||||
vleft.push_back (3);
|
||||
|
||||
std::vector <int> vright;
|
||||
vright.push_back (4);
|
||||
|
||||
combine (vleft, vright);
|
||||
t.is (vleft.size (), (size_t)4, "1,2,3 + 4 -> [4]");
|
||||
t.is (vleft[0], 1, "1,2,3 + 4 -> 1,2,3,4");
|
||||
t.is (vleft[1], 2, "1,2,3 + 4 -> 1,2,3,4");
|
||||
t.is (vleft[2], 3, "1,2,3 + 4 -> 1,2,3,4");
|
||||
t.is (vleft[3], 4, "1,2,3 + 4 -> 1,2,3,4");
|
||||
|
||||
vright.push_back (3);
|
||||
vright.push_back (5);
|
||||
combine (vleft, vright);
|
||||
|
||||
t.is (vleft.size (), (size_t)5, "1,2,3,4 + 3,4,5 -> [5]");
|
||||
t.is (vleft[0], 1, "1,2,3,4 + 3,4,5 -> 1,2,3,4,5");
|
||||
t.is (vleft[1], 2, "1,2,3,4 + 3,4,5 -> 1,2,3,4,5");
|
||||
t.is (vleft[2], 3, "1,2,3,4 + 3,4,5 -> 1,2,3,4,5");
|
||||
t.is (vleft[3], 4, "1,2,3,4 + 3,4,5 -> 1,2,3,4,5");
|
||||
t.is (vleft[4], 5, "1,2,3,4 + 3,4,5 -> 1,2,3,4,5");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue