conditionally build the paircomp tests
authorDiane Trout <diane@caltech.edu>
Thu, 4 Jan 2007 22:34:37 +0000 (22:34 +0000)
committerDiane Trout <diane@caltech.edu>
Thu, 4 Jan 2007 22:34:37 +0000 (22:34 +0000)
alg/test/CMakeLists.txt
alg/test/test_paircomp.cpp [new file with mode: 0644]

index 39815c2ab80a210ff2b94789343168200d67d3fc..cd61835f6cb9249fa54bf6a8d366dcd4095615ee 100644 (file)
@@ -30,7 +30,7 @@ MACRO(MAKE_ALG_UNITTEST basename)
       COMPILE_FLAGS "-DEXAMPLE_DIR=\\\"${EXAMPLE_DIR}\\\" ${ALG_TEST_CFLAGS}"
   )
   ADD_EXECUTABLE(${basename} ${${basename}_SRC})
-  TARGET_LINK_LIBRARIES(${basename} ${ALG_TEST_LIBS}) # ${${basename}_extra_libs})
+  TARGET_LINK_LIBRARIES(${basename} ${ALG_TEST_LIBS})
   
   SET_TARGET_PROPERTIES(
     ${basename}
@@ -53,3 +53,9 @@ MAKE_ALG_UNITTEST( test_mussa )
 MAKE_ALG_UNITTEST( test_nway )
 MAKE_ALG_UNITTEST( test_sequence )
 MAKE_ALG_UNITTEST( test_sequence_location )
+
+IF(USE_PAIRCOMP)
+  INCLUDE_DIRECTORIES( ${CMAKE_SOURCE_DIR}/paircomp/lib )
+  MAKE_ALG_UNITTEST( test_paircomp )
+  TARGET_LINK_LIBRARIES( test_paircomp paircomplib )
+ENDIF(USE_PAIRCOMP)
diff --git a/alg/test/test_paircomp.cpp b/alg/test/test_paircomp.cpp
new file mode 100644 (file)
index 0000000..045c7e2
--- /dev/null
@@ -0,0 +1,47 @@
+#define BOOST_AUTO_TEST_MAIN
+#include <boost/test/auto_unit_test.hpp>
+#include <boost/filesystem/path.hpp>
+namespace fs = boost::filesystem;
+
+#include <string>
+#include <iostream>
+
+#include "alg/sequence.hpp"
+#include "paircomp.hh"
+
+using namespace std;
+
+BOOST_AUTO_TEST_CASE( simple_nxn_comparison )
+{
+  std::string s(10, 'A');
+  Sequence s1(s);
+  Sequence s2(s);
+  
+  paircomp::ImmutableComparison *cmp;
+  // Make sure we called the string constructor correctly
+  BOOST_REQUIRE_EQUAL( s1.size(), 10 );
+  BOOST_REQUIRE_EQUAL( s2.size(), 10 );
+  cmp = paircomp::simple_nxn_comparison<Sequence>(s1, s2, 10, 0.10);
+  
+  BOOST_CHECK_EQUAL( cmp->is_empty(), false);
+  const paircomp::_MatchContainer *matches = cmp->get_matches(0);
+  BOOST_REQUIRE( matches != 0);
+  BOOST_CHECK_EQUAL( matches->num, 1 );
+}
+
+BOOST_AUTO_TEST_CASE( simple_nxn_comparison_mixed_case )
+{
+  Sequence s1("AtGGcT");
+  Sequence s2("aTggCt");
+  
+  paircomp::ImmutableComparison *cmp;
+  // Make sure we called the string constructor correctly
+  BOOST_REQUIRE_EQUAL( s1.size(), 6 );
+  BOOST_REQUIRE_EQUAL( s2.size(), 6 );
+  cmp = paircomp::simple_nxn_comparison<Sequence>(s1, s2, 6, 1.0);
+  
+  BOOST_CHECK_EQUAL( cmp->is_empty(), false);
+  const paircomp::_MatchContainer *matches = cmp->get_matches(0);
+  BOOST_REQUIRE( matches != 0);
+  BOOST_CHECK_EQUAL( matches->num, 1 );  
+}
\ No newline at end of file