ProteoWizard
Main Page
Namespaces
Classes
Files
File List
File Members
pwiz
utility
misc
mru_list_test.cpp
Go to the documentation of this file.
1
//
2
// $Id: mru_list_test.cpp 4129 2012-11-20 00:05:37Z chambm $
3
//
4
//
5
// Original author: Matt Chambers <matt.chambers .@. vanderbilt.edu>
6
//
7
// Copyright 2008 Vanderbilt University - Nashville, TN 37232
8
//
9
// Licensed under the Apache License, Version 2.0 (the "License");
10
// you may not use this file except in compliance with the License.
11
// You may obtain a copy of the License at
12
//
13
// http://www.apache.org/licenses/LICENSE-2.0
14
//
15
// Unless required by applicable law or agreed to in writing, software
16
// distributed under the License is distributed on an "AS IS" BASIS,
17
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18
// See the License for the specific language governing permissions and
19
// limitations under the License.
20
//
21
22
23
#include "
Std.hpp
"
24
#include "
mru_list.hpp
"
25
#include "
pwiz/utility/misc/unit.hpp
"
26
27
using namespace
pwiz::util;
28
29
void
test
()
30
{
31
mru_list<std::string>
mru(5);
32
33
mru.
insert
(
"Fighting"
);
34
mru.
insert
(
"Fu"
);
35
mru.
insert
(
"Kung"
);
36
mru.
insert
(
"Was"
);
37
mru.
insert
(
"Everybody"
);
38
39
unit_assert
(mru.
size
() == 5);
40
unit_assert
(*mru.
begin
() ==
"Everybody"
);
41
unit_assert
(*mru.
rbegin
() ==
"Fighting"
);
42
43
// set "Everybody" as MRU item (no effect)
44
mru.
insert
(
"Everybody"
);
45
46
unit_assert
(mru.
size
() == 5);
47
unit_assert
(*mru.
begin
() ==
"Everybody"
);
48
unit_assert
(*mru.
rbegin
() ==
"Fighting"
);
49
50
// set "Fighting" as MRU item
51
mru.
insert
(
"Fighting"
);
52
53
unit_assert
(mru.
size
() == 5);
54
unit_assert
(*mru.
begin
() ==
"Fighting"
);
55
unit_assert
(*mru.
rbegin
() ==
"Fu"
);
56
57
// pop LRU item "Fu"
58
mru.
insert
(
"Wax on, wax off"
);
59
60
unit_assert
(mru.
size
() == 5);
61
unit_assert
(*mru.
begin
() ==
"Wax on, wax off"
);
62
unit_assert
(*mru.
rbegin
() ==
"Kung"
);
63
}
64
65
66
int
main
(
int
argc,
const
char
* argv[])
67
{
68
TEST_PROLOG
(argc, argv)
69
70
try
71
{
72
test
();
73
}
74
catch
(exception&
e
)
75
{
76
TEST_FAILED
(e.what())
77
}
78
catch
(...)
79
{
80
TEST_FAILED
(
"Caught unknown exception."
)
81
}
82
83
TEST_EPILOG
84
}
Generated on Mon Nov 26 2012 18:05:49 for ProteoWizard by
1.8.1.1