From 6317e56b965b35eb20abbd3c383cba487908bf39 Mon Sep 17 00:00:00 2001 From: Diane Trout Date: Wed, 4 Apr 2007 01:08:29 +0000 Subject: [PATCH] fix uninitialized pointer ticket:256 I forgot to initialize the motif_list pointer in one of the Sequence constructors. Unfortunately it was the one that was used by the mussa load_sequence code, which hadn't been tested. this patch adds a test, and fixes the reported problem. --- alg/sequence.cpp | 3 ++- alg/test/test_mussa.cpp | 11 +++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/alg/sequence.cpp b/alg/sequence.cpp index ecbc633..6cb4e2c 100644 --- a/alg/sequence.cpp +++ b/alg/sequence.cpp @@ -80,7 +80,8 @@ motif::~motif() Sequence::Sequence(AlphabetRef alphabet) - : seq(new SeqSpan("", alphabet, SeqSpan::PlusStrand)) + : seq(new SeqSpan("", alphabet, SeqSpan::PlusStrand)), + motif_list(new MotifList) { } diff --git a/alg/test/test_mussa.cpp b/alg/test/test_mussa.cpp index 1606847..55188ea 100644 --- a/alg/test/test_mussa.cpp +++ b/alg/test/test_mussa.cpp @@ -152,6 +152,17 @@ BOOST_AUTO_TEST_CASE( mussa_load_full_path ) BOOST_CHECK_EQUAL( m1.is_dirty(), true); BOOST_CHECK_EQUAL( m1.get_analysis_path().string(), ""); } + +BOOST_AUTO_TEST_CASE( mussa_valid_motifs_in_new_analysis ) +{ + Mussa m1; + fs::path full_path(fs::path(EXAMPLE_DIR, fs::native) / "mck3test.mupa"); + m1.load_mupa_file( full_path ); + m1.analyze(); + // check motifs + BOOST_CHECK( m1.sequences().size() > 0 ); + BOOST_CHECK_EQUAL( m1.sequences()[0]->motifs().size(), 0 ); +} // make sure we know that mupa files cannot be directories BOOST_AUTO_TEST_CASE( mussa_mupa_is_file_not_directory ) -- 2.30.2