annotate OrthancStone/UnitTestsSources/TestStrategy.cpp @ 1890:6ce81914f7e4

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