3 #include "stg/tariff_conf.h"
4 #include "tariff_impl.h"
11 typedef test_group<tariff_data> tg;
12 tg tariff_test_group("TARIFF tests group");
14 typedef tg::object testobject;
18 void testobject::test<1>()
20 set_test_name("Check construction");
22 TARIFF_DATA td("test");
23 td.tariffConf.fee = 1;
24 td.tariffConf.free = 2;
25 td.tariffConf.traffType = TARIFF::TRAFF_UP_DOWN;
26 td.tariffConf.passiveCost = 4;
27 td.dirPrice[0].mDay = 30;
28 td.dirPrice[0].hDay = 9;
29 td.dirPrice[0].mNight = 30;
30 td.dirPrice[0].hNight = 21;
31 td.dirPrice[0].priceDayA = 0;
32 td.dirPrice[0].priceDayB = 1;
33 td.dirPrice[0].priceNightA = 2;
34 td.dirPrice[0].priceNightB = 3;
35 td.dirPrice[0].threshold = 4;
36 td.dirPrice[0].singlePrice = 0;
37 td.dirPrice[0].noDiscount = 0;
38 TARIFF_IMPL tariff(td);
40 ensure("freeMb = 2", tariff.GetFreeMb() == td.tariffConf.free);
41 ensure("passiveCost = 4", tariff.GetPassiveCost() == td.tariffConf.passiveCost);
42 ensure("fee = 1", tariff.GetFee() == td.tariffConf.fee);
43 ensure("free (alias of freeMb) = 2", tariff.GetFree() == td.tariffConf.free);
44 ensure("name = \"test\"'", tariff.GetName() == td.tariffConf.name);
45 ensure("traffType = TRAFF_UP_DOWN", tariff.GetTraffType() == td.tariffConf.traffType);
46 ensure("threshold[0] = 4", tariff.GetThreshold(0) == td.dirPrice[0].threshold);
47 ensure_equals("traffByType(6, 0) = 6", tariff.GetTraffByType(6, 0), 6);
48 ensure_equals("traffByType(5, 1) = 6", tariff.GetTraffByType(5, 1), 6);
49 ensure_equals("traffByType(4, 2) = 6", tariff.GetTraffByType(4, 2), 6);
50 ensure_equals("traffByType(3, 3) = 6", tariff.GetTraffByType(3, 3), 6);
51 ensure_equals("traffByType(2, 4) = 6", tariff.GetTraffByType(2, 4), 6);
52 ensure_equals("traffByType(1, 5) = 6", tariff.GetTraffByType(1, 5), 6);
53 ensure_equals("traffByType(0, 6) = 6", tariff.GetTraffByType(0, 6), 6);
58 void testobject::test<2>()
60 set_test_name("Check traff types");
62 TARIFF_DATA td("test");
63 td.tariffConf.fee = 1;
64 td.tariffConf.free = 2;
65 td.tariffConf.traffType = TARIFF::TRAFF_UP;
66 td.tariffConf.passiveCost = 4;
67 td.dirPrice[0].mDay = 30;
68 td.dirPrice[0].hDay = 9;
69 td.dirPrice[0].mNight = 30;
70 td.dirPrice[0].hNight = 21;
71 td.dirPrice[0].priceDayA = 0;
72 td.dirPrice[0].priceDayB = 1;
73 td.dirPrice[0].priceNightA = 2;
74 td.dirPrice[0].priceNightB = 3;
75 td.dirPrice[0].threshold = 4;
76 td.dirPrice[0].singlePrice = 0;
77 td.dirPrice[0].noDiscount = 0;
78 TARIFF_IMPL tariff(td);
80 ensure("traffType = TRAFF_UP", tariff.GetTraffType() == TARIFF::TRAFF_UP);
81 ensure_equals("traffByType(6, 0) = 6 for UP", tariff.GetTraffByType(6, 0), 6);
82 ensure_equals("traffByType(5, 1) = 5 for UP", tariff.GetTraffByType(5, 1), 5);
83 ensure_equals("traffByType(4, 2) = 4 for UP", tariff.GetTraffByType(4, 2), 4);
84 ensure_equals("traffByType(3, 3) = 3 for UP", tariff.GetTraffByType(3, 3), 3);
85 ensure_equals("traffByType(2, 4) = 2 for UP", tariff.GetTraffByType(2, 4), 2);
86 ensure_equals("traffByType(1, 5) = 1 for UP", tariff.GetTraffByType(1, 5), 1);
87 ensure_equals("traffByType(0, 6) = 0 for UP", tariff.GetTraffByType(0, 6), 0);
89 td.tariffConf.traffType = TARIFF::TRAFF_DOWN;
92 ensure("traffType = TRAFF_DOWN", tariff.GetTraffType() == TARIFF::TRAFF_DOWN);
93 ensure_equals("traffByType(6, 0) = 0 for DOWN", tariff.GetTraffByType(6, 0), 0);
94 ensure_equals("traffByType(5, 1) = 1 for DOWN", tariff.GetTraffByType(5, 1), 1);
95 ensure_equals("traffByType(4, 2) = 2 for DOWN", tariff.GetTraffByType(4, 2), 2);
96 ensure_equals("traffByType(3, 3) = 3 for DOWN", tariff.GetTraffByType(3, 3), 3);
97 ensure_equals("traffByType(2, 4) = 4 for DOWN", tariff.GetTraffByType(2, 4), 4);
98 ensure_equals("traffByType(1, 5) = 5 for DOWN", tariff.GetTraffByType(1, 5), 5);
99 ensure_equals("traffByType(0, 6) = 6 for DOWN", tariff.GetTraffByType(0, 6), 6);
101 td.tariffConf.traffType = TARIFF::TRAFF_MAX;
104 ensure("traffType = TRAFF_MAX", tariff.GetTraffType() == TARIFF::TRAFF_MAX);
105 ensure_equals("traffByType(6, 0) = 6 for MAX", tariff.GetTraffByType(6, 0), 6);
106 ensure_equals("traffByType(5, 1) = 5 for MAX", tariff.GetTraffByType(5, 1), 5);
107 ensure_equals("traffByType(4, 2) = 4 for MAX", tariff.GetTraffByType(4, 2), 4);
108 ensure_equals("traffByType(3, 3) = 3 for MAX", tariff.GetTraffByType(3, 3), 3);
109 ensure_equals("traffByType(2, 4) = 4 for MAX", tariff.GetTraffByType(2, 4), 4);
110 ensure_equals("traffByType(1, 5) = 5 for MAX", tariff.GetTraffByType(1, 5), 5);
111 ensure_equals("traffByType(0, 6) = 6 for MAX", tariff.GetTraffByType(0, 6), 6);
113 td.tariffConf.traffType = TARIFF::TRAFF_UP_DOWN;
116 ensure("traffType = TRAFF_UP_DOWN", tariff.GetTraffType() == TARIFF::TRAFF_UP_DOWN);
117 ensure_equals("traffByType(6, 0) = 6 for UP_DOWN", tariff.GetTraffByType(6, 0), 6);
118 ensure_equals("traffByType(5, 1) = 6 for UP_DOWN", tariff.GetTraffByType(5, 1), 6);
119 ensure_equals("traffByType(4, 2) = 6 for UP_DOWN", tariff.GetTraffByType(4, 2), 6);
120 ensure_equals("traffByType(3, 3) = 6 for UP_DOWN", tariff.GetTraffByType(3, 3), 6);
121 ensure_equals("traffByType(2, 4) = 6 for UP_DOWN", tariff.GetTraffByType(2, 4), 6);
122 ensure_equals("traffByType(1, 5) = 6 for UP_DOWN", tariff.GetTraffByType(1, 5), 6);
123 ensure_equals("traffByType(0, 6) = 6 for UP_DOWN", tariff.GetTraffByType(0, 6), 6);
128 void testobject::test<3>()
130 set_test_name("Check normal interval prices");
132 TARIFF_DATA td("test");
133 td.tariffConf.fee = 1;
134 td.tariffConf.free = 2;
135 td.tariffConf.traffType = TARIFF::TRAFF_UP_DOWN;
136 td.tariffConf.passiveCost = 4;
137 td.dirPrice[0].mDay = 30;
138 td.dirPrice[0].hDay = 9;
139 td.dirPrice[0].mNight = 30;
140 td.dirPrice[0].hNight = 21;
141 td.dirPrice[0].priceDayA = 0;
142 td.dirPrice[0].priceDayB = 1;
143 td.dirPrice[0].priceNightA = 2;
144 td.dirPrice[0].priceNightB = 3;
145 td.dirPrice[0].threshold = 4;
146 td.dirPrice[0].singlePrice = 0;
147 td.dirPrice[0].noDiscount = 0;
148 TARIFF_IMPL tariff(td);
150 ensure_equals("0000 == 0", tariff.GetPriceWithTraffType(0, 0 * 1024 * 1024, 0, 1286461245), 0); // Near 17:30, 0 < 4 DA
151 ensure_equals("0001 == 0", tariff.GetPriceWithTraffType(0, 6 * 1024 * 1024, 0, 1286461245), 1); // Near 17:30, 6 > 4 DB
152 ensure_equals("0010 == 0", tariff.GetPriceWithTraffType(0, 0 * 1024 * 1024, 0, 1286479245), 2); // Near 22:30, 0 < 4 NA
153 ensure_equals("0011 == 0", tariff.GetPriceWithTraffType(0, 6 * 1024 * 1024, 0, 1286479245), 3); // Near 22:30, 6 > 4 NB
155 td.dirPrice[0].singlePrice = 1;
158 ensure_equals("0100 == 0", tariff.GetPriceWithTraffType(0, 0 * 1024 * 1024, 0, 1286461245), 0); // Near 17:30, 0 < 4 DA
159 ensure_equals("0101 == 0", tariff.GetPriceWithTraffType(0, 6 * 1024 * 1024, 0, 1286461245), 1); // Near 17:30, 6 > 4 DB
160 ensure_equals("0110 == 0", tariff.GetPriceWithTraffType(0, 0 * 1024 * 1024, 0, 1286479245), 0); // Near 22:30, 0 < 4 DA
161 ensure_equals("0111 == 0", tariff.GetPriceWithTraffType(0, 6 * 1024 * 1024, 0, 1286479245), 1); // Near 22:30, 6 > 4 DB
163 td.dirPrice[0].singlePrice = 0;
164 td.dirPrice[0].noDiscount = 1;
167 ensure_equals("1000 == 0", tariff.GetPriceWithTraffType(0, 0 * 1024 * 1024, 0, 1286461245), 0); // Near 17:30, 0 < 4 DA
168 ensure_equals("1001 == 0", tariff.GetPriceWithTraffType(0, 6 * 1024 * 1024, 0, 1286461245), 0); // Near 17:30, 6 > 4 DA
169 ensure_equals("1010 == 0", tariff.GetPriceWithTraffType(0, 0 * 1024 * 1024, 0, 1286479245), 2); // Near 22:30, 0 < 4 NA
170 ensure_equals("1011 == 0", tariff.GetPriceWithTraffType(0, 6 * 1024 * 1024, 0, 1286479245), 2); // Near 22:30, 6 > 4 NA
172 td.dirPrice[0].singlePrice = 1;
173 td.dirPrice[0].noDiscount = 1;
176 ensure_equals("1100 == 0", tariff.GetPriceWithTraffType(0, 0 * 1024 * 1024, 0, 1286461245), 0); // Near 17:30, 0 < 4 DA
177 ensure_equals("1101 == 0", tariff.GetPriceWithTraffType(0, 6 * 1024 * 1024, 0, 1286461245), 0); // Near 17:30, 6 > 4 DA
178 ensure_equals("1110 == 0", tariff.GetPriceWithTraffType(0, 0 * 1024 * 1024, 0, 1286479245), 0); // Near 22:30, 0 < 4 DA
179 ensure_equals("1111 == 0", tariff.GetPriceWithTraffType(0, 6 * 1024 * 1024, 0, 1286479245), 0); // Near 22:30, 6 > 4 DA
184 void testobject::test<4>()
186 set_test_name("Check construction for day-night inversion");
188 TARIFF_DATA td("test");
189 td.tariffConf.fee = 1;
190 td.tariffConf.free = 2;
191 td.tariffConf.traffType = TARIFF::TRAFF_UP_DOWN;
192 td.tariffConf.passiveCost = 4;
193 td.dirPrice[0].mDay = 30;
194 td.dirPrice[0].hDay = 21;
195 td.dirPrice[0].mNight = 30;
196 td.dirPrice[0].hNight = 9;
197 td.dirPrice[0].priceDayA = 0;
198 td.dirPrice[0].priceDayB = 1;
199 td.dirPrice[0].priceNightA = 2;
200 td.dirPrice[0].priceNightB = 3;
201 td.dirPrice[0].threshold = 4;
202 td.dirPrice[0].singlePrice = 0;
203 td.dirPrice[0].noDiscount = 0;
204 TARIFF_IMPL tariff(td);
206 ensure("freeMb = 2", tariff.GetFreeMb() == td.tariffConf.free);
207 ensure("passiveCost = 4", tariff.GetPassiveCost() == td.tariffConf.passiveCost);
208 ensure("fee = 1", tariff.GetFee() == td.tariffConf.fee);
209 ensure("free (alias of freeMb) = 2", tariff.GetFree() == td.tariffConf.free);
210 ensure("name = \"test\"'", tariff.GetName() == td.tariffConf.name);
211 ensure("traffType = TRAFF_UP_DOWN", tariff.GetTraffType() == td.tariffConf.traffType);
212 ensure("threshold[0] = 4", tariff.GetThreshold(0) == td.dirPrice[0].threshold);
213 ensure_equals("traffByType(6, 0) = 6", tariff.GetTraffByType(6, 0), 6);
214 ensure_equals("traffByType(5, 1) = 6", tariff.GetTraffByType(5, 1), 6);
215 ensure_equals("traffByType(4, 2) = 6", tariff.GetTraffByType(4, 2), 6);
216 ensure_equals("traffByType(3, 3) = 6", tariff.GetTraffByType(3, 3), 6);
217 ensure_equals("traffByType(2, 4) = 6", tariff.GetTraffByType(2, 4), 6);
218 ensure_equals("traffByType(1, 5) = 6", tariff.GetTraffByType(1, 5), 6);
219 ensure_equals("traffByType(0, 6) = 6", tariff.GetTraffByType(0, 6), 6);
224 void testobject::test<5>()
226 set_test_name("Check traff types for day-night inversion");
228 TARIFF_DATA td("test");
229 td.tariffConf.fee = 1;
230 td.tariffConf.free = 2;
231 td.tariffConf.traffType = TARIFF::TRAFF_UP;
232 td.tariffConf.passiveCost = 4;
233 td.dirPrice[0].mDay = 30;
234 td.dirPrice[0].hDay = 21;
235 td.dirPrice[0].mNight = 30;
236 td.dirPrice[0].hNight = 9;
237 td.dirPrice[0].priceDayA = 0;
238 td.dirPrice[0].priceDayB = 1;
239 td.dirPrice[0].priceNightA = 2;
240 td.dirPrice[0].priceNightB = 3;
241 td.dirPrice[0].threshold = 4;
242 td.dirPrice[0].singlePrice = 0;
243 td.dirPrice[0].noDiscount = 0;
244 TARIFF_IMPL tariff(td);
246 ensure("traffType = TRAFF_UP", tariff.GetTraffType() == TARIFF::TRAFF_UP);
247 ensure_equals("traffByType(6, 0) = 6 for UP", tariff.GetTraffByType(6, 0), 6);
248 ensure_equals("traffByType(5, 1) = 5 for UP", tariff.GetTraffByType(5, 1), 5);
249 ensure_equals("traffByType(4, 2) = 4 for UP", tariff.GetTraffByType(4, 2), 4);
250 ensure_equals("traffByType(3, 3) = 3 for UP", tariff.GetTraffByType(3, 3), 3);
251 ensure_equals("traffByType(2, 4) = 2 for UP", tariff.GetTraffByType(2, 4), 2);
252 ensure_equals("traffByType(1, 5) = 1 for UP", tariff.GetTraffByType(1, 5), 1);
253 ensure_equals("traffByType(0, 6) = 0 for UP", tariff.GetTraffByType(0, 6), 0);
255 td.tariffConf.traffType = TARIFF::TRAFF_DOWN;
258 ensure("traffType = TRAFF_DOWN", tariff.GetTraffType() == TARIFF::TRAFF_DOWN);
259 ensure_equals("traffByType(6, 0) = 0 for DOWN", tariff.GetTraffByType(6, 0), 0);
260 ensure_equals("traffByType(5, 1) = 1 for DOWN", tariff.GetTraffByType(5, 1), 1);
261 ensure_equals("traffByType(4, 2) = 2 for DOWN", tariff.GetTraffByType(4, 2), 2);
262 ensure_equals("traffByType(3, 3) = 3 for DOWN", tariff.GetTraffByType(3, 3), 3);
263 ensure_equals("traffByType(2, 4) = 4 for DOWN", tariff.GetTraffByType(2, 4), 4);
264 ensure_equals("traffByType(1, 5) = 5 for DOWN", tariff.GetTraffByType(1, 5), 5);
265 ensure_equals("traffByType(0, 6) = 6 for DOWN", tariff.GetTraffByType(0, 6), 6);
267 td.tariffConf.traffType = TARIFF::TRAFF_MAX;
270 ensure("traffType = TRAFF_MAX", tariff.GetTraffType() == TARIFF::TRAFF_MAX);
271 ensure_equals("traffByType(6, 0) = 6 for MAX", tariff.GetTraffByType(6, 0), 6);
272 ensure_equals("traffByType(5, 1) = 5 for MAX", tariff.GetTraffByType(5, 1), 5);
273 ensure_equals("traffByType(4, 2) = 4 for MAX", tariff.GetTraffByType(4, 2), 4);
274 ensure_equals("traffByType(3, 3) = 3 for MAX", tariff.GetTraffByType(3, 3), 3);
275 ensure_equals("traffByType(2, 4) = 4 for MAX", tariff.GetTraffByType(2, 4), 4);
276 ensure_equals("traffByType(1, 5) = 5 for MAX", tariff.GetTraffByType(1, 5), 5);
277 ensure_equals("traffByType(0, 6) = 6 for MAX", tariff.GetTraffByType(0, 6), 6);
279 td.tariffConf.traffType = TARIFF::TRAFF_UP_DOWN;
282 ensure("traffType = TRAFF_UP_DOWN", tariff.GetTraffType() == TARIFF::TRAFF_UP_DOWN);
283 ensure_equals("traffByType(6, 0) = 6 for UP_DOWN", tariff.GetTraffByType(6, 0), 6);
284 ensure_equals("traffByType(5, 1) = 6 for UP_DOWN", tariff.GetTraffByType(5, 1), 6);
285 ensure_equals("traffByType(4, 2) = 6 for UP_DOWN", tariff.GetTraffByType(4, 2), 6);
286 ensure_equals("traffByType(3, 3) = 6 for UP_DOWN", tariff.GetTraffByType(3, 3), 6);
287 ensure_equals("traffByType(2, 4) = 6 for UP_DOWN", tariff.GetTraffByType(2, 4), 6);
288 ensure_equals("traffByType(1, 5) = 6 for UP_DOWN", tariff.GetTraffByType(1, 5), 6);
289 ensure_equals("traffByType(0, 6) = 6 for UP_DOWN", tariff.GetTraffByType(0, 6), 6);
294 void testobject::test<6>()
296 set_test_name("Check normal interval prices for day-night inversion");
298 TARIFF_DATA td("test");
299 td.tariffConf.fee = 1;
300 td.tariffConf.free = 2;
301 td.tariffConf.traffType = TARIFF::TRAFF_UP_DOWN;
302 td.tariffConf.passiveCost = 4;
303 td.dirPrice[0].mDay = 30;
304 td.dirPrice[0].hDay = 21;
305 td.dirPrice[0].mNight = 30;
306 td.dirPrice[0].hNight = 9;
307 td.dirPrice[0].priceDayA = 0;
308 td.dirPrice[0].priceDayB = 1;
309 td.dirPrice[0].priceNightA = 2;
310 td.dirPrice[0].priceNightB = 3;
311 td.dirPrice[0].threshold = 4;
312 td.dirPrice[0].singlePrice = 0;
313 td.dirPrice[0].noDiscount = 0;
314 TARIFF_IMPL tariff(td);
316 ensure_equals("0000 == 0", tariff.GetPriceWithTraffType(0, 0 * 1024 * 1024, 0, 1286461245), 2); // Near 17:30, 0 < 4 NA
317 ensure_equals("0001 == 0", tariff.GetPriceWithTraffType(0, 6 * 1024 * 1024, 0, 1286461245), 3); // Near 17:30, 6 > 4 NB
318 ensure_equals("0010 == 0", tariff.GetPriceWithTraffType(0, 0 * 1024 * 1024, 0, 1286479245), 0); // Near 22:30, 0 < 4 DA
319 ensure_equals("0011 == 0", tariff.GetPriceWithTraffType(0, 6 * 1024 * 1024, 0, 1286479245), 1); // Near 22:30, 6 > 4 DB
321 td.dirPrice[0].singlePrice = 1;
324 ensure_equals("0100 == 0", tariff.GetPriceWithTraffType(0, 0 * 1024 * 1024, 0, 1286461245), 0); // Near 17:30, 0 < 4 DA (ignore night)
325 ensure_equals("0101 == 0", tariff.GetPriceWithTraffType(0, 6 * 1024 * 1024, 0, 1286461245), 1); // Near 17:30, 6 > 4 DB (ignore night)
326 ensure_equals("0110 == 0", tariff.GetPriceWithTraffType(0, 0 * 1024 * 1024, 0, 1286479245), 0); // Near 22:30, 0 < 4 DA (ignore night)
327 ensure_equals("0111 == 0", tariff.GetPriceWithTraffType(0, 6 * 1024 * 1024, 0, 1286479245), 1); // Near 22:30, 6 > 4 DB (ignore night)
329 td.dirPrice[0].singlePrice = 0;
330 td.dirPrice[0].noDiscount = 1;
333 ensure_equals("1000 == 0", tariff.GetPriceWithTraffType(0, 0 * 1024 * 1024, 0, 1286461245), 2); // Near 17:30, 0 < 4 NA
334 ensure_equals("1001 == 0", tariff.GetPriceWithTraffType(0, 6 * 1024 * 1024, 0, 1286461245), 2); // Near 17:30, 6 > 4 NA
335 ensure_equals("1010 == 0", tariff.GetPriceWithTraffType(0, 0 * 1024 * 1024, 0, 1286479245), 0); // Near 22:30, 0 < 4 DA
336 ensure_equals("1011 == 0", tariff.GetPriceWithTraffType(0, 6 * 1024 * 1024, 0, 1286479245), 0); // Near 22:30, 6 > 4 DA
338 td.dirPrice[0].singlePrice = 1;
339 td.dirPrice[0].noDiscount = 1;
342 ensure_equals("1100 == 0", tariff.GetPriceWithTraffType(0, 0 * 1024 * 1024, 0, 1286461245), 0); // Near 17:30, 0 < 4 DA (ignore night)
343 ensure_equals("1101 == 0", tariff.GetPriceWithTraffType(0, 6 * 1024 * 1024, 0, 1286461245), 0); // Near 17:30, 6 > 4 DA (ignore night)
344 ensure_equals("1110 == 0", tariff.GetPriceWithTraffType(0, 0 * 1024 * 1024, 0, 1286479245), 0); // Near 22:30, 0 < 4 DA (ignore night)
345 ensure_equals("1111 == 0", tariff.GetPriceWithTraffType(0, 6 * 1024 * 1024, 0, 1286479245), 0); // Near 22:30, 6 > 4 DA (ignore night)
350 void testobject::test<7>()
352 set_test_name("Check changePolicy - ALLOW");
354 TARIFF_DATA td("test");
355 td.tariffConf.changePolicy = TARIFF::ALLOW;
356 td.tariffConf.fee = 100;
357 TARIFF_IMPL tariff(td);
359 td.tariffConf.fee = 50;
360 TARIFF_IMPL cheaper(td);
362 ensure_equals("Allow cheaper", tariff.TariffChangeIsAllowed(cheaper).empty(), true);
364 td.tariffConf.fee = 100;
365 TARIFF_IMPL equals(td);
367 ensure_equals("Allow equal", tariff.TariffChangeIsAllowed(equals).empty(), true);
369 td.tariffConf.fee = 150;
370 TARIFF_IMPL expensive(td);
372 ensure_equals("Allow expensive", tariff.TariffChangeIsAllowed(expensive).empty(), true);
377 void testobject::test<8>()
379 set_test_name("Check changePolicy - TO_CHEAP");
381 TARIFF_DATA td("test");
382 td.tariffConf.changePolicy = TARIFF::TO_CHEAP;
383 td.tariffConf.fee = 100;
384 TARIFF_IMPL tariff(td);
386 td.tariffConf.fee = 50;
387 TARIFF_IMPL cheaper(td);
389 ensure_equals("Allow cheaper", tariff.TariffChangeIsAllowed(cheaper).empty(), true);
391 td.tariffConf.fee = 100;
392 TARIFF_IMPL equals(td);
394 ensure_equals("Allow equal", !tariff.TariffChangeIsAllowed(equals).empty(), true);
396 td.tariffConf.fee = 150;
397 TARIFF_IMPL expensive(td);
399 ensure_equals("Allow expensive", !tariff.TariffChangeIsAllowed(expensive).empty(), true);
404 void testobject::test<9>()
406 set_test_name("Check changePolicy - TO_EXPENSIVE");
408 TARIFF_DATA td("test");
409 td.tariffConf.changePolicy = TARIFF::TO_EXPENSIVE;
410 td.tariffConf.fee = 100;
411 TARIFF_IMPL tariff(td);
413 td.tariffConf.fee = 50;
414 TARIFF_IMPL cheaper(td);
416 ensure_equals("Allow cheaper", !tariff.TariffChangeIsAllowed(cheaper).empty(), true);
418 td.tariffConf.fee = 100;
419 TARIFF_IMPL equals(td);
421 ensure_equals("Allow equal", !tariff.TariffChangeIsAllowed(equals).empty(), true);
423 td.tariffConf.fee = 150;
424 TARIFF_IMPL expensive(td);
426 ensure_equals("Allow expensive", tariff.TariffChangeIsAllowed(expensive).empty(), true);
431 void testobject::test<10>()
433 set_test_name("Check changePolicy - DENY");
435 TARIFF_DATA td("test");
436 td.tariffConf.changePolicy = TARIFF::DENY;
437 td.tariffConf.fee = 100;
438 TARIFF_IMPL tariff(td);
440 td.tariffConf.fee = 50;
441 TARIFF_IMPL cheaper(td);
443 ensure_equals("Allow cheaper", !tariff.TariffChangeIsAllowed(cheaper).empty(), true);
445 td.tariffConf.fee = 100;
446 TARIFF_IMPL equals(td);
448 ensure_equals("Allow equal", !tariff.TariffChangeIsAllowed(equals).empty(), true);
450 td.tariffConf.fee = 150;
451 TARIFF_IMPL expensive(td);
453 ensure_equals("Allow expensive", !tariff.TariffChangeIsAllowed(expensive).empty(), true);