mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-08-28 04:27:20 +02:00
List: Removed unused listDiff and liѕtIntersect templates and tests
This commit is contained in:
parent
af49564194
commit
64bf571c13
2 changed files with 1 additions and 67 deletions
31
src/main.h
31
src/main.h
|
@ -83,19 +83,6 @@ std::string legacyCheckForDeprecatedColumns ();
|
||||||
void legacyAttributeMap (std::string&);
|
void legacyAttributeMap (std::string&);
|
||||||
|
|
||||||
// list template
|
// list template
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
|
||||||
template <class T> bool listDiff (const T& left, const T& right)
|
|
||||||
{
|
|
||||||
if (left.size () != right.size ())
|
|
||||||
return true;
|
|
||||||
|
|
||||||
for (unsigned int i = 0; i < left.size (); ++i)
|
|
||||||
if (left[i] != right[i])
|
|
||||||
return true;
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
template <class T> void listDiff (
|
template <class T> void listDiff (
|
||||||
const T& left, const T& right, T& leftOnly, T& rightOnly)
|
const T& left, const T& right, T& leftOnly, T& rightOnly)
|
||||||
|
@ -136,23 +123,5 @@ template <class T> void listDiff (
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
template <class T> void listIntersect (const T& left, const T& right, T& join)
|
|
||||||
{
|
|
||||||
join.clear ();
|
|
||||||
|
|
||||||
for (unsigned int l = 0; l < left.size (); ++l)
|
|
||||||
{
|
|
||||||
for (unsigned int r = 0; r < right.size (); ++r)
|
|
||||||
{
|
|
||||||
if (left[l] == right[r])
|
|
||||||
{
|
|
||||||
join.push_back (left[l]);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
|
@ -27,20 +27,13 @@
|
||||||
#include <cmake.h>
|
#include <cmake.h>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <Context.h>
|
|
||||||
#include <main.h>
|
#include <main.h>
|
||||||
#include <test.h>
|
#include <test.h>
|
||||||
|
|
||||||
Context context;
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
int main (int, char**)
|
int main (int, char**)
|
||||||
{
|
{
|
||||||
UnitTest t (24);
|
UnitTest t (8);
|
||||||
|
|
||||||
// Ensure environment has no influence.
|
|
||||||
unsetenv ("TASKDATA");
|
|
||||||
unsetenv ("TASKRC");
|
|
||||||
|
|
||||||
// 1,2,3 <=> 2,3,4
|
// 1,2,3 <=> 2,3,4
|
||||||
std::vector <std::string> string_one {"1", "2", "3"};
|
std::vector <std::string> string_one {"1", "2", "3"};
|
||||||
|
@ -48,13 +41,6 @@ int main (int, char**)
|
||||||
std::vector <std::string> string_three {"2", "3", "4"};
|
std::vector <std::string> string_three {"2", "3", "4"};
|
||||||
std::vector <std::string> string_four;
|
std::vector <std::string> string_four;
|
||||||
|
|
||||||
// Differences?
|
|
||||||
t.ok (!listDiff (string_one, string_one), "std::string (1,2,3) == (1,2,3)");
|
|
||||||
t.ok (listDiff (string_one, string_two), "std::string (1,2,3) != (2,3,4)");
|
|
||||||
t.ok (listDiff (string_one, string_three), "std::string (1,2,3) != (2,3,4)");
|
|
||||||
t.ok (listDiff (string_one, string_four), "std::string (1,2,3) != ()");
|
|
||||||
t.ok (!listDiff (string_four, string_four), "std::string () == ()");
|
|
||||||
|
|
||||||
// What are the differences?
|
// What are the differences?
|
||||||
std::vector<std::string> string_leftOnly;
|
std::vector<std::string> string_leftOnly;
|
||||||
std::vector<std::string> string_rightOnly;
|
std::vector<std::string> string_rightOnly;
|
||||||
|
@ -65,13 +51,6 @@ int main (int, char**)
|
||||||
t.is ((int) string_rightOnly.size (), 1, "std::string (1,2,3) <=> (2,3,4) = ->4");
|
t.is ((int) string_rightOnly.size (), 1, "std::string (1,2,3) <=> (2,3,4) = ->4");
|
||||||
t.is (string_rightOnly[0], "4", "std::string (1,2,3) <=> (2,3,4) = ->4");
|
t.is (string_rightOnly[0], "4", "std::string (1,2,3) <=> (2,3,4) = ->4");
|
||||||
|
|
||||||
// What is the intersection?
|
|
||||||
std::vector <std::string> string_join;
|
|
||||||
listIntersect (string_one, string_two, string_join);
|
|
||||||
t.is ((int) string_join.size (), 2, "std::string (1,2,3) intersect (2,3,4) = (2,3)");
|
|
||||||
t.is (string_join[0], "2", "std::string (1,2,3) intersect (2,3,4) = (2,3)");
|
|
||||||
t.is (string_join[1], "3", "std::string (1,2,3) intersect (2,3,4) = (2,3)");
|
|
||||||
|
|
||||||
// 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
|
||||||
|
@ -80,13 +59,6 @@ int main (int, char**)
|
||||||
std::vector <int> int_three {2, 3, 4};
|
std::vector <int> int_three {2, 3, 4};
|
||||||
std::vector <int> int_four;
|
std::vector <int> int_four;
|
||||||
|
|
||||||
// Differences?
|
|
||||||
t.ok (!listDiff (int_one, int_one), "int (1,2,3) == (1,2,3)");
|
|
||||||
t.ok (listDiff (int_one, int_two), "int (1,2,3) != (2,3,4)");
|
|
||||||
t.ok (listDiff (int_one, int_three), "int (1,2,3) != (2,3,4)");
|
|
||||||
t.ok (listDiff (int_one, int_four), "int (1,2,3) != ()");
|
|
||||||
t.ok (!listDiff (int_four, int_four), "int () == ()");
|
|
||||||
|
|
||||||
// What are the differences?
|
// What are the differences?
|
||||||
std::vector<int> int_leftOnly;
|
std::vector<int> int_leftOnly;
|
||||||
std::vector<int> int_rightOnly;
|
std::vector<int> int_rightOnly;
|
||||||
|
@ -97,13 +69,6 @@ int main (int, char**)
|
||||||
t.is ((int) int_rightOnly.size (), 1, "int (1,2,3) <=> (2,3,4) = ->4");
|
t.is ((int) int_rightOnly.size (), 1, "int (1,2,3) <=> (2,3,4) = ->4");
|
||||||
t.is (int_rightOnly[0], "4", "int (1,2,3) <=> (2,3,4) = ->4");
|
t.is (int_rightOnly[0], "4", "int (1,2,3) <=> (2,3,4) = ->4");
|
||||||
|
|
||||||
// What is the intersection?
|
|
||||||
std::vector <int> int_join;
|
|
||||||
listIntersect (int_one, int_two, int_join);
|
|
||||||
t.is ((int) int_join.size (), 2, "int (1,2,3) intersect (2,3,4) = (2,3)");
|
|
||||||
t.is (int_join[0], "2", "int (1,2,3) intersect (2,3,4) = (2,3)");
|
|
||||||
t.is (int_join[1], "3", "int (1,2,3) intersect (2,3,4) = (2,3)");
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue