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, char *argv[])
 

Function Documentation

◆ test()

void test ( )

Definition at line 63 of file ProteinListWrapperTest.cpp.

64{
65 typedef shared_ptr<ProteinListSimple> ProteinListSimplePtr;
66 ProteinListSimplePtr simple(new ProteinListSimple);
67
68 const size_t proteinCount = 10;
69 for (size_t i=0; i<proteinCount; i++)
70 simple->proteins.push_back(ProteinPtr(new Protein("PWIZ:" + lexical_cast<string>(i), i, "", "")));
71
72 // check MyWrapper
73
74 shared_ptr<MyWrapper> wrapper(new MyWrapper(simple));
75
76 wrapper->verifySize(10);
77 unit_assert(wrapper->size() == 10);
78 for (size_t i=0; i<proteinCount; i++)
79 {
80 string id = "PWIZ:" + lexical_cast<string>(i);
81
82 unit_assert(wrapper->find(id) == i);
83
84 ProteinPtr s = wrapper->protein(i);
85 unit_assert(s->id == id);
86 }
87
88 // check FilterWrapper
89
90 shared_ptr<FilterWrapper> filterWrapper(new FilterWrapper(simple));
91
92 unit_assert(filterWrapper->size() == 5);
93
94 for (size_t i=0; i<filterWrapper->size(); i++)
95 {
96 string id = "PWIZ:" + lexical_cast<string>(i*2);
97
98 unit_assert(filterWrapper->find(id) == i);
99
100 ProteinPtr s = filterWrapper->protein(i);
101 unit_assert(s->id == id);
102 }
103}
boost::shared_ptr< Protein > ProteinPtr
#define unit_assert(x)
Definition unit.hpp:85

References unit_assert.

Referenced by main().

◆ main()

int main ( int  argc,
char *  argv[] 
)

Definition at line 106 of file ProteinListWrapperTest.cpp.

107{
108 TEST_PROLOG(argc, argv)
109
110 try
111 {
112 test();
113 }
114 catch (exception& e)
115 {
116 TEST_FAILED(e.what())
117 }
118 catch (...)
119 {
120 TEST_FAILED("Caught unknown exception.")
121 }
122
124}
void test()
#define TEST_EPILOG
Definition unit.hpp:183
#define TEST_FAILED(x)
Definition unit.hpp:177
#define TEST_PROLOG(argc, argv)
Definition unit.hpp:175

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