ProteoWizard
Public Member Functions | Protected Member Functions | List of all members
MatrixIOTest Class Reference

Public Member Functions

void Run ()
 

Protected Member Functions

virtual void SetUp ()
 
void TearDown ()
 
void SingleReadWrite ()
 
void MultiReadWrite ()
 

Detailed Description

Definition at line 29 of file MatrixIOTest.cpp.

Member Function Documentation

◆ Run()

void MatrixIOTest::Run ( )
inline

Definition at line 31 of file MatrixIOTest.cpp.

32  {
33  SetUp();
36  TearDown();
37  }

Referenced by main().

◆ SetUp()

virtual void MatrixIOTest::SetUp ( )
inlineprotectedvirtual

Definition at line 41 of file MatrixIOTest.cpp.

42  {
43  }

◆ TearDown()

void MatrixIOTest::TearDown ( )
inlineprotected

Definition at line 45 of file MatrixIOTest.cpp.

46  {
47  remove("TestMatrixIOTemp.log");
48  }

◆ SingleReadWrite()

void MatrixIOTest::SingleReadWrite ( )
inlineprotected

Definition at line 50 of file MatrixIOTest.cpp.

51  {
52  std::string testFilename = "TestMatrixIOTemp.log";
53  DemuxTypes::MatrixPtr matrix = boost::make_shared<DemuxTypes::MatrixType>(3, 3);
54  *matrix << 1, 2, 3,
55  4, 5, 6,
56  7, 8, 9;
57  MatrixIO::WriteBinary(testFilename, matrix);
58 
59  DemuxTypes::MatrixPtr matrixIn = boost::make_shared<DemuxTypes::MatrixType>(1, 1);
60  MatrixIO::ReadBinary(testFilename, matrixIn);
61 
62  unit_assert(matrixIn->isApprox(*matrix));
63  }

References testFilename(), and unit_assert.

◆ MultiReadWrite()

void MatrixIOTest::MultiReadWrite ( )
inlineprotected

Definition at line 65 of file MatrixIOTest.cpp.

66  {
67  std::string testFilename = "TestMatrixIOTemp.log";
68 
69  boost::filesystem::path full_path(boost::filesystem::current_path());
70 
71  DemuxTypes::MatrixPtr A = boost::make_shared<DemuxTypes::MatrixType>(3, 4);
72  DemuxTypes::MatrixPtr B = boost::make_shared<DemuxTypes::MatrixType>(4, 3);
73  DemuxTypes::MatrixPtr C = boost::make_shared<DemuxTypes::MatrixType>(3, 3);
74  *A << -14.834628974133, -15.729764770592, 56.292839002858, 30.766363712773,
75  79.595747995303, -8.356622426449, 20.840197237638, 83.801095382748,
76  87.889866880787, 13.75327399942, 86.730656404499, -0.46420627108677;
77 
78  *B << 23.588885367543, 49.667231605868, -86.700220187964,
79  51.392601274063, -77.511392742378, 23.389497301117,
80  -78.475202879706, -62.60684915327, -42.39206607192,
81  59.595164405161, 2.1025961854091, 65.787705013259;
82 
83  *C = *A * *B;
84 
85  std::ofstream out;
86  MatrixIO::GetWriteStream(out, testFilename);
87  unit_assert(out.is_open());
88  MatrixIO::WriteBinary(out, A);
89  MatrixIO::WriteBinary(out, B);
90  MatrixIO::WriteBinary(out, C);
91  out.flush();
92  out.close();
93 
94  DemuxTypes::MatrixPtr AIn = boost::make_shared<DemuxTypes::MatrixType>(1, 1);
95  DemuxTypes::MatrixPtr BIn = boost::make_shared<DemuxTypes::MatrixType>(1, 1);
96  DemuxTypes::MatrixPtr CIn = boost::make_shared<DemuxTypes::MatrixType>(1, 1);
97 
98  std::ifstream in;
99  MatrixIO::GetReadStream(in, testFilename);
100  unit_assert(in.is_open());
101  MatrixIO::ReadBinary(in, AIn);
102  MatrixIO::ReadBinary(in, BIn);
103  MatrixIO::ReadBinary(in, CIn);
104  in.close();
105 
106  unit_assert(AIn->isApprox(*A));
107  unit_assert(BIn->isApprox(*B));
108  unit_assert(CIn->isApprox(*C));
109  }

References A, B, C, testFilename(), and unit_assert.


The documentation for this class was generated from the following file:
DemuxTypes::MatrixPtr
boost::shared_ptr< MatrixType > MatrixPtr
Definition: DemuxTypes.hpp:39
MatrixIOTest::SetUp
virtual void SetUp()
Definition: MatrixIOTest.cpp:41
MatrixIOTest::MultiReadWrite
void MultiReadWrite()
Definition: MatrixIOTest.cpp:65
testFilename
void testFilename()
Definition: PeptideID_pepXMLTest.cpp:69
MatrixIOTest::SingleReadWrite
void SingleReadWrite()
Definition: MatrixIOTest.cpp:50
B
B
Definition: Chemistry.hpp:81
C
C
Definition: Chemistry.hpp:80
MatrixIOTest::TearDown
void TearDown()
Definition: MatrixIOTest.cpp:45
unit_assert
#define unit_assert(x)
Definition: unit.hpp:85
A
#define A
Definition: FilesystemTest.cpp:50