Skip to content
Snippets Groups Projects
Commit 4d14334a authored by Gabriel Studer's avatar Gabriel Studer
Browse files

added unit tests to entity and chain

parent 738adb94
No related branches found
No related tags found
No related merge requests found
...@@ -87,16 +87,38 @@ BOOST_AUTO_TEST_CASE(test_comparison) ...@@ -87,16 +87,38 @@ BOOST_AUTO_TEST_CASE(test_comparison)
BOOST_CHECK(cc==ch1); BOOST_CHECK(cc==ch1);
} }
BOOST_AUTO_TEST_CASE(throw_invalid_chain_handle) BOOST_AUTO_TEST_CASE(throw_invalid_chain_handle)
{ {
EntityHandle ent=CreateEntity(); EntityHandle ent=CreateEntity();
ChainHandle chain=ent.FindChain("A"); ChainHandle ch=ent.FindChain("A");
BOOST_CHECK_THROW(CheckHandleValidity(chain), InvalidHandle); BOOST_CHECK_THROW(CheckHandleValidity(ch), InvalidHandle);
XCSEditor edi=ent.EditXCS(); XCSEditor edi=ent.EditXCS();
edi.InsertChain("A"); edi.InsertChain("A");
chain=ent.FindChain("A"); ch=ent.FindChain("A");
BOOST_CHECK_NO_THROW(CheckHandleValidity(chain)); BOOST_CHECK_NO_THROW(CheckHandleValidity(ch));
EntityHandle eh1 = CreateEntity();
XCSEditor e1=eh1.EditXCS();
ChainHandle chain = e1.InsertChain("C");
ResidueHandle res1 = e1.AppendResidue(chain, "FOO", ResNum(13));
AtomHandle atom1 = e1.InsertAtom(res1, "X1",geom::Vec3());
AtomHandle atom2 = e1.InsertAtom(res1, "X2",geom::Vec3());
ResidueHandle res2 = e1.AppendResidue(chain, "FOO", ResNum(42));
e1.InsertAtom(res2, "X1",geom::Vec3());
e1.InsertAtom(res2, "X2",geom::Vec3());
EntityHandle eh2=CreateEntity();
XCSEditor e2=eh2.EditXCS();
ChainHandle inserted_chain1 = e2.InsertChain("Q",chain);
res1.SetIntProp("amazing",42);
ResidueHandle inserted_residue1 = e2.AppendResidue(inserted_chain1,res1);
BOOST_CHECK(inserted_residue1!=res1);
BOOST_CHECK(eh2.GetResidueCount()==1);
BOOST_CHECK(eh2.GetAtomCount()==0);
BOOST_CHECK(inserted_residue1.HasProp("amazing"));
ResidueHandle inserted_residue2 = e2.AppendResidue(inserted_chain1,res2,true);
BOOST_CHECK(eh2.GetAtomCount()==2);
} }
BOOST_AUTO_TEST_CASE(throw_invalid_chain_view) BOOST_AUTO_TEST_CASE(throw_invalid_chain_view)
......
...@@ -136,8 +136,24 @@ BOOST_AUTO_TEST_CASE(entity_creator) ...@@ -136,8 +136,24 @@ BOOST_AUTO_TEST_CASE(entity_creator)
BOOST_CHECK(eh.GetAtomCount()==2); BOOST_CHECK(eh.GetAtomCount()==2);
BOOST_CHECK(eh.GetAtomCount()==chain.GetAtomCount()); BOOST_CHECK(eh.GetAtomCount()==chain.GetAtomCount());
BOOST_CHECK(eh.GetResidueCount()==chain.GetResidueCount()); BOOST_CHECK(eh.GetResidueCount()==chain.GetResidueCount());
chain.SetIntProp("amazing",42);
EntityHandle eh2 = CreateEntity();
XCSEditor e2 = eh2.EditXCS();
ChainHandle inserted_chain=e2.InsertChain("Q",chain);
BOOST_CHECK(eh2.GetChainCount()==1);
BOOST_CHECK(eh2.GetResidueCount()==0);
BOOST_CHECK(eh2.GetAtomCount()==0);
BOOST_CHECK(inserted_chain.HasProp("amazing"));
BOOST_CHECK(eh2.FindChain("Q").IsValid());
EntityHandle eh3 = CreateEntity();
XCSEditor e3 = eh3.EditXCS();
e3.InsertChain("Q",chain,true);
BOOST_CHECK(eh3.GetResidueCount()==1);
BOOST_CHECK(eh3.GetAtomCount()==2);
EntityVisitor v; EntityVisitor v;
eh.Apply(v); eh.Apply(v);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment