From 64bf571c13171ec03dc82688543529f9a1ea64fe Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Wed, 28 Oct 2015 20:51:31 -0400 Subject: [PATCH] =?UTF-8?q?List:=20Removed=20unused=20listDiff=20and=20li?= =?UTF-8?q?=D1=95tIntersect=20templates=20and=20tests?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main.h | 31 ------------------------------- test/list.t.cpp | 37 +------------------------------------ 2 files changed, 1 insertion(+), 67 deletions(-) diff --git a/src/main.h b/src/main.h index ea59fce2b..f77982903 100644 --- a/src/main.h +++ b/src/main.h @@ -83,19 +83,6 @@ std::string legacyCheckForDeprecatedColumns (); void legacyAttributeMap (std::string&); // list template -/////////////////////////////////////////////////////////////////////////////// -template 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 void listDiff ( const T& left, const T& right, T& leftOnly, T& rightOnly) @@ -136,23 +123,5 @@ template void listDiff ( } } -//////////////////////////////////////////////////////////////////////////////// -template 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 //////////////////////////////////////////////////////////////////////////////// diff --git a/test/list.t.cpp b/test/list.t.cpp index f1ae917a0..3fe4fafba 100644 --- a/test/list.t.cpp +++ b/test/list.t.cpp @@ -27,20 +27,13 @@ #include #include #include -#include #include #include -Context context; - //////////////////////////////////////////////////////////////////////////////// int main (int, char**) { - UnitTest t (24); - - // Ensure environment has no influence. - unsetenv ("TASKDATA"); - unsetenv ("TASKRC"); + UnitTest t (8); // 1,2,3 <=> 2,3,4 std::vector string_one {"1", "2", "3"}; @@ -48,13 +41,6 @@ int main (int, char**) std::vector string_three {"2", "3", "4"}; std::vector 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? std::vector string_leftOnly; std::vector 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 (string_rightOnly[0], "4", "std::string (1,2,3) <=> (2,3,4) = ->4"); - // What is the intersection? - std::vector 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. // 1,2,3 <=> 2,3,4 @@ -80,13 +59,6 @@ int main (int, char**) std::vector int_three {2, 3, 4}; std::vector 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? std::vector int_leftOnly; std::vector 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_rightOnly[0], "4", "int (1,2,3) <=> (2,3,4) = ->4"); - // What is the intersection? - std::vector 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; }