From 36c42a013b6711d13298b5152e40f77d71e6b6fc Mon Sep 17 00:00:00 2001 From: marco <marco@5a81b35b-ba03-0410-adc8-b2c5c5119f08> Date: Tue, 2 Mar 2010 12:32:14 +0000 Subject: [PATCH] make sure unit tests are actually executed git-svn-id: https://dng.biozentrum.unibas.ch/svn/openstructure/trunk@1751 5a81b35b-ba03-0410-adc8-b2c5c5119f08 --- modules/mol/base/tests/test_atom_groups.cc | 29 +-- modules/mol/base/tests/test_chain.cc | 87 ++++---- modules/mol/base/tests/test_conn.cc | 13 +- modules/mol/base/tests/test_coord_group.cc | 11 +- modules/mol/base/tests/test_entity.cc | 35 +-- modules/mol/base/tests/test_ics.cc | 87 ++------ modules/mol/base/tests/test_iterators.cc | 192 +++++++--------- modules/mol/base/tests/test_query.cc | 245 ++++++++------------- modules/mol/base/tests/test_residue.cc | 12 +- modules/mol/base/tests/test_signal.cc | 81 ------- modules/mol/base/tests/test_view.cc | 11 +- 11 files changed, 266 insertions(+), 537 deletions(-) delete mode 100644 modules/mol/base/tests/test_signal.cc diff --git a/modules/mol/base/tests/test_atom_groups.cc b/modules/mol/base/tests/test_atom_groups.cc index 6ddfbeea7..72835fa76 100644 --- a/modules/mol/base/tests/test_atom_groups.cc +++ b/modules/mol/base/tests/test_atom_groups.cc @@ -29,7 +29,10 @@ using namespace ost; using namespace ost::mol; -void test_switch_pos() { +BOOST_AUTO_TEST_SUITE(mol_base) + +BOOST_AUTO_TEST_CASE(switch_pos) +{ test::DummyEnt ent; geom::Vec3 y=geom::Vec3(0.0, 1.0, 0.0); geom::Vec3 z=geom::Vec3(0.0, 0.0, 1.0); @@ -49,8 +52,8 @@ void test_switch_pos() { BOOST_CHECK(ent.r.SwitchAtomPos("A")); BOOST_CHECK_EQUAL(xx.GetPos(), geom::Vec3(0.0, 0.0, 0.0)); } - -void test_delete_atom() { +BOOST_AUTO_TEST_CASE(delete_atom) +{ test::DummyEnt ent; XCSEditor editor=ent.e.RequestXCSEditor(); AtomHandle xx=editor.InsertAltAtom(ent.r, "ZZ", "A", geom::Vec3(), @@ -67,9 +70,8 @@ void test_delete_atom() { BOOST_CHECK_EQUAL(ent.r.GetCurrentAltGroupName(), ""); BOOST_CHECK(ent.r.HasAltAtoms()==false); } - - -void test_atom_group_trivial() { +BOOST_AUTO_TEST_CASE(atom_group_triv) +{ test::DummyEnt ent; BOOST_CHECK(ent.r.HasAltAtoms()==false); BOOST_CHECK(ent.r.HasAltAtomGroup("")==false); @@ -86,19 +88,4 @@ void test_atom_group_trivial() { BOOST_CHECK_EQUAL(names[0], "B"); } -BOOST_AUTO_TEST_SUITE( mol_base ) - -BOOST_AUTO_TEST_CASE(switch_pos) -{ - test_switch_pos(); -} -BOOST_AUTO_TEST_CASE(delete_atom) -{ - test_delete_atom(); -} -BOOST_AUTO_TEST_CASE(atom_group_triv) -{ - test_atom_group_trivial(); -} - BOOST_AUTO_TEST_SUITE_END() diff --git a/modules/mol/base/tests/test_chain.cc b/modules/mol/base/tests/test_chain.cc index f511bec7e..e03c588a5 100644 --- a/modules/mol/base/tests/test_chain.cc +++ b/modules/mol/base/tests/test_chain.cc @@ -27,18 +27,6 @@ using namespace ost; using namespace ost::mol; -void test_comparison() -{ - EntityHandle eh=CreateEntity(); - XCSEditor e=eh.RequestXCSEditor(); - ChainHandle ch1=e.InsertChain("A"); - ChainHandle ch2=e.InsertChain("B"); - ChainHandle cc=ch1; - BOOST_CHECK(ch1!=ch2); - BOOST_CHECK(ch1==ch1); - BOOST_CHECK(cc==ch1); -} - void find_and_check_res(ChainHandle chain, const ResNum& n) { ResidueHandle fa=chain.FindResidue(n); BOOST_CHECK_MESSAGE(fa.IsValid(), "residue " << n << " not found"); @@ -83,7 +71,52 @@ void test_res_pos() { find_and_check_res(ch1, ResNum(13)); } -void test_res_pos_with_insertion_code() { +BOOST_AUTO_TEST_SUITE( mol_base ) + +BOOST_AUTO_TEST_CASE(test_comparison) +{ + EntityHandle eh=CreateEntity(); + XCSEditor e=eh.RequestXCSEditor(); + ChainHandle ch1=e.InsertChain("A"); + ChainHandle ch2=e.InsertChain("B"); + ChainHandle cc=ch1; + BOOST_CHECK(ch1!=ch2); + BOOST_CHECK(ch1==ch1); + BOOST_CHECK(cc==ch1); +} + + +BOOST_AUTO_TEST_CASE(res_pos) +{ + EntityHandle eh=CreateEntity(); + XCSEditor e=eh.RequestXCSEditor(); + ChainHandle ch1=e.InsertChain("A"); + e.AppendResidue(ch1, "A"); + e.AppendResidue(ch1, "B"); + e.AppendResidue(ch1, "C", ResNum(5)); + e.AppendResidue(ch1, "D"); + e.AppendResidue(ch1, "E", ResNum(9)); + e.AppendResidue(ch1, "F"); + e.AppendResidue(ch1, "E", ResNum(12)); + e.AppendResidue(ch1, "G"); + find_and_check_res(ch1, ResNum(1)); + find_and_check_res(ch1, ResNum(2)); + no_find_res(ch1, ResNum(3)); + no_find_res(ch1, ResNum(4)); + find_and_check_res(ch1, ResNum(5)); + find_and_check_res(ch1, ResNum(6)); + no_find_res(ch1, ResNum(7)); + no_find_res(ch1, ResNum(8)); + find_and_check_res(ch1, ResNum(9)); + find_and_check_res(ch1, ResNum(10)); + no_find_res(ch1, ResNum(11)); + find_and_check_res(ch1, ResNum(12)); + find_and_check_res(ch1, ResNum(13)); +} + + +BOOST_AUTO_TEST_CASE(res_pos_with_insertion_code) +{ EntityHandle eh=CreateEntity(); XCSEditor e=eh.RequestXCSEditor(); ChainHandle ch1=e.InsertChain("A"); @@ -112,8 +145,8 @@ void test_res_pos_with_insertion_code() { no_find_res(ch1, ResNum(10)); } - -void test_prev_next() { +BOOST_AUTO_TEST_CASE(prev_next) +{ EntityHandle eh=CreateEntity(); XCSEditor e=eh.RequestXCSEditor(); ChainHandle ch1=e.InsertChain("A"); @@ -131,28 +164,4 @@ void test_prev_next() { BOOST_CHECK(!ch1.GetNext(ResidueHandle()).IsValid()); } -BOOST_AUTO_TEST_SUITE( mol_base ) - -BOOST_AUTO_TEST_CASE(test_comparison) -{ - test_comparison(); -} - - -BOOST_AUTO_TEST_CASE(test_res_pos) -{ - test_res_pos(); -} - - -BOOST_AUTO_TEST_CASE(test_res_pos_with_insertion_code) -{ - test_res_pos_with_insertion_code(); -} - -BOOST_AUTO_TEST_CASE(test_prev_next) -{ - test_prev_next(); -} - BOOST_AUTO_TEST_SUITE_END() \ No newline at end of file diff --git a/modules/mol/base/tests/test_conn.cc b/modules/mol/base/tests/test_conn.cc index 3e05c6e22..b36e5f754 100644 --- a/modules/mol/base/tests/test_conn.cc +++ b/modules/mol/base/tests/test_conn.cc @@ -26,7 +26,10 @@ using namespace ost; using namespace ost::mol; -void test_connect() { +BOOST_AUTO_TEST_SUITE( mol_base ) + +BOOST_AUTO_TEST_CASE(connect) +{ EntityHandle e=CreateEntity(); XCSEditor editor=e.RequestXCSEditor(); ChainHandle c=editor.InsertChain("A"); @@ -51,14 +54,6 @@ void test_connect() { BOOST_CHECK(n.GetBondCount()==1); BOOST_CHECK(o.GetBondCount()==2); BOOST_CHECK(n.GetBondCount()==1); - -} - -BOOST_AUTO_TEST_SUITE( mol_base ) - -BOOST_AUTO_TEST_CASE(test_connect) -{ - test_connect(); } BOOST_AUTO_TEST_SUITE_END() \ No newline at end of file diff --git a/modules/mol/base/tests/test_coord_group.cc b/modules/mol/base/tests/test_coord_group.cc index 58d8de188..f2012b998 100644 --- a/modules/mol/base/tests/test_coord_group.cc +++ b/modules/mol/base/tests/test_coord_group.cc @@ -28,7 +28,9 @@ using namespace ost; using namespace ost::mol; -void test_coord_group() +BOOST_AUTO_TEST_SUITE( io ) + +BOOST_AUTO_TEST_CASE(coord_group) { EntityHandle e=CreateEntity(); XCSEditor editor=e.RequestXCSEditor(); @@ -79,11 +81,4 @@ void test_coord_group() BOOST_CHECK(ad.GetPos()==geom::Vec3(9,10,11)); } -BOOST_AUTO_TEST_SUITE( io ) - -BOOST_AUTO_TEST_CASE(test_coord_group) -{ - test_coord_group(); -} - BOOST_AUTO_TEST_SUITE_END() \ No newline at end of file diff --git a/modules/mol/base/tests/test_entity.cc b/modules/mol/base/tests/test_entity.cc index 9ca2e4153..bacd2f410 100644 --- a/modules/mol/base/tests/test_entity.cc +++ b/modules/mol/base/tests/test_entity.cc @@ -73,7 +73,9 @@ EntityHandle make_test_entity() return eh; } -void test_entity_creator() +BOOST_AUTO_TEST_SUITE( mol_base ) + +BOOST_AUTO_TEST_CASE(entity_creator) { EntityHandle eh = CreateEntity(); XCSEditor e=eh.RequestXCSEditor(); @@ -104,10 +106,9 @@ void test_entity_creator() EntityVisitor v; eh.Apply(v); - } -void test_spatial_organizer() +BOOST_AUTO_TEST_CASE(spatial_organizer) { EntityHandle eh=CreateEntity(); XCSEditor e=eh.RequestXCSEditor(); @@ -128,7 +129,7 @@ void test_spatial_organizer() BOOST_CHECK_EQUAL(std::count(ahv.begin(), ahv.end(), a5), 1); } -void test_transformation() +BOOST_AUTO_TEST_CASE(transformation) { EntityHandle eh = CreateEntity(); XCSEditor e=eh.RequestXCSEditor(); @@ -292,8 +293,7 @@ void test_transformation() CHECK_ALTERNATE_ATOM_POSITION(atom4,orig_atom4,"Set1"); } - -void test_copy() +BOOST_AUTO_TEST_CASE(copy) { EntityHandle eh=make_test_entity(); EntityHandle cp=eh.Copy(); @@ -316,27 +316,4 @@ void test_copy() BOOST_CHECK(r2.GetPhiTorsion()); } - -BOOST_AUTO_TEST_SUITE( mol_base ) - -BOOST_AUTO_TEST_CASE(test_entity_creator) -{ - test_entity_creator(); -} - -BOOST_AUTO_TEST_CASE(test_spatial_organizer) -{ - test_spatial_organizer(); -} - -BOOST_AUTO_TEST_CASE(test_transformation) -{ - test_transformation(); -} - -BOOST_AUTO_TEST_CASE(test_copy) -{ - test_copy(); -} - BOOST_AUTO_TEST_SUITE_END() diff --git a/modules/mol/base/tests/test_ics.cc b/modules/mol/base/tests/test_ics.cc index 345717391..379559093 100644 --- a/modules/mol/base/tests/test_ics.cc +++ b/modules/mol/base/tests/test_ics.cc @@ -59,7 +59,22 @@ struct Structure { AtomHandle a5; }; -void test_ics_angle_trivia() { +const static Real EPSILON=0.000001; + +Real angle_xcs(AtomHandle a1, AtomHandle a2, AtomHandle a3) { + return acos(Dot(geom::Normalize(a1.GetPos()-a2.GetPos()), + geom::Normalize(a3.GetPos()-a2.GetPos()))); +} + +bool test_angle(Real a, Real e) { + return std::abs(fmod(float(a-e), float(M_PI/2)))<EPSILON; +} + +BOOST_AUTO_TEST_SUITE( mol_base ) + + +BOOST_AUTO_TEST_CASE(ics_angle_trivia) +{ Structure s; ICSEditor e=s.e.RequestICSEditor(); BOOST_CHECK(!e.SetAngle(s.a1, s.a3, s.a2, 0)); @@ -75,18 +90,8 @@ void test_ics_angle_trivia() { BOOST_CHECK_NO_THROW(s.e.GetAngle(s.a1, s.a2, s.a3)); } -const static Real EPSILON=0.000001; - -Real angle_xcs(AtomHandle a1, AtomHandle a2, AtomHandle a3) { - return acos(Dot(geom::Normalize(a1.GetPos()-a2.GetPos()), - geom::Normalize(a3.GetPos()-a2.GetPos()))); -} - -bool test_angle(Real a, Real e) { - return std::abs(fmod(float(a-e), float(M_PI/2)))<EPSILON; -} - -void test_ics_set_angle_sec() { +BOOST_AUTO_TEST_CASE(ics_set_angle_sec) +{ Structure s; // test for set angle of two secondary connectors ICSEditor e=s.e.RequestICSEditor(); @@ -102,7 +107,8 @@ void test_ics_set_angle_sec() { BOOST_CHECK(geom::IsInPlane(p, s.a4.GetPos(), EPSILON)); } -void test_ics_set_angle_prim() { +BOOST_AUTO_TEST_CASE(ics_set_angle_prim) +{ Structure s; // test for set angle of two secondary connectors ICSEditor e=s.e.RequestICSEditor(); @@ -118,13 +124,8 @@ void test_ics_set_angle_prim() { BOOST_CHECK(geom::IsInPlane(p, s.a4.GetPos(), EPSILON)); } -void test_ics_set_angle() { - //Logger::Instance().PushVerbosityLevel(Logger::DUMP); - test_ics_set_angle_sec(); - test_ics_set_angle_prim(); -} - -void test_ics_get_angle() { +BOOST_AUTO_TEST_CASE(ics_get_angle) +{ Structure s; // test for get angle with secondary connectors only Real a=s.e.GetAngle(s.a3, s.a2, s.a4); @@ -146,48 +147,4 @@ void test_ics_get_angle() { << " found"); } -void test_ics() { - // test trivial things first - test_ics_angle_trivia(); - test_ics_get_angle(); - test_ics_set_angle(); -} - -BOOST_AUTO_TEST_SUITE( mol_base ) - -BOOST_AUTO_TEST_CASE(test_ics_angle_trivia) -{ - test_ics_angle_trivia(); -} - -BOOST_AUTO_TEST_CASE(test_angle) -{ - test_angle(); -} - -BOOST_AUTO_TEST_CASE(test_ics_set_angle_sec) -{ - test_ics_set_angle_sec(); -} - -BOOST_AUTO_TEST_CASE(test_ics_set_angle_prim) -{ - test_ics_set_angle_prim(); -} - -BOOST_AUTO_TEST_CASE(test_ics_set_angle) -{ - test_ics_set_angle(); -} - -BOOST_AUTO_TEST_CASE(test_ics_get_angle) -{ - test_ics_get_angle(); -} - -BOOST_AUTO_TEST_CASE(test_ics) -{ - test_ics(); -} - BOOST_AUTO_TEST_SUITE_END() \ No newline at end of file diff --git a/modules/mol/base/tests/test_iterators.cc b/modules/mol/base/tests/test_iterators.cc index 76fd64049..8dfc0dca0 100644 --- a/modules/mol/base/tests/test_iterators.cc +++ b/modules/mol/base/tests/test_iterators.cc @@ -28,26 +28,6 @@ using namespace ost; using namespace ost::mol; -void test_chain_handle_iterator() { - EntityHandle ent=CreateEntity(); - XCSEditor editor=ent.RequestXCSEditor(); - ChainHandle ch1=editor.InsertChain("A"); - ChainHandle ch2=editor.InsertChain("B"); - ChainHandle ch3=editor.InsertChain("C"); - ChainHandleIter ch_it=ent.ChainsBegin(); - ChainHandleIter ch_end=ent.ChainsEnd(); - BOOST_CHECK(ch_it!=ch_end); - BOOST_CHECK_EQUAL((*ch_it).GetName(), "A"); - ++ch_it; - BOOST_CHECK(ch_it!=ch_end); - BOOST_CHECK_EQUAL((*ch_it).GetName(), "B"); - ++ch_it; - BOOST_CHECK(ch_it!=ch_end); - BOOST_CHECK_EQUAL((*ch_it).GetName(), "C"); - ++ch_it; - BOOST_CHECK(ch_it==ch_end); -} - template <typename HANDLE, typename ITER> void test_res_handle_iterator_b(HANDLE ch) { ITER r1=ch.ResiduesBegin(); @@ -97,38 +77,6 @@ void test_res_handle_iterator_a(HANDLE eh) { BOOST_CHECK(r1==r2); } -void test_res_handle_iterator() { - EntityHandle eh=CreateEntity(); - XCSEditor editor=eh.RequestXCSEditor(); - ChainHandle ch1=editor.InsertChain("A"); - editor.AppendResidue(ch1, "A"); - editor.AppendResidue(ch1, "B"); - editor.AppendResidue(ch1, "C"); - - // make sure the iterator knows how to deal with empty chains - ChainHandle ch3=editor.InsertChain("B"); - - ChainHandle ch2=editor.InsertChain("C"); - editor.AppendResidue(ch2, "D"); - editor.AppendResidue(ch2, "E"); - editor.AppendResidue(ch2, "F"); - EntityView v1=eh.CreateFullView(); - test_res_handle_iterator_b<ChainHandle, ResidueHandleIter>(ch2); - test_res_handle_iterator_a<EntityHandle, ResidueHandleIter>(eh); - test_res_handle_iterator_a<EntityView, ResidueViewIter>(v1); - // make the sure the iterator knows how to deal with an empty chain at - // the end - ChainHandle ch4=editor.InsertChain("D"); - test_res_handle_iterator_a<EntityHandle, ResidueHandleIter>(eh); - EntityView v2=eh.CreateFullView(); - test_res_handle_iterator_a<EntityView, ResidueViewIter>(v2); - test_res_handle_iterator_b<ChainHandle, ResidueHandleIter>(ch2); - editor.AppendResidue(ch4, "D"); - editor.AppendResidue(ch4, "E"); - editor.AppendResidue(ch4, "F"); - test_res_handle_iterator_b<ChainHandle, ResidueHandleIter>(ch2); - -} template <typename HANDLE, typename ITER> void test_atom_handle_iterator_c(HANDLE en) { ITER a1=en.AtomsBegin(); @@ -173,7 +121,78 @@ void test_atom_handle_iterator_a(HANDLE ch) { BOOST_CHECK(a1==a2); } -void test_empty_iterators() { +template <typename HANDLE, typename ITER> +void test_atom_handle_iterator_b(HANDLE rr) { + ITER a1=rr.AtomsBegin(); + ITER a2=rr.AtomsEnd(); + BOOST_CHECK(a1!=a2); + BOOST_CHECK_EQUAL((*a1).GetName(), "X"); + ++a1; + BOOST_CHECK(a1!=a2); + BOOST_CHECK_EQUAL((*a1).GetName(), "Y"); + + ++a1; + BOOST_CHECK(a1==a2); +} + +BOOST_AUTO_TEST_SUITE( mol_base ) + +BOOST_AUTO_TEST_CASE(chain_handle_iterator) +{ + EntityHandle ent=CreateEntity(); + XCSEditor editor=ent.RequestXCSEditor(); + ChainHandle ch1=editor.InsertChain("A"); + ChainHandle ch2=editor.InsertChain("B"); + ChainHandle ch3=editor.InsertChain("C"); + ChainHandleIter ch_it=ent.ChainsBegin(); + ChainHandleIter ch_end=ent.ChainsEnd(); + BOOST_CHECK(ch_it!=ch_end); + BOOST_CHECK_EQUAL((*ch_it).GetName(), "A"); + ++ch_it; + BOOST_CHECK(ch_it!=ch_end); + BOOST_CHECK_EQUAL((*ch_it).GetName(), "B"); + ++ch_it; + BOOST_CHECK(ch_it!=ch_end); + BOOST_CHECK_EQUAL((*ch_it).GetName(), "C"); + ++ch_it; + BOOST_CHECK(ch_it==ch_end); +} + +BOOST_AUTO_TEST_CASE(test_res_handle_iterator) +{ + EntityHandle eh=CreateEntity(); + XCSEditor editor=eh.RequestXCSEditor(); + ChainHandle ch1=editor.InsertChain("A"); + editor.AppendResidue(ch1, "A"); + editor.AppendResidue(ch1, "B"); + editor.AppendResidue(ch1, "C"); + + // make sure the iterator knows how to deal with empty chains + ChainHandle ch3=editor.InsertChain("B"); + + ChainHandle ch2=editor.InsertChain("C"); + editor.AppendResidue(ch2, "D"); + editor.AppendResidue(ch2, "E"); + editor.AppendResidue(ch2, "F"); + EntityView v1=eh.CreateFullView(); + test_res_handle_iterator_b<ChainHandle, ResidueHandleIter>(ch2); + test_res_handle_iterator_a<EntityHandle, ResidueHandleIter>(eh); + test_res_handle_iterator_a<EntityView, ResidueViewIter>(v1); + // make the sure the iterator knows how to deal with an empty chain at + // the end + ChainHandle ch4=editor.InsertChain("D"); + test_res_handle_iterator_a<EntityHandle, ResidueHandleIter>(eh); + EntityView v2=eh.CreateFullView(); + test_res_handle_iterator_a<EntityView, ResidueViewIter>(v2); + test_res_handle_iterator_b<ChainHandle, ResidueHandleIter>(ch2); + editor.AppendResidue(ch4, "D"); + editor.AppendResidue(ch4, "E"); + editor.AppendResidue(ch4, "F"); + test_res_handle_iterator_b<ChainHandle, ResidueHandleIter>(ch2); +} + +BOOST_AUTO_TEST_CASE(test_empty_iterators) +{ EntityHandle eh=CreateEntity(); BOOST_CHECK(eh.ChainsBegin()==eh.ChainsEnd()); BOOST_CHECK(eh.ResiduesBegin()==eh.ResiduesEnd()); @@ -203,24 +222,12 @@ void test_empty_iterators() { } BOOST_CHECK(ev.AtomsBegin()==ev.AtomsEnd()); BOOST_CHECK(ev.GetAtomList().empty()); - //BOOST_CHECK(ev.FindChain("A").AtomsBegin()==ev.FindChain("A").AtomsEnd()); + //BOOST_CHECK(ev.FindChain("A").AtomsBegin()==ev.FindChain("A").AtomsEnd()); } -template <typename HANDLE, typename ITER> -void test_atom_handle_iterator_b(HANDLE rr) { - ITER a1=rr.AtomsBegin(); - ITER a2=rr.AtomsEnd(); - BOOST_CHECK(a1!=a2); - BOOST_CHECK_EQUAL((*a1).GetName(), "X"); - ++a1; - BOOST_CHECK(a1!=a2); - BOOST_CHECK_EQUAL((*a1).GetName(), "Y"); - - ++a1; - BOOST_CHECK(a1==a2); -} -void test_atom_handle_iterator() { +BOOST_AUTO_TEST_CASE(test_atom_handle_iterator) +{ EntityHandle eh=CreateEntity(); XCSEditor editor=eh.RequestXCSEditor(); ChainHandle ch1=editor.InsertChain("A"); @@ -245,53 +252,6 @@ void test_atom_handle_iterator() { EntityView v=eh.CreateFullView(); test_atom_handle_iterator_c<EntityHandle, AtomHandleIter>(eh); - test_atom_handle_iterator_c<EntityView, AtomViewIter>(v); -} - -BOOST_AUTO_TEST_SUITE( mol_base ) - -BOOST_AUTO_TEST_CASE(test_chain_handle_iterator) -{ - test_chain_handle_iterator(); -} - -BOOST_AUTO_TEST_CASE(test_res_handle_iterator_b) -{ - test_res_handle_iterator_b(); -} - -BOOST_AUTO_TEST_CASE(test_res_handle_iterator_a) -{ - test_res_handle_iterator_a(); -} - -BOOST_AUTO_TEST_CASE(test_res_handle_iterator) -{ - test_res_handle_iterator(); -} - -BOOST_AUTO_TEST_CASE(test_atom_handle_iterator_c) -{ - test_atom_handle_iterator_c(); -} - -BOOST_AUTO_TEST_CASE(test_atom_handle_iterator_a) -{ - test_atom_handle_iterator_a(); -} - -BOOST_AUTO_TEST_CASE(test_empty_iterators) -{ - test_empty_iterators(); -} - -BOOST_AUTO_TEST_CASE(test_atom_handle_iterator_b) -{ - test_atom_handle_iterator_b(); -} - -BOOST_AUTO_TEST_CASE(test_atom_handle_iterator) -{ - test_atom_handle_iterator(); + test_atom_handle_iterator_c<EntityView, AtomViewIter>(v); } BOOST_AUTO_TEST_SUITE_END() \ No newline at end of file diff --git a/modules/mol/base/tests/test_query.cc b/modules/mol/base/tests/test_query.cc index 3ecea03ca..1b5074444 100644 --- a/modules/mol/base/tests/test_query.cc +++ b/modules/mol/base/tests/test_query.cc @@ -28,96 +28,6 @@ using namespace ost; using namespace ost::mol; -void test_query_parse_properties() { - BOOST_CHECK(Query("rname=Ala").IsValid()); - BOOST_CHECK(Query("ele=C").IsValid()); - BOOST_CHECK(Query("aname=X").IsValid()); - BOOST_CHECK(Query("rnum=3").IsValid()); - BOOST_CHECK(Query("cname=A").IsValid()); - BOOST_CHECK(Query("occ=50").IsValid()); - BOOST_CHECK(Query("occ=50").IsValid()); - BOOST_CHECK(Query("rtype=H").IsValid()); - BOOST_CHECK(Query("x=3").IsValid()); - BOOST_CHECK(Query("y=4").IsValid()); - BOOST_CHECK(Query("z=6").IsValid()); - BOOST_CHECK(Query("gatest=7").IsValid()); - BOOST_CHECK(Query("grtest=8").IsValid()); - BOOST_CHECK(Query("gctest=9").IsValid()); - BOOST_CHECK(Query("gatest:1=7").IsValid()); - BOOST_CHECK(Query("grtest:2=8").IsValid()); - BOOST_CHECK(Query("gctest:3.0=9").IsValid()); - BOOST_CHECK(Query("anita=3").IsValid()==false); -} - -void test_query_parse_value_type() { - - BOOST_CHECK(Query("rnum<=3").IsValid()); - BOOST_CHECK(Query("rnum>=3").IsValid()); - BOOST_CHECK(Query("rnum<3").IsValid()); - BOOST_CHECK(Query("rnum>3").IsValid()); - BOOST_CHECK(Query("rnum!=3").IsValid()); - - BOOST_CHECK(Query("rnum=3:10").IsValid()); - BOOST_CHECK(Query("rnum!=3:10").IsValid()); - BOOST_CHECK(Query("rnum!=3:10").IsValid()); - BOOST_CHECK(Query("rnum>=30:40").IsValid()==false); - BOOST_CHECK(Query("rnum>30:40").IsValid()==false); - BOOST_CHECK(Query("rnum<=30:40").IsValid()==false); - BOOST_CHECK(Query("rnum<30:40").IsValid()==false); - - BOOST_CHECK(Query("rnum=1,2").IsValid()); - BOOST_CHECK(Query("rnum=1,2,3,4").IsValid()); - BOOST_CHECK(Query("rnum>1,2,3,4").IsValid()==false); - - BOOST_CHECK(Query("rnum=WTF").IsValid()==false); - BOOST_CHECK(Query("rnum=WTF").IsValid()==false); - BOOST_CHECK(Query("rnum=3.0").IsValid()==false); - BOOST_CHECK(Query("ele>=XXX").IsValid()==false); - -} - -void test_query_parse_logical_op() { - - BOOST_CHECK(Query("rnum=3 and rnum=5").IsValid()); - BOOST_CHECK(Query("rnum=3 or rnum=5").IsValid()); - BOOST_CHECK(Query("not rnum=3").IsValid()); - BOOST_CHECK(Query("not rnum=3").IsValid()); - BOOST_CHECK(Query("not rnum=3 and not rnum=5").IsValid()); - BOOST_CHECK(Query("not not rnum=3").IsValid()==false); -} - -void test_query_parse_unexpected() { - BOOST_CHECK(Query("cname").IsValid()==false); - BOOST_CHECK(Query("cname=").IsValid()==false); - BOOST_CHECK(Query("not").IsValid()==false); - BOOST_CHECK(Query("(rnum=3").IsValid()==false); - BOOST_CHECK(Query("(rnum=3").IsValid()==false); - BOOST_CHECK(Query("(rnum=3").IsValid()==false); - BOOST_CHECK(Query("(not").IsValid()==false); - BOOST_CHECK(Query("()").IsValid()==false); - BOOST_CHECK(Query("(rnum)").IsValid()==false); - BOOST_CHECK(Query("(rnum=)").IsValid()==false); - BOOST_CHECK(Query("gatest:=5").IsValid()==false); - BOOST_CHECK(Query("gatest:5.0=").IsValid()==false); - BOOST_CHECK(Query("gatest:=").IsValid()==false); -} - -void test_query_parse_within() { - BOOST_CHECK(Query("5 <> {0,0,0.0}").IsValid()); - BOOST_CHECK(Query("5 <> {0}").IsValid()==false); - BOOST_CHECK(Query("5 <> {0").IsValid()==false); - BOOST_CHECK(Query("5 <> {0,}").IsValid()==false); - BOOST_CHECK(Query("5 <> {0,0.}").IsValid()==false); -} - -void test_query_parse() { - test_query_parse_properties(); - test_query_parse_value_type(); - test_query_parse_unexpected(); - test_query_parse_logical_op(); - test_query_parse_within(); -} - EntityHandle make_query_test_entity() { EntityHandle eh = CreateEntity(); @@ -204,7 +114,94 @@ void ensure_counts_v(EntityView src, const String& qs, " for query String " << qs); } -void test_query_eval() { +BOOST_AUTO_TEST_SUITE( mol_base ) + +BOOST_AUTO_TEST_CASE(test_query_parse_properties) +{ + BOOST_CHECK(Query("rname=Ala").IsValid()); + BOOST_CHECK(Query("ele=C").IsValid()); + BOOST_CHECK(Query("aname=X").IsValid()); + BOOST_CHECK(Query("rnum=3").IsValid()); + BOOST_CHECK(Query("cname=A").IsValid()); + BOOST_CHECK(Query("occ=50").IsValid()); + BOOST_CHECK(Query("occ=50").IsValid()); + BOOST_CHECK(Query("rtype=H").IsValid()); + BOOST_CHECK(Query("x=3").IsValid()); + BOOST_CHECK(Query("y=4").IsValid()); + BOOST_CHECK(Query("z=6").IsValid()); + BOOST_CHECK(Query("gatest=7").IsValid()); + BOOST_CHECK(Query("grtest=8").IsValid()); + BOOST_CHECK(Query("gctest=9").IsValid()); + BOOST_CHECK(Query("gatest:1=7").IsValid()); + BOOST_CHECK(Query("grtest:2=8").IsValid()); + BOOST_CHECK(Query("gctest:3.0=9").IsValid()); + BOOST_CHECK(Query("anita=3").IsValid()==false); +} + +BOOST_AUTO_TEST_CASE(test_query_parse_value_type) +{ + BOOST_CHECK(Query("rnum<=3").IsValid()); + BOOST_CHECK(Query("rnum>=3").IsValid()); + BOOST_CHECK(Query("rnum<3").IsValid()); + BOOST_CHECK(Query("rnum>3").IsValid()); + BOOST_CHECK(Query("rnum!=3").IsValid()); + + BOOST_CHECK(Query("rnum=3:10").IsValid()); + BOOST_CHECK(Query("rnum!=3:10").IsValid()); + BOOST_CHECK(Query("rnum!=3:10").IsValid()); + BOOST_CHECK(Query("rnum>=30:40").IsValid()==false); + BOOST_CHECK(Query("rnum>30:40").IsValid()==false); + BOOST_CHECK(Query("rnum<=30:40").IsValid()==false); + BOOST_CHECK(Query("rnum<30:40").IsValid()==false); + + BOOST_CHECK(Query("rnum=1,2").IsValid()); + BOOST_CHECK(Query("rnum=1,2,3,4").IsValid()); + BOOST_CHECK(Query("rnum>1,2,3,4").IsValid()==false); + + BOOST_CHECK(Query("rnum=WTF").IsValid()==false); + BOOST_CHECK(Query("rnum=WTF").IsValid()==false); + BOOST_CHECK(Query("rnum=3.0").IsValid()==false); + BOOST_CHECK(Query("ele>=XXX").IsValid()==false); +} + +BOOST_AUTO_TEST_CASE(test_query_parse_logical_op) +{ + BOOST_CHECK(Query("rnum=3 and rnum=5").IsValid()); + BOOST_CHECK(Query("rnum=3 or rnum=5").IsValid()); + BOOST_CHECK(Query("not rnum=3").IsValid()); + BOOST_CHECK(Query("not rnum=3").IsValid()); + BOOST_CHECK(Query("not rnum=3 and not rnum=5").IsValid()); + BOOST_CHECK(Query("not not rnum=3").IsValid()==false); +} + +BOOST_AUTO_TEST_CASE(test_query_parse_unexpected) +{ + BOOST_CHECK(Query("cname").IsValid()==false); + BOOST_CHECK(Query("cname=").IsValid()==false); + BOOST_CHECK(Query("not").IsValid()==false); + BOOST_CHECK(Query("(rnum=3").IsValid()==false); + BOOST_CHECK(Query("(rnum=3").IsValid()==false); + BOOST_CHECK(Query("(rnum=3").IsValid()==false); + BOOST_CHECK(Query("(not").IsValid()==false); + BOOST_CHECK(Query("()").IsValid()==false); + BOOST_CHECK(Query("(rnum)").IsValid()==false); + BOOST_CHECK(Query("(rnum=)").IsValid()==false); + BOOST_CHECK(Query("gatest:=5").IsValid()==false); + BOOST_CHECK(Query("gatest:5.0=").IsValid()==false); + BOOST_CHECK(Query("gatest:=").IsValid()==false); +} + +BOOST_AUTO_TEST_CASE(test_query_parse_within) +{ + BOOST_CHECK(Query("5 <> {0,0,0.0}").IsValid()); + BOOST_CHECK(Query("5 <> {0}").IsValid()==false); + BOOST_CHECK(Query("5 <> {0").IsValid()==false); + BOOST_CHECK(Query("5 <> {0,}").IsValid()==false); + BOOST_CHECK(Query("5 <> {0,0.}").IsValid()==false); +} + +BOOST_AUTO_TEST_CASE(test_query_eval) +{ EntityHandle e=make_query_test_entity(); ensure_counts(e, "", 1, 3, 27); @@ -237,7 +234,8 @@ void test_query_eval() { ensure_counts(e, "gctestpropc:2.0=2", 0, 0, 0); } -void test_query_eval_on_view() { +BOOST_AUTO_TEST_CASE(test_query_eval_on_view) +{ EntityHandle e=make_query_test_entity(); EntityView v=e.CreateFullView(); ensure_counts_v(v, "", 1, 3, 27); @@ -268,7 +266,8 @@ void test_query_eval_on_view() { ensure_counts_v(v, "gctestpropc:2.0=2", 0, 0, 0); } -void test_query_throw() { +BOOST_AUTO_TEST_CASE(test_query_throw) +{ EntityHandle e=make_query_test_entity(); BOOST_CHECK_NO_THROW(e.Select("gatestpropa:0=1")); BOOST_CHECK_NO_THROW(e.Select("gatestpropa:1=1")); @@ -284,66 +283,6 @@ void test_query_throw() { BOOST_CHECK_NO_THROW(e.Select("ganotsetprop:0=1")); BOOST_CHECK_NO_THROW(e.Select("grnotsetprop:0=1")); BOOST_CHECK_NO_THROW(e.Select("gcnotsetprop:0=1")); - -} - -void test_query() { - test_query_parse(); - test_query_eval(); - test_query_eval_on_view(); - test_query_throw(); -} - -BOOST_AUTO_TEST_SUITE( mol_base ) - -BOOST_AUTO_TEST_CASE(test_query_parse_properties) -{ - test_query_parse_properties(); -} - -BOOST_AUTO_TEST_CASE(test_query_parse_value_type) -{ - test_query_parse_value_type(); -} - -BOOST_AUTO_TEST_CASE(test_query_parse_logical_op) -{ - test_query_parse_logical_op(); -} - -BOOST_AUTO_TEST_CASE(test_query_parse_unexpected) -{ - test_query_parse_unexpected(); -} - -BOOST_AUTO_TEST_CASE(test_query_parse_within) -{ - test_query_parse_within(); -} - -BOOST_AUTO_TEST_CASE(test_query_parse) -{ - test_query_parse(); -} - -BOOST_AUTO_TEST_CASE(test_query_eval) -{ - test_query_eval(); -} - -BOOST_AUTO_TEST_CASE(test_query_eval_on_view) -{ - test_query_eval_on_view(); -} - -BOOST_AUTO_TEST_CASE(test_query_throw) -{ - test_query_throw(); -} - -BOOST_AUTO_TEST_CASE(test_query) -{ - test_query(); } BOOST_AUTO_TEST_SUITE_END() diff --git a/modules/mol/base/tests/test_residue.cc b/modules/mol/base/tests/test_residue.cc index 865e55cdd..5b5dea5eb 100644 --- a/modules/mol/base/tests/test_residue.cc +++ b/modules/mol/base/tests/test_residue.cc @@ -29,7 +29,10 @@ using namespace ost; using namespace ost::mol; -void test_in_sequence() { +BOOST_AUTO_TEST_SUITE( mol_base ) + +BOOST_AUTO_TEST_CASE(test_in_sequence) +{ EntityHandle eh=CreateEntity(); XCSEditor e=eh.RequestXCSEditor(); ChainHandle ch1=e.InsertChain("A"); @@ -42,11 +45,4 @@ void test_in_sequence() { BOOST_CHECK(!InSequence(rA,rC)); } -BOOST_AUTO_TEST_SUITE( mol_base ) - -BOOST_AUTO_TEST_CASE(test_in_sequence) -{ - test_in_sequence(); -} - BOOST_AUTO_TEST_SUITE_END() \ No newline at end of file diff --git a/modules/mol/base/tests/test_signal.cc b/modules/mol/base/tests/test_signal.cc deleted file mode 100644 index 16afb19bf..000000000 --- a/modules/mol/base/tests/test_signal.cc +++ /dev/null @@ -1,81 +0,0 @@ -//------------------------------------------------------------------------------ -// This file is part of the OpenStructure project <www.openstructure.org> -// -// Copyright (C) 2008-2010 by the OpenStructure authors -// -// This library is free software; you can redistribute it and/or modify it under -// the terms of the GNU Lesser General Public License as published by the Free -// Software Foundation; either version 3.0 of the License, or (at your option) -// any later version. -// This library is distributed in the hope that it will be useful, but WITHOUT -// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS -// FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more -// details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with this library; if not, write to the Free Software Foundation, Inc., -// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -//------------------------------------------------------------------------------ -/* - * Authors: Marco Biasini, Juergen Haas - */ -#include <ost/mol/mol.hh> -#include <ost/log.hh> -#define BOOST_TEST_DYN_LINK -#include <boost/test/unit_test.hpp> -#include <ost/message.hh> -#include <ost/geom/geom.hh> - -using namespace ost; -using namespace ost::mol; - -int num_of_atoms_deleted=0; -void on_delete_atom(const AtomHandle& atom) { - num_of_atoms_deleted++; -} - - -struct Fixture { - Fixture() { - e=CreateEntity(); - c=e.InsertChain("A"); - r=c.AppendResidue("XXX"); - aa=r.InsertAtom("A", geom::Vec3()); - ab=r.InsertAtom("B", geom::Vec3()); - ac=r.InsertAtom("C", geom::Vec3()); - ad=r.InsertAtom("D", geom::Vec3()); - - BondHandle b1=e.Connect(aa, ab); - BondHandle b2=e.Connect(ab, ac); - BondHandle b3=e.Connect(ac, ad); - - TorsionHandle t=e.AddTorsion("TORSION", aa, ab, ac, ad); - } - EntityHandle e; - ChainHandle c; - ResidueHandle r; - AtomHandle aa; - AtomHandle ab; - AtomHandle ac; - AtomHandle ad; -}; - -void test_signal() { - Fixture f1; - SignalConnection c=f1.e.OnAtomDeleted().AttachObserver(on_delete_atom); - f1.r.DeleteAtom(f1.aa); - BOOST_CHECK_EQUAL(num_of_atoms_deleted, 1); - f1.e.OnAtomDeleted().DetachObserver(c); - f1.r.DeleteAtom(f1.ab); - BOOST_CHECK_EQUAL(num_of_atoms_deleted, 1); -} - - -BOOST_AUTO_TEST_SUITE( mol_base ) - -BOOST_AUTO_TEST_CASE(test_signal) -{ - test_signal(); -} - -BOOST_AUTO_TEST_SUITE_END() diff --git a/modules/mol/base/tests/test_view.cc b/modules/mol/base/tests/test_view.cc index f04c97e76..33bda815d 100644 --- a/modules/mol/base/tests/test_view.cc +++ b/modules/mol/base/tests/test_view.cc @@ -50,7 +50,9 @@ struct Fixture { AtomHandle ad; }; -void test_GenerateFullView() +BOOST_AUTO_TEST_SUITE( mol_base ) + +BOOST_AUTO_TEST_CASE(gen_full_view) { Fixture f; @@ -77,11 +79,4 @@ void test_GenerateFullView() BOOST_CHECK_EQUAL(avl[3].GetBondCount(),1); } -BOOST_AUTO_TEST_SUITE( mol_base ) - -BOOST_AUTO_TEST_CASE(test_GenerateFullView) -{ - test_GenerateFullView(); -} - BOOST_AUTO_TEST_SUITE_END() -- GitLab