Skip to content

Commit

Permalink
fixing unittest memory leak
Browse files Browse the repository at this point in the history
  • Loading branch information
shajoezhu committed Nov 16, 2018
1 parent 4d73536 commit 600cd16
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ io_unit_tests_LDADD = -lcppunit -ldl $(common_LDADD)

current_unit_tests_SOURCES = $(common_src) \
tests/unittest/test_runner.cpp \
tests/unittest/test_vcfReader.cpp
tests/unittest/test_mcmc.cpp

current_unit_tests_CXXFLAGS = $(common_flags) -DNDEBUG -DUNITTEST -Wno-write-strings --coverage
current_unit_tests_LDADD = -lcppunit -ldl $(common_LDADD)
Expand Down
2 changes: 1 addition & 1 deletion tests/test_binary.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ function test_dEploid {
valgrind --error-exitcode=1 --leak-check=full -q --gen-suppressions=yes ./dEploid $@ -seed $i > /dev/null
if [ $? -ne 0 ]; then
echo ""
echo "Valgrind check of \"./dEploid $@ -seed $i\" failed."
echo "Valgrind check of \"valgrind --error-exitcode=1 --leak-check=full -q --gen-suppressions=yes ./dEploid $@ -seed $i\" failed."
exit 1
fi

Expand Down
8 changes: 4 additions & 4 deletions tests/unittest/test_mcmc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -332,15 +332,15 @@ class TestMcmcMachinery: public CppUnit::TestCase {
CPPUNIT_ASSERT_EQUAL(nRepeat, this->mcmcMachinery_->mcmcSample_->proportion.size());
CPPUNIT_ASSERT_EQUAL(nRepeat, this->mcmcMachinery_->mcmcSample_->sumLLKs.size());
CPPUNIT_ASSERT_EQUAL(nRepeat, this->mcmcMachinery_->mcmcSample_->moves.size());
vector <size_t> counter(3, 0);
vector <size_t> counter(4, 0);
for(size_t i = 0; i < nRepeat; i++) {
counter[this->mcmcMachinery_->mcmcSample_->moves[i]] += 1;
}
for(size_t i = 0; i < 3; i++) {
CPPUNIT_ASSERT_DOUBLES_EQUAL(0.333333,(double)counter[i]/(double)nRepeat, epsilon2);
for(size_t i = 0; i < 4; i++) {
CPPUNIT_ASSERT_DOUBLES_EQUAL(0.25,(double)counter[i]/(double)nRepeat, epsilon2);
}

// IBD
//// IBD
CPPUNIT_ASSERT_NO_THROW(this->mcmcMachineryIbd_->setKstrain(3));
CPPUNIT_ASSERT_NO_THROW(this->mcmcMachineryIbd_->calcMaxIteration(100, 1, 0.5));
CPPUNIT_ASSERT_NO_THROW(this->mcmcMachineryIbd_->runMcmcChain(true, true));
Expand Down

0 comments on commit 600cd16

Please sign in to comment.