+#define BOOST_AUTO_TEST_MAIN
#include <boost/test/auto_unit_test.hpp>
#include <boost/filesystem/path.hpp>
#include <boost/filesystem/operations.hpp>
BOOST_CHECK_EQUAL(s.get_sequence(), std::string() );
}
+BOOST_AUTO_TEST_CASE( sequence_from_string )
+{
+ std::string str1("AAAT");
+ Sequence seq1(str1);
+ BOOST_CHECK_EQUAL(seq1.get_sequence(), str1);
+}
+
+BOOST_AUTO_TEST_CASE( sequence_find_first_not_of )
+{
+ std::string str1("AAAAT");
+ Sequence seq1(str1);
+ BOOST_CHECK_EQUAL(seq1.find_first_not_of("A"), str1.find_first_not_of("A"));
+
+ std::string str2("AATTGGCC");
+ Sequence seq2(str2);
+ BOOST_CHECK_EQUAL(seq2.find_first_not_of("qwer"), str2.find_first_not_of("qwer"));
+}
+
//! when we try to load a missing file, do we get an error?
BOOST_AUTO_TEST_CASE( sequence_load_exception )
{
"5' flank");
}
-BOOST_AUTO_TEST_CASE( sequence_load_error )
+BOOST_AUTO_TEST_CASE( sequence_load_fasta_error )
{
fs::path seq_path(fs::path(EXAMPLE_DIR, fs::native)/"seq");
seq_path /= "broken.fa";
BOOST_CHECK_EQUAL(seq_path.native_file_string(), exception_filename);
}
+BOOST_AUTO_TEST_CASE( sequence_load_annot_error )
+{
+ fs::path seq_path(fs::path(EXAMPLE_DIR, fs::native)/"seq");
+ seq_path /= "mouse_mck_pro.fa";
+ fs::path annot_path(fs::path(EXAMPLE_DIR, fs::native));
+ annot_path /= "broken.annot";
+ bool exception_thrown = false;
+ Sequence s;
+ s.load_fasta(seq_path);
+
+ std::string exception_filename;
+ try {
+ s.load_annot(annot_path, 0, 0);
+ } catch(annotation_load_error e) {
+ exception_thrown = true;
+ std:string estr(e.what());
+ size_t native_string_size = annot_path.native_file_string().size();
+ BOOST_REQUIRE(estr.size() > native_string_size);
+ std::copy(estr.begin(), estr.begin()+native_string_size,
+ std::back_inserter(exception_filename));
+ }
+ BOOST_CHECK_EQUAL(exception_thrown, true);
+ BOOST_CHECK_EQUAL(annot_path.native_file_string(), exception_filename);
+}
+
BOOST_AUTO_TEST_CASE( sequence_load_dna_reduced )
{
std::string reduced_dna_fasta_string(">foo\nAAGGCCTTNN\n");
BOOST_CHECK_EQUAL(seq1_loaded, seq1);
BOOST_CHECK_EQUAL(seq2_loaded, seq2);
// test if our pointers are the same
- BOOST_CHECK_EQUAL(seq1_loaded.c_str(), seq2_loaded.c_str());
+ BOOST_CHECK_EQUAL(seq1_loaded.data(), seq2_loaded.data());
}