ProteoWizard
mru_list_test.cpp
Go to the documentation of this file.
1//
2// $Id$
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"
26
27using namespace pwiz::util;
28
29void test()
30{
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
66int main(int argc, 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
84}
reverse_iterator rbegin()
Definition mru_list.hpp:102
std::size_t size() const
Definition mru_list.hpp:92
bool insert(const item_type &item)
Definition mru_list.hpp:71
int main(int argc, char *argv[])
void test()
#define unit_assert(x)
Definition unit.hpp:85
#define TEST_EPILOG
Definition unit.hpp:183
#define TEST_FAILED(x)
Definition unit.hpp:177
#define TEST_PROLOG(argc, argv)
Definition unit.hpp:175