ProteoWizard
Classes | Functions
ProteinListWrapperTest.cpp File Reference
#include "ProteinListWrapper.hpp"
#include "pwiz/utility/misc/unit.hpp"
#include "pwiz/utility/misc/Std.hpp"

Go to the source code of this file.

Classes

class  MyWrapper
class  FilterWrapper

Functions

void test ()
int main (int argc, const char *argv[])

Function Documentation

void test ( )

Definition at line 63 of file ProteinListWrapperTest.cpp.

References boost::lexical_cast(), and unit_assert.

{
typedef shared_ptr<ProteinListSimple> ProteinListSimplePtr;
ProteinListSimplePtr simple(new ProteinListSimple);
const size_t proteinCount = 10;
for (size_t i=0; i<proteinCount; i++)
simple->proteins.push_back(ProteinPtr(new Protein("PWIZ:" + lexical_cast<string>(i), i, "", "")));
// check MyWrapper
shared_ptr<MyWrapper> wrapper(new MyWrapper(simple));
wrapper->verifySize(10);
unit_assert(wrapper->size() == 10);
for (size_t i=0; i<proteinCount; i++)
{
string id = "PWIZ:" + lexical_cast<string>(i);
unit_assert(wrapper->find(id) == i);
ProteinPtr s = wrapper->protein(i);
unit_assert(s->id == id);
}
// check FilterWrapper
shared_ptr<FilterWrapper> filterWrapper(new FilterWrapper(simple));
unit_assert(filterWrapper->size() == 5);
for (size_t i=0; i<filterWrapper->size(); i++)
{
string id = "PWIZ:" + lexical_cast<string>(i*2);
unit_assert(filterWrapper->find(id) == i);
ProteinPtr s = filterWrapper->protein(i);
unit_assert(s->id == id);
}
}
int main ( int  argc,
const char *  argv[] 
)

Definition at line 106 of file ProteinListWrapperTest.cpp.

References e(), test(), TEST_EPILOG, TEST_FAILED, and TEST_PROLOG.

{
TEST_PROLOG(argc, argv)
try
{
test();
}
catch (exception& e)
{
TEST_FAILED(e.what())
}
catch (...)
{
TEST_FAILED("Caught unknown exception.")
}
}