ProteoWizard
Classes | Functions | Variables
ProteinList_FilterTest.cpp File Reference
#include "ProteinList_Filter.hpp"
#include "pwiz/utility/misc/unit.hpp"
#include "pwiz/utility/misc/IntegerSet.hpp"
#include "pwiz/utility/misc/Std.hpp"
#include <boost/assign.hpp>

Go to the source code of this file.

Classes

struct  SelectedIndexPredicate

Functions

void printProteinList (const ProteinList &pl, ostream &os)
ProteinListPtr createProteinList ()
void testSelectedIndices (ProteinListPtr pl)
void testIndexSet (ProteinListPtr pl)
void testIdSet (ProteinListPtr pl)
void test ()
int main (int argc, char *argv[])

Variables

ostream * os_ = 0

Function Documentation

void printProteinList ( const ProteinList pl,
ostream &  os 
)

Definition at line 41 of file ProteinList_FilterTest.cpp.

References pwiz::proteome::ProteinList::protein(), and pwiz::proteome::ProteinList::size().

Referenced by createProteinList(), testIdSet(), testIndexSet(), and testSelectedIndices().

{
os << "size: " << pl.size() << endl;
for (size_t i=0, end=pl.size(); i<end; i++)
{
ProteinPtr protein = pl.protein(i, false);
os << protein->index << " "
<< protein->id << " "
<< endl;
}
}
ProteinListPtr createProteinList ( )

Definition at line 55 of file ProteinList_FilterTest.cpp.

References os_, and printProteinList().

Referenced by test().

{
shared_ptr<ProteinListSimple> pl(new ProteinListSimple);
for (size_t i=0; i<10; ++i)
{
ProteinPtr protein(new Protein("Pro" + lexical_cast<string>(i+1), i, "", string(16, 'A'+i)));
pl->proteins.push_back(protein);
}
if (os_)
{
*os_ << "original protein list:\n";
*os_ << endl;
}
return pl;
}
void testSelectedIndices ( ProteinListPtr  pl)

Definition at line 98 of file ProteinList_FilterTest.cpp.

References os_, printProteinList(), pwiz::analysis::ProteinList_Filter::protein(), pwiz::analysis::ProteinList_Filter::size(), and unit_assert_operator_equal.

Referenced by test().

{
if (os_) *os_ << "testSelectedIndices:\n";
if (os_)
{
printProteinList(filter, *os_);
*os_ << endl;
}
unit_assert_operator_equal(3, filter.size());
unit_assert_operator_equal("Pro2", filter.protein(0)->id);
unit_assert_operator_equal("Pro4", filter.protein(1)->id);
unit_assert_operator_equal("Pro6", filter.protein(2)->id);
}
void testIndexSet ( ProteinListPtr  pl)

Definition at line 117 of file ProteinList_FilterTest.cpp.

References pwiz::util::IntegerSet::insert(), os_, printProteinList(), pwiz::analysis::ProteinList_Filter::protein(), pwiz::analysis::ProteinList_Filter::size(), and unit_assert_operator_equal.

Referenced by test().

{
if (os_) *os_ << "testIndexSet:\n";
IntegerSet indexSet;
indexSet.insert(3,5);
indexSet.insert(7);
indexSet.insert(9);
if (os_)
{
printProteinList(filter, *os_);
*os_ << endl;
}
unit_assert_operator_equal(5, filter.size());
unit_assert_operator_equal("Pro4", filter.protein(0)->id);
unit_assert_operator_equal("Pro5", filter.protein(1)->id);
unit_assert_operator_equal("Pro6", filter.protein(2)->id);
unit_assert_operator_equal("Pro8", filter.protein(3)->id);
unit_assert_operator_equal("Pro10", filter.protein(4)->id);
}
void testIdSet ( ProteinListPtr  pl)

Definition at line 143 of file ProteinList_FilterTest.cpp.

References os_, printProteinList(), pwiz::analysis::ProteinList_Filter::protein(), pwiz::analysis::ProteinList_Filter::size(), and unit_assert_operator_equal.

Referenced by test().

{
if (os_) *os_ << "testIdSet:\n";
set<string> idSet;
idSet += "Pro2", "Pro3", "Pro4", "Pro7";
if (os_)
{
printProteinList(filter, *os_);
*os_ << endl;
}
unit_assert_operator_equal(4, filter.size());
unit_assert_operator_equal("Pro2", filter.protein(0)->id);
unit_assert_operator_equal("Pro3", filter.protein(1)->id);
unit_assert_operator_equal("Pro4", filter.protein(2)->id);
unit_assert_operator_equal("Pro7", filter.protein(3)->id);
}
void test ( )
int main ( int  argc,
char *  argv[] 
)

Definition at line 175 of file ProteinList_FilterTest.cpp.

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

{
TEST_PROLOG(argc, argv)
try
{
if (argc>1 && !strcmp(argv[1],"-v")) os_ = &cout;
test();
}
catch (exception& e)
{
TEST_FAILED(e.what())
}
catch (...)
{
TEST_FAILED("Caught unknown exception.")
}
}

Variable Documentation

ostream* os_ = 0

Definition at line 38 of file ProteinList_FilterTest.cpp.