annotate UnitTestsSources/TestStrategy.cpp @ 708:51976977d2d3

reorganization
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 20 May 2019 11:20:01 +0200
parents 14557e550920
children 2d8ab34c8c91
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
695
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1 /**
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2 * Stone of Orthanc
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
4 * Department, University Hospital of Liege, Belgium
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
5 * Copyright (C) 2017-2019 Osimis S.A., Belgium
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
6 *
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
7 * This program is free software: you can redistribute it and/or
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
8 * modify it under the terms of the GNU Affero General Public License
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
9 * as published by the Free Software Foundation, either version 3 of
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
10 * the License, or (at your option) any later version.
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
11 *
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
12 * This program is distributed in the hope that it will be useful, but
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
15 * Affero General Public License for more details.
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
16 *
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
17 * You should have received a copy of the GNU Affero General Public License
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
19 **/
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
20
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
21
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
22 #include "gtest/gtest.h"
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
23
708
51976977d2d3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 697
diff changeset
24 #include "../Framework/Loaders/BasicFetchingStrategy.h"
51976977d2d3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 697
diff changeset
25 #include "../Framework/Loaders/BasicFetchingItemsSorter.h"
695
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
26
708
51976977d2d3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 697
diff changeset
27 #include <Core/OrthancException.h>
695
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
28
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
29
697
14557e550920 BasicFetchingStrategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 695
diff changeset
30 namespace
14557e550920 BasicFetchingStrategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 695
diff changeset
31 {
14557e550920 BasicFetchingStrategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 695
diff changeset
32 class StrategyTester : public boost::noncopyable
14557e550920 BasicFetchingStrategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 695
diff changeset
33 {
14557e550920 BasicFetchingStrategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 695
diff changeset
34 private:
14557e550920 BasicFetchingStrategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 695
diff changeset
35 std::map<unsigned int, unsigned int> qualities_;
14557e550920 BasicFetchingStrategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 695
diff changeset
36
14557e550920 BasicFetchingStrategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 695
diff changeset
37 public:
14557e550920 BasicFetchingStrategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 695
diff changeset
38 bool IsValidCommand(unsigned int item,
14557e550920 BasicFetchingStrategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 695
diff changeset
39 unsigned int quality)
14557e550920 BasicFetchingStrategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 695
diff changeset
40 {
14557e550920 BasicFetchingStrategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 695
diff changeset
41 if (qualities_.find(item) != qualities_.end() &&
14557e550920 BasicFetchingStrategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 695
diff changeset
42 qualities_[item] >= quality)
14557e550920 BasicFetchingStrategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 695
diff changeset
43 {
14557e550920 BasicFetchingStrategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 695
diff changeset
44 return false;
14557e550920 BasicFetchingStrategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 695
diff changeset
45 }
14557e550920 BasicFetchingStrategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 695
diff changeset
46 else
14557e550920 BasicFetchingStrategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 695
diff changeset
47 {
14557e550920 BasicFetchingStrategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 695
diff changeset
48 qualities_[item] = quality;
14557e550920 BasicFetchingStrategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 695
diff changeset
49 return true;
14557e550920 BasicFetchingStrategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 695
diff changeset
50 }
14557e550920 BasicFetchingStrategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 695
diff changeset
51 }
14557e550920 BasicFetchingStrategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 695
diff changeset
52
14557e550920 BasicFetchingStrategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 695
diff changeset
53 bool HasFinished(OrthancStone::BasicFetchingStrategy& strategy)
14557e550920 BasicFetchingStrategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 695
diff changeset
54 {
14557e550920 BasicFetchingStrategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 695
diff changeset
55 for (unsigned int i = 0; i < strategy.GetItemsCount(); i++)
14557e550920 BasicFetchingStrategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 695
diff changeset
56 {
14557e550920 BasicFetchingStrategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 695
diff changeset
57 if (qualities_.find(i) == qualities_.end() ||
14557e550920 BasicFetchingStrategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 695
diff changeset
58 qualities_[i] != strategy.GetMaxQuality())
14557e550920 BasicFetchingStrategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 695
diff changeset
59 {
14557e550920 BasicFetchingStrategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 695
diff changeset
60 return false;
14557e550920 BasicFetchingStrategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 695
diff changeset
61 }
14557e550920 BasicFetchingStrategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 695
diff changeset
62 }
14557e550920 BasicFetchingStrategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 695
diff changeset
63
14557e550920 BasicFetchingStrategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 695
diff changeset
64 return true;
14557e550920 BasicFetchingStrategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 695
diff changeset
65 }
14557e550920 BasicFetchingStrategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 695
diff changeset
66 };
14557e550920 BasicFetchingStrategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 695
diff changeset
67 }
14557e550920 BasicFetchingStrategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 695
diff changeset
68
14557e550920 BasicFetchingStrategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 695
diff changeset
69
14557e550920 BasicFetchingStrategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 695
diff changeset
70 TEST(BasicFetchingStrategy, Test1)
695
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
71 {
697
14557e550920 BasicFetchingStrategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 695
diff changeset
72 ASSERT_THROW(OrthancStone::BasicFetchingStrategy(NULL, 0), Orthanc::OrthancException);
14557e550920 BasicFetchingStrategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 695
diff changeset
73 ASSERT_THROW(OrthancStone::BasicFetchingStrategy(new OrthancStone::BasicFetchingItemsSorter(0), 0), Orthanc::OrthancException);
14557e550920 BasicFetchingStrategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 695
diff changeset
74
14557e550920 BasicFetchingStrategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 695
diff changeset
75 {
14557e550920 BasicFetchingStrategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 695
diff changeset
76 OrthancStone::BasicFetchingStrategy s(new OrthancStone::BasicFetchingItemsSorter(1), 0);
14557e550920 BasicFetchingStrategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 695
diff changeset
77 unsigned int i, q;
14557e550920 BasicFetchingStrategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 695
diff changeset
78 ASSERT_TRUE(s.GetNext(i, q)); ASSERT_EQ(0u, i); ASSERT_EQ(0u, q);
14557e550920 BasicFetchingStrategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 695
diff changeset
79 ASSERT_FALSE(s.GetNext(i, q));
14557e550920 BasicFetchingStrategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 695
diff changeset
80 }
14557e550920 BasicFetchingStrategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 695
diff changeset
81
14557e550920 BasicFetchingStrategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 695
diff changeset
82 {
14557e550920 BasicFetchingStrategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 695
diff changeset
83 OrthancStone::BasicFetchingStrategy s(new OrthancStone::BasicFetchingItemsSorter(1), 5);
14557e550920 BasicFetchingStrategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 695
diff changeset
84 unsigned int i, q;
14557e550920 BasicFetchingStrategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 695
diff changeset
85 ASSERT_TRUE(s.GetNext(i, q)); ASSERT_EQ(0u, i); ASSERT_EQ(5u, q);
14557e550920 BasicFetchingStrategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 695
diff changeset
86 ASSERT_FALSE(s.GetNext(i, q));
14557e550920 BasicFetchingStrategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 695
diff changeset
87 }
14557e550920 BasicFetchingStrategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 695
diff changeset
88
14557e550920 BasicFetchingStrategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 695
diff changeset
89 {
14557e550920 BasicFetchingStrategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 695
diff changeset
90 OrthancStone::BasicFetchingStrategy s(new OrthancStone::BasicFetchingItemsSorter(2), 2);
14557e550920 BasicFetchingStrategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 695
diff changeset
91 unsigned int i, q;
14557e550920 BasicFetchingStrategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 695
diff changeset
92 ASSERT_TRUE(s.GetNext(i, q)); ASSERT_EQ(0u, i); ASSERT_EQ(2u, q);
14557e550920 BasicFetchingStrategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 695
diff changeset
93 ASSERT_TRUE(s.GetNext(i, q)); ASSERT_EQ(1u, i); ASSERT_EQ(1u, q);
14557e550920 BasicFetchingStrategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 695
diff changeset
94 ASSERT_TRUE(s.GetNext(i, q)); ASSERT_EQ(1u, i); ASSERT_EQ(2u, q);
14557e550920 BasicFetchingStrategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 695
diff changeset
95 ASSERT_FALSE(s.GetNext(i, q));
14557e550920 BasicFetchingStrategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 695
diff changeset
96 }
14557e550920 BasicFetchingStrategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 695
diff changeset
97
14557e550920 BasicFetchingStrategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 695
diff changeset
98 {
14557e550920 BasicFetchingStrategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 695
diff changeset
99 OrthancStone::BasicFetchingStrategy s(new OrthancStone::BasicFetchingItemsSorter(3), 2);
14557e550920 BasicFetchingStrategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 695
diff changeset
100 unsigned int i, q;
14557e550920 BasicFetchingStrategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 695
diff changeset
101 ASSERT_TRUE(s.GetNext(i, q)); ASSERT_EQ(0u, i); ASSERT_EQ(2u, q);
14557e550920 BasicFetchingStrategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 695
diff changeset
102 ASSERT_TRUE(s.GetNext(i, q)); ASSERT_EQ(1u, i); ASSERT_EQ(1u, q);
14557e550920 BasicFetchingStrategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 695
diff changeset
103 ASSERT_TRUE(s.GetNext(i, q)); ASSERT_EQ(2u, i); ASSERT_EQ(1u, q);
14557e550920 BasicFetchingStrategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 695
diff changeset
104 ASSERT_TRUE(s.GetNext(i, q)); ASSERT_EQ(1u, i); ASSERT_EQ(2u, q);
14557e550920 BasicFetchingStrategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 695
diff changeset
105 ASSERT_TRUE(s.GetNext(i, q)); ASSERT_EQ(2u, i); ASSERT_EQ(2u, q);
14557e550920 BasicFetchingStrategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 695
diff changeset
106 ASSERT_FALSE(s.GetNext(i, q));
14557e550920 BasicFetchingStrategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 695
diff changeset
107 }
14557e550920 BasicFetchingStrategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 695
diff changeset
108
14557e550920 BasicFetchingStrategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 695
diff changeset
109 {
14557e550920 BasicFetchingStrategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 695
diff changeset
110 OrthancStone::BasicFetchingStrategy s(new OrthancStone::BasicFetchingItemsSorter(3), 2);
14557e550920 BasicFetchingStrategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 695
diff changeset
111 s.SetBlockSize(1);
14557e550920 BasicFetchingStrategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 695
diff changeset
112 s.SetCurrent(0);
14557e550920 BasicFetchingStrategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 695
diff changeset
113 unsigned int i, q;
14557e550920 BasicFetchingStrategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 695
diff changeset
114 ASSERT_TRUE(s.GetNext(i, q)); ASSERT_EQ(0u, i); ASSERT_EQ(2u, q);
14557e550920 BasicFetchingStrategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 695
diff changeset
115 ASSERT_TRUE(s.GetNext(i, q)); ASSERT_EQ(1u, i); ASSERT_EQ(1u, q);
14557e550920 BasicFetchingStrategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 695
diff changeset
116 ASSERT_TRUE(s.GetNext(i, q)); ASSERT_EQ(1u, i); ASSERT_EQ(2u, q);
14557e550920 BasicFetchingStrategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 695
diff changeset
117 ASSERT_TRUE(s.GetNext(i, q)); ASSERT_EQ(2u, i); ASSERT_EQ(0u, q);
14557e550920 BasicFetchingStrategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 695
diff changeset
118 ASSERT_TRUE(s.GetNext(i, q)); ASSERT_EQ(2u, i); ASSERT_EQ(1u, q);
14557e550920 BasicFetchingStrategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 695
diff changeset
119 ASSERT_TRUE(s.GetNext(i, q)); ASSERT_EQ(2u, i); ASSERT_EQ(2u, q);
14557e550920 BasicFetchingStrategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 695
diff changeset
120 ASSERT_FALSE(s.GetNext(i, q));
14557e550920 BasicFetchingStrategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 695
diff changeset
121 }
14557e550920 BasicFetchingStrategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 695
diff changeset
122
14557e550920 BasicFetchingStrategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 695
diff changeset
123 {
14557e550920 BasicFetchingStrategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 695
diff changeset
124 OrthancStone::BasicFetchingStrategy s(new OrthancStone::BasicFetchingItemsSorter(5), 0);
14557e550920 BasicFetchingStrategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 695
diff changeset
125 ASSERT_THROW(s.SetCurrent(5), Orthanc::OrthancException);
14557e550920 BasicFetchingStrategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 695
diff changeset
126 s.SetCurrent(2);
14557e550920 BasicFetchingStrategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 695
diff changeset
127
14557e550920 BasicFetchingStrategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 695
diff changeset
128 unsigned int i, q;
14557e550920 BasicFetchingStrategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 695
diff changeset
129 ASSERT_TRUE(s.GetNext(i, q)); ASSERT_EQ(2u, i); ASSERT_EQ(0u, q);
14557e550920 BasicFetchingStrategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 695
diff changeset
130 ASSERT_TRUE(s.GetNext(i, q)); ASSERT_EQ(3u, i); ASSERT_EQ(0u, q);
14557e550920 BasicFetchingStrategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 695
diff changeset
131 ASSERT_TRUE(s.GetNext(i, q)); ASSERT_EQ(1u, i); ASSERT_EQ(0u, q);
14557e550920 BasicFetchingStrategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 695
diff changeset
132 ASSERT_TRUE(s.GetNext(i, q)); ASSERT_EQ(4u, i); ASSERT_EQ(0u, q);
14557e550920 BasicFetchingStrategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 695
diff changeset
133 ASSERT_TRUE(s.GetNext(i, q)); ASSERT_EQ(0u, i); ASSERT_EQ(0u, q);
14557e550920 BasicFetchingStrategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 695
diff changeset
134 ASSERT_FALSE(s.GetNext(i, q));
14557e550920 BasicFetchingStrategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 695
diff changeset
135 }
14557e550920 BasicFetchingStrategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 695
diff changeset
136
14557e550920 BasicFetchingStrategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 695
diff changeset
137 {
14557e550920 BasicFetchingStrategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 695
diff changeset
138 OrthancStone::BasicFetchingStrategy s(new OrthancStone::BasicFetchingItemsSorter(5), 0);
14557e550920 BasicFetchingStrategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 695
diff changeset
139 s.SetCurrent(4);
14557e550920 BasicFetchingStrategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 695
diff changeset
140
14557e550920 BasicFetchingStrategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 695
diff changeset
141 unsigned int i, q;
14557e550920 BasicFetchingStrategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 695
diff changeset
142 ASSERT_TRUE(s.GetNext(i, q)); ASSERT_EQ(4u, i); ASSERT_EQ(0u, q);
14557e550920 BasicFetchingStrategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 695
diff changeset
143 ASSERT_TRUE(s.GetNext(i, q)); ASSERT_EQ(3u, i); ASSERT_EQ(0u, q);
14557e550920 BasicFetchingStrategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 695
diff changeset
144 ASSERT_TRUE(s.GetNext(i, q)); ASSERT_EQ(2u, i); ASSERT_EQ(0u, q);
14557e550920 BasicFetchingStrategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 695
diff changeset
145 ASSERT_TRUE(s.GetNext(i, q)); ASSERT_EQ(1u, i); ASSERT_EQ(0u, q);
14557e550920 BasicFetchingStrategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 695
diff changeset
146 ASSERT_TRUE(s.GetNext(i, q)); ASSERT_EQ(0u, i); ASSERT_EQ(0u, q);
14557e550920 BasicFetchingStrategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 695
diff changeset
147 ASSERT_FALSE(s.GetNext(i, q));
14557e550920 BasicFetchingStrategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 695
diff changeset
148 }
14557e550920 BasicFetchingStrategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 695
diff changeset
149 }
14557e550920 BasicFetchingStrategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 695
diff changeset
150
14557e550920 BasicFetchingStrategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 695
diff changeset
151
14557e550920 BasicFetchingStrategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 695
diff changeset
152 TEST(BasicFetchingStrategy, Test2)
14557e550920 BasicFetchingStrategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 695
diff changeset
153 {
14557e550920 BasicFetchingStrategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 695
diff changeset
154 OrthancStone::BasicFetchingStrategy s(new OrthancStone::BasicFetchingItemsSorter(20), 2);
14557e550920 BasicFetchingStrategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 695
diff changeset
155 ASSERT_EQ(20u, s.GetItemsCount());
14557e550920 BasicFetchingStrategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 695
diff changeset
156 ASSERT_EQ(2u, s.GetMaxQuality());
14557e550920 BasicFetchingStrategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 695
diff changeset
157
14557e550920 BasicFetchingStrategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 695
diff changeset
158 StrategyTester t;
14557e550920 BasicFetchingStrategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 695
diff changeset
159
14557e550920 BasicFetchingStrategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 695
diff changeset
160 s.SetCurrent(10);
14557e550920 BasicFetchingStrategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 695
diff changeset
161
14557e550920 BasicFetchingStrategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 695
diff changeset
162 unsigned int i, q;
14557e550920 BasicFetchingStrategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 695
diff changeset
163 while (s.GetNext(i, q))
14557e550920 BasicFetchingStrategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 695
diff changeset
164 {
14557e550920 BasicFetchingStrategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 695
diff changeset
165 ASSERT_TRUE(t.IsValidCommand(i, q));
14557e550920 BasicFetchingStrategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 695
diff changeset
166 }
14557e550920 BasicFetchingStrategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 695
diff changeset
167
14557e550920 BasicFetchingStrategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 695
diff changeset
168 ASSERT_TRUE(t.HasFinished(s));
695
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
169 }
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
170
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
171
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
172
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
173
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
174 TEST(BasicFetchingItemsSorter, Small)
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
175 {
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
176 ASSERT_THROW(OrthancStone::BasicFetchingItemsSorter(0), Orthanc::OrthancException);
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
177 std::vector<unsigned int> v;
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
178
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
179 {
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
180 OrthancStone::BasicFetchingItemsSorter s(1);
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
181 s.Sort(v, 0);
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
182 ASSERT_EQ(1u, v.size());
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
183 ASSERT_EQ(0u, v[0]);
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
184
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
185 ASSERT_THROW(s.Sort(v, 1), Orthanc::OrthancException);
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
186 }
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
187
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
188 {
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
189 OrthancStone::BasicFetchingItemsSorter s(2);
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
190 s.Sort(v, 0);
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
191 ASSERT_EQ(2u, v.size());
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
192 ASSERT_EQ(0u, v[0]);
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
193 ASSERT_EQ(1u, v[1]);
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
194
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
195 s.Sort(v, 1);
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
196 ASSERT_EQ(2u, v.size());
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
197 ASSERT_EQ(1u, v[0]);
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
198 ASSERT_EQ(0u, v[1]);
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
199
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
200 ASSERT_THROW(s.Sort(v, 2), Orthanc::OrthancException);
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
201 }
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
202
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
203 {
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
204 OrthancStone::BasicFetchingItemsSorter s(3);
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
205 s.Sort(v, 0);
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
206 ASSERT_EQ(3u, v.size());
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
207 ASSERT_EQ(0u, v[0]);
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
208 ASSERT_EQ(1u, v[1]);
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
209 ASSERT_EQ(2u, v[2]);
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
210
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
211 s.Sort(v, 1);
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
212 ASSERT_EQ(3u, v.size());
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
213 ASSERT_EQ(1u, v[0]);
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
214 ASSERT_EQ(2u, v[1]);
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
215 ASSERT_EQ(0u, v[2]);
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
216
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
217 s.Sort(v, 2);
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
218 ASSERT_EQ(3u, v.size());
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
219 ASSERT_EQ(2u, v[0]);
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
220 ASSERT_EQ(1u, v[1]);
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
221 ASSERT_EQ(0u, v[2]);
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
222
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
223 ASSERT_THROW(s.Sort(v, 3), Orthanc::OrthancException);
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
224 }
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
225 }
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
226
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
227
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
228 TEST(BasicFetchingItemsSorter, Odd)
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
229 {
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
230 OrthancStone::BasicFetchingItemsSorter s(7);
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
231 std::vector<unsigned int> v;
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
232
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
233 ASSERT_THROW(s.Sort(v, 7), Orthanc::OrthancException);
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
234
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
235 {
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
236 s.Sort(v, 0);
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
237 ASSERT_EQ(7u, v.size());
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
238 ASSERT_EQ(0u, v[0]);
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
239 ASSERT_EQ(1u, v[1]);
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
240 ASSERT_EQ(2u, v[2]);
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
241 ASSERT_EQ(3u, v[3]);
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
242 ASSERT_EQ(4u, v[4]);
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
243 ASSERT_EQ(5u, v[5]);
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
244 ASSERT_EQ(6u, v[6]);
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
245 }
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
246
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
247 {
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
248 s.Sort(v, 1);
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
249 ASSERT_EQ(7u, v.size());
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
250 ASSERT_EQ(1u, v[0]);
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
251 ASSERT_EQ(2u, v[1]);
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
252 ASSERT_EQ(0u, v[2]);
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
253 ASSERT_EQ(3u, v[3]);
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
254 ASSERT_EQ(4u, v[4]);
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
255 ASSERT_EQ(5u, v[5]);
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
256 ASSERT_EQ(6u, v[6]);
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
257 }
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
258
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
259 {
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
260 s.Sort(v, 2);
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
261 ASSERT_EQ(7u, v.size());
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
262 ASSERT_EQ(2u, v[0]);
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
263 ASSERT_EQ(3u, v[1]);
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
264 ASSERT_EQ(1u, v[2]);
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
265 ASSERT_EQ(4u, v[3]);
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
266 ASSERT_EQ(0u, v[4]);
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
267 ASSERT_EQ(5u, v[5]);
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
268 ASSERT_EQ(6u, v[6]);
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
269 }
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
270
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
271 {
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
272 s.Sort(v, 3);
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
273 ASSERT_EQ(7u, v.size());
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
274 ASSERT_EQ(3u, v[0]);
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
275 ASSERT_EQ(4u, v[1]);
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
276 ASSERT_EQ(2u, v[2]);
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
277 ASSERT_EQ(5u, v[3]);
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
278 ASSERT_EQ(1u, v[4]);
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
279 ASSERT_EQ(6u, v[5]);
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
280 ASSERT_EQ(0u, v[6]);
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
281 }
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
282
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
283 {
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
284 s.Sort(v, 4);
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
285 ASSERT_EQ(7u, v.size());
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
286 ASSERT_EQ(4u, v[0]);
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
287 ASSERT_EQ(5u, v[1]);
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
288 ASSERT_EQ(3u, v[2]);
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
289 ASSERT_EQ(6u, v[3]);
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
290 ASSERT_EQ(2u, v[4]);
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
291 ASSERT_EQ(1u, v[5]);
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
292 ASSERT_EQ(0u, v[6]);
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
293 }
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
294
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
295 {
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
296 s.Sort(v, 5);
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
297 ASSERT_EQ(7u, v.size());
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
298 ASSERT_EQ(5u, v[0]);
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
299 ASSERT_EQ(6u, v[1]);
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
300 ASSERT_EQ(4u, v[2]);
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
301 ASSERT_EQ(3u, v[3]);
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
302 ASSERT_EQ(2u, v[4]);
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
303 ASSERT_EQ(1u, v[5]);
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
304 ASSERT_EQ(0u, v[6]);
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
305 }
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
306
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
307 {
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
308 s.Sort(v, 6);
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
309 ASSERT_EQ(7u, v.size());
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
310 ASSERT_EQ(6u, v[0]);
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
311 ASSERT_EQ(5u, v[1]);
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
312 ASSERT_EQ(4u, v[2]);
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
313 ASSERT_EQ(3u, v[3]);
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
314 ASSERT_EQ(2u, v[4]);
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
315 ASSERT_EQ(1u, v[5]);
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
316 ASSERT_EQ(0u, v[6]);
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
317 }
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
318 }
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
319
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
320
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
321 TEST(BasicFetchingItemsSorter, Even)
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
322 {
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
323 OrthancStone::BasicFetchingItemsSorter s(6);
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
324 std::vector<unsigned int> v;
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
325
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
326 {
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
327 s.Sort(v, 0);
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
328 ASSERT_EQ(6u, v.size());
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
329 ASSERT_EQ(0u, v[0]);
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
330 ASSERT_EQ(1u, v[1]);
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
331 ASSERT_EQ(2u, v[2]);
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
332 ASSERT_EQ(3u, v[3]);
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
333 ASSERT_EQ(4u, v[4]);
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
334 ASSERT_EQ(5u, v[5]);
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
335 }
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
336
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
337 {
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
338 s.Sort(v, 1);
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
339 ASSERT_EQ(6u, v.size());
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
340 ASSERT_EQ(1u, v[0]);
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
341 ASSERT_EQ(2u, v[1]);
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
342 ASSERT_EQ(0u, v[2]);
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
343 ASSERT_EQ(3u, v[3]);
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
344 ASSERT_EQ(4u, v[4]);
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
345 ASSERT_EQ(5u, v[5]);
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
346 }
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
347
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
348 {
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
349 s.Sort(v, 2);
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
350 ASSERT_EQ(6u, v.size());
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
351 ASSERT_EQ(2u, v[0]);
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
352 ASSERT_EQ(3u, v[1]);
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
353 ASSERT_EQ(1u, v[2]);
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
354 ASSERT_EQ(4u, v[3]);
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
355 ASSERT_EQ(0u, v[4]);
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
356 ASSERT_EQ(5u, v[5]);
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
357 }
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
358
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
359 {
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
360 s.Sort(v, 3);
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
361 ASSERT_EQ(6u, v.size());
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
362 ASSERT_EQ(3u, v[0]);
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
363 ASSERT_EQ(4u, v[1]);
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
364 ASSERT_EQ(2u, v[2]);
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
365 ASSERT_EQ(5u, v[3]);
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
366 ASSERT_EQ(1u, v[4]);
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
367 ASSERT_EQ(0u, v[5]);
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
368 }
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
369
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
370 {
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
371 s.Sort(v, 4);
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
372 ASSERT_EQ(6u, v.size());
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
373 ASSERT_EQ(4u, v[0]);
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
374 ASSERT_EQ(5u, v[1]);
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
375 ASSERT_EQ(3u, v[2]);
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
376 ASSERT_EQ(2u, v[3]);
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
377 ASSERT_EQ(1u, v[4]);
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
378 ASSERT_EQ(0u, v[5]);
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
379 }
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
380
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
381 {
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
382 s.Sort(v, 5);
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
383 ASSERT_EQ(6u, v.size());
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
384 ASSERT_EQ(5u, v[0]);
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
385 ASSERT_EQ(4u, v[1]);
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
386 ASSERT_EQ(3u, v[2]);
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
387 ASSERT_EQ(2u, v[3]);
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
388 ASSERT_EQ(1u, v[4]);
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
389 ASSERT_EQ(0u, v[5]);
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
390 }
7bf91c4ebd65 strategy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
391 }