MOOCHO (Single Doxygen Collection)  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
IterationPack_TestIterQuantityAccessContinuous.cpp
Go to the documentation of this file.
1 // @HEADER
2 // ***********************************************************************
3 //
4 // Moocho: Multi-functional Object-Oriented arCHitecture for Optimization
5 // Copyright (2003) Sandia Corporation
6 //
7 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
8 // license for use of this work by or on behalf of the U.S. Government.
9 //
10 // Redistribution and use in source and binary forms, with or without
11 // modification, are permitted provided that the following conditions are
12 // met:
13 //
14 // 1. Redistributions of source code must retain the above copyright
15 // notice, this list of conditions and the following disclaimer.
16 //
17 // 2. Redistributions in binary form must reproduce the above copyright
18 // notice, this list of conditions and the following disclaimer in the
19 // documentation and/or other materials provided with the distribution.
20 //
21 // 3. Neither the name of the Corporation nor the names of the
22 // contributors may be used to endorse or promote products derived from
23 // this software without specific prior written permission.
24 //
25 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
26 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
29 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
30 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
31 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
32 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
33 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
34 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
35 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 //
37 // Questions? Contact Roscoe A. Bartlett (rabartl@sandia.gov)
38 //
39 // ***********************************************************************
40 // @HEADER
41 
42 #include <ostream>
43 #include <iomanip>
44 #include <vector>
45 
49 
51 {
52  namespace rcp = MemMngPack;
53 
54  {
55  // explicit instantiation test
56  typedef std::vector<int> T;
58  1,"v"
59 #ifdef _MIPS_CXX
62 #endif
63  );
64  }
65 
66  using std::endl;
67  using std::setw;
68 
70 
71  try {
72 
73 // int w = 15;
74  int prec = 8;
75  if(out) out->precision(prec);
76  if(out) *out << std::boolalpha;
77  bool success = true;
78  bool result;
79 
80  int r; // result
81 
82  if(out)
83  *out << "\n********************************************\n"
84  << "*** Testing IterQuantityAccessContiguous ***\n"
85  << "********************************************\n";
86 
87  // Create a 1 storage and test it
88  {
89 
90  if(out)
91  *out << "\n *** Test single storage ***\n"
92  << " IterQuantityAccessContiguous<int> x_cont(1,\"x\");\n"
93  << " IterQuantityAccess<int>& x = x_cont;\n";
95  1, "x"
96 #ifdef _MIPS_CXX
99 #endif
100  );
101  IterQuantityAccess<int>& x = x_cont;
102 
103  if(out)
104  *out<< "\n** Check state\n"
105  << "x.has_storage_k(-300) == true : ";
106  update_success( result = (x.has_storage_k(-300) == true), &success );
107  if(out)
108  *out<< result << endl;
109 
110  if(out)
111  *out<< "x.has_storage_k(400) == true : ";
112  update_success( result = x.has_storage_k(400) == true, &success );
113  if(out)
114  *out<< result << endl;
115 
116  if(out)
117  *out<< "!x.updated_k(-45) == true : ";
118  update_success( result = x.updated_k(-45) == false, &success );
119  if(out)
120  *out<< result << endl;
121 
122  if(out)
123  *out<< "!x.updated_k(60) == true : ";
124  update_success( result = x.updated_k(60) == false, &success );
125  if(out)
126  *out<< result << endl;
127 
128  if(out)
129  *out<< "\n** Perform an update and check state\n"
130  << "x.set_k(0) = 5;\n\n";
131  x.set_k(0) = 5;
132 
133  if(out)
134  *out<< "x.get_k(0) == 5 : ";
135  r = x.get_k(0);
136  update_success( result = r == 5, &success );
137  if(out)
138  *out<< r << " : " << result << endl;
139 
140  if(out)
141  *out<< "!x.updated_k(-1) == true : ";
142  update_success( result = x.updated_k(-1) == false, &success );
143  if(out)
144  *out<< result << endl;
145 
146  if(out)
147  *out<< "!x.updated_k(1) == true : ";
148  update_success( result = x.updated_k(1) == false, &success );
149  if(out)
150  *out<< result << endl;
151 
152  if(out)
153  *out<< "!x.has_storage_k(-1) == true : ";
154  update_success( result = x.has_storage_k(-1) == false, &success );
155  if(out)
156  *out<< result << endl;
157 
158  if(out)
159  *out<< "x.has_storage_k(1) == true : ";
160  update_success( result = x.has_storage_k(1) == true, &success );
161  if(out)
162  *out<< result << endl;
163 
164  if(out)
165  *out<< "\n** Do illegal set_k(), should throw NoStorageAvailable: x.set_k(-1) = 4 : ";
166  try {
167  x.set_k(-1) = 4;
168  success = false;
169  if(out)
170  *out<< "false\n";
171  }
172  catch(const IterQuantity::NoStorageAvailable& excpt) {
173  if(out)
174  *out<< "As expected! Caught IterQuantity::NoStorageAvailable: " << excpt.what() << " : true\n" << endl;
175  }
176 
177  if(out)
178  *out<< "\n** Do illegal get_k(), should throw QuanityNotSet: x.get_k(1) : ";
179  try {
180  x.get_k(1);
181  success = false;
182  if(out)
183  *out<< "false\n";
184  }
185  catch(const IterQuantity::QuanityNotSet& excpt) {
186  if(out) *out << "As expected! Caught IterQuantity::QuanityNotSet: " << excpt.what() << " : true\n" << endl;
187  }
188 
189  if(out) *out << "\nx.next_iteration();\n";
190  x.next_iteration();
191 
192  if(out) *out<< "x.get_k(-1) == 5 : ";
193  r = x.get_k(-1);
194  update_success( result = r == 5, &success );
195  if(out)
196  *out<< " : " << result << endl;
197 
198  if(out)
199  *out<< "!x.updated_k(-2) == true : ";
200  update_success( result = x.updated_k(-2) == false, &success );
201  if(out)
202  *out<< result << endl;
203 
204  if(out)
205  *out<< "x.updated_k(0) == true : ";
206  update_success( result = x.updated_k(0) == false, &success );
207  if(out)
208  *out<< result << endl;
209 
210  if(out)
211  *out<< "!x.has_storage_k(-2) == true : ";
212  update_success( result = x.has_storage_k(-2) == false, &success );
213  if(out)
214  *out<< result << endl;
215 
216  if(out)
217  *out<< "x.has_storage_k(0) == true : ";
218  update_success( result = x.has_storage_k(0) == true, &success );
219  if(out)
220  *out<< result << endl;
221 
222  if(out) *out << "\nx.set_k(0,-1);\n\n";
223  {
224  x.set_k(0,-1);
225  }
226 
227  if(out) *out << "x.get_k(0) == 5 : ";
228  r = x.get_k(0);
229  update_success( result = r == 5, &success );
230  if(out)
231  *out<< r << " : " << result << endl;
232 
233  if(out)
234  *out<< "x.will_loose_mem(0,1) == true : ";
235  update_success( result = x.will_loose_mem(0,1) == true, &success );
236  if(out)
237  *out<< result << endl;
238 
239  if(out) *out << "\nx.set_k(1) = -4;\n\n";
240  x.set_k(1) = -4;
241 
242  if(out)
243  *out<< "x.get_k(1) == -4 : ";
244  r = x.get_k(1);
245  update_success( result = r == -4, &success );
246  if(out)
247  *out<< r << " : " << result << endl;
248 
249  if(out)
250  *out<< "\nx.next_iteration();\n\n";
251  x.next_iteration();
252 
253  if(out)
254  *out<< "x.get_k(0) == -4 : ";
255  r = x.get_k(0);
256  update_success( result = r == -4, &success );
257  if(out)
258  *out<< r << " : " << result << endl;
259 
260  }
261 
262  // Create a 2 storage and test it
263  {
264 
265  if(out)
266  *out<< "\n*** Test dual storage ***\n"
267  << "IterQuantityAccessContiguous<int> x_cont(2,\"x\");\n"
268  << "IterQuantityAccess<int>& x = x_cont;\n";
270  2, "x"
271 #ifdef _MIPS_CXX
274 #endif
275  );
276  IterQuantityAccess<int>& x = x_cont;
277 
278  if(out)
279  *out<< "\n** Check state\n"
280  << "x.has_storage_k(-300) == true : ";
281  update_success( result = x.has_storage_k(-300) == true, &success );
282  if(out)
283  *out<< result << endl;
284 
285  if(out)
286  *out<< "x.has_storage_k(400) == true : ";
287  update_success( result = x.has_storage_k(400) == true, &success );
288  if(out)
289  *out<< result << endl;
290 
291  if(out)
292  *out<< "!x.updated_k(-45) == true : ";
293  update_success( result = x.updated_k(-45) == false, &success );
294  if(out)
295  *out<< result << endl;
296 
297  if(out)
298  *out<< "!x.updated_k(60) == true : ";
299  update_success( result = x.updated_k(60) == false, &success );
300  if(out)
301  *out<< result << endl;
302 
303  if(out)
304  *out<< "\n** Perform an update and check state\n"
305  << "x.set_k(0) = 5;\n\n";
306  x.set_k(0) = 5;
307 
308  if(out)
309  *out<< "x.get_k(0) == 5 : ";
310  r = x.get_k(0);
311  update_success( result = r == 5, &success );
312  if(out)
313  *out<< r << " : " << result << endl;
314 
315  if(out)
316  *out<< "!x.updated_k(-1) == true : ";
317  update_success( result = x.updated_k(-1) == false, &success );
318  if(out)
319  *out<< result << endl;
320 
321  if(out)
322  *out<< "!x.updated_k(1) == true : ";
323  update_success( result = x.updated_k(1) == false, &success );
324  if(out)
325  *out<< result << endl;
326 
327  if(out)
328  *out<< "!x.has_storage_k(-2) == true : ";
329  update_success( result = x.has_storage_k(-2) == false, &success );
330  if(out)
331  *out<< result << endl;
332 
333  if(out)
334  *out<< "x.has_storage_k(-1) == true : ";
335  update_success( result = x.has_storage_k(-1) == true, &success );
336  if(out)
337  *out<< result << endl;
338 
339  if(out)
340  *out<< "x.has_storage_k(1) == true : ";
341  update_success( result = x.has_storage_k(1) == true, &success );
342  if(out)
343  *out<< result << endl;
344 
345  if(out)
346  *out<< "\nx.set_k(-1) = 4;\n\n";
347  x.set_k(-1) = 4;
348 
349  if(out)
350  *out<< "x.get_k(-1) == 4 : ";
351  r = x.get_k(-1);
352  update_success( result = r == 4, &success );
353  if(out)
354  *out<< r << " : " << result << endl;
355 
356  if(out)
357  *out<< "\n** Do illegal set_k(), should throw NoStorageAvailable: x.set_k(-2) = 4 : ";
358  try {
359  x.set_k(-2) = 4;
360  success = false;
361  if(out)
362  *out<< "false\n";
363  }
364  catch(const IterQuantity::NoStorageAvailable& excpt) {
365  if(out)
366  *out<< "As expected! Caught IterQuantity::NoStorageAvailable: " << excpt.what() << " : true\n" << endl;
367  }
368 
369  if(out)
370  *out<< "\n** Do illegal get_k(), should throw QuanityNotSet: x.get_k(1) : ";
371  try {
372  x.get_k(1);
373  success = false;
374  if(out)
375  *out<< "false\n";
376  }
377  catch(const IterQuantity::QuanityNotSet& excpt) {
378  if(out)
379  *out<< "As expected! Caught IterQuantity::QuanityNotSet: " << excpt.what() << " : true\n" << endl;
380  }
381 
382  if(out)
383  *out<< "\nx.next_iteration();\n\n";
384  x.next_iteration();
385 
386  if(out)
387  *out<< "x.get_k(-2) == 4 : ";
388  r = x.get_k(-2);
389  update_success( result = r == 4, &success );
390  if(out)
391  *out<< r << " : " << result << endl;
392 
393  if(out)
394  *out<< "x.get_k(-1) == 5 : ";
395  r = x.get_k(-1);
396  update_success( result = r == 5, &success );
397  if(out)
398  *out<< r << " : " << result << endl;
399 
400  if(out)
401  *out<< "!x.updated_k(-3) == true : ";
402  update_success( result = x.updated_k(-3) == false, &success );
403  if(out)
404  *out<< result << endl;
405 
406  if(out)
407  *out<< "!x.updated_k(0) == true : ";
408  update_success( result = x.updated_k(0) == false, &success );
409  if(out)
410  *out<< result << endl;
411 
412  if(out)
413  *out<< "!x.has_storage_k(-3) == true : ";
414  update_success( result = x.has_storage_k(-3) == false, &success );
415  if(out)
416  *out<< result << endl;
417 
418  if(out)
419  *out<< "!x.has_storage_k(0) == true : ";
420  update_success( result = x.has_storage_k(0) == true, &success );
421  if(out)
422  *out<< result << endl;
423 
424  if(out)
425  *out<< "x.set_k(0,-1);\n\n";
426  {
427  x.set_k(0,-1);
428  }
429 
430  if(out)
431  *out<< "x.get_k(0) == 5 : ";
432  r = x.get_k(0);
433  update_success( result = r == 5, &success );
434  if(out)
435  *out<< r << " : " << result << endl;
436 
437  if(out)
438  *out<< "x.get_k(-1) == 5 : ";
439  r = x.get_k(-1);
440  update_success( result = r == 5, &success );
441  if(out)
442  *out<< r << " : " << result << endl;
443 
444  if(out)
445  *out<< "!x.updated_k(-2) == true : ";
446  update_success( result = x.updated_k(-2) == false, &success );
447  if(out)
448  *out<< result << endl;
449 
450  if(out)
451  *out<< "!x.will_loose_mem(0,1) == true : ";
452  update_success( result = x.will_loose_mem(0,1) == false, &success );
453  if(out)
454  *out<< result << endl;
455 
456  if(out)
457  *out<< "x.will_loose_mem(-1,1) == true : ";
458  update_success( result = x.will_loose_mem(-1,1) == true, &success );
459  if(out)
460  *out<< result << endl;
461 
462  if(out)
463  *out<< "\nx.set_k(1) = -4;\n\n";
464  x.set_k(1) = -4;
465 
466  if(out)
467  *out<< "x.get_k(1) == -4 : ";
468  r = x.get_k(1);
469  update_success( result = r == -4, &success );
470  if(out)
471  *out<< r << " : " << result << endl;
472 
473  if(out)
474  *out<< "x.get_k(0) == 5 : ";
475  r = x.get_k(0);
476  update_success( result = r == 5, &success );
477  if(out)
478  *out<< r << " : " << result << endl;
479 
480  if(out)
481  *out<< "\nx.next_iteration();\n\n";
482  x.next_iteration();
483 
484  if(out)
485  *out<< "x.get_k(0) == -4 : ";
486  r = x.get_k(0);
487  update_success( result = r == -4, &success );
488  if(out)
489  *out<< r << " : " << result << endl;
490 
491  }
492 
493  // Create a 4 storage and test it
494  {
495  if(out)
496  *out<< "\n*** Test 4 storage ***\n"
497  << "IterQuantityAccessContiguous<int> x_cont(4,\"x\");\n"
498  << "IterQuantityAccess<int>& x = x_cont;\n";
500  4, "x"
501 #ifdef _MIPS_CXX
504 #endif
505  );
506  IterQuantityAccess<int>& x = x_cont;
507 
508  if(out)
509  *out<< "\n** Check state\n";
510 
511  if(out)
512  *out<< "x.has_storage_k(-300) == true : ";
513  update_success( result = x.has_storage_k(-300) == true, &success );
514  if(out)
515  *out<< result << endl;
516 
517  if(out)
518  *out<< "x.has_storage_k(400) == true : ";
519  update_success( result = x.has_storage_k(400) == true, &success );
520  if(out)
521  *out<< result << endl;
522 
523  if(out)
524  *out<< "!x.updated_k(-45) == true : ";
525  update_success( result = x.updated_k(-45) == false, &success );
526  if(out)
527  *out<< result << endl;
528 
529  if(out)
530  *out<< "!x.updated_k(60) == true : ";
531  update_success( result = x.updated_k(60) == false, &success );
532  if(out)
533  *out<< result << endl;
534 
535  if(out)
536  *out<< "\n** Perform an update and check state\n"
537  << "x.set_k(0) = 1;\n\n";
538  x.set_k(0) = 1;
539 
540  if(out)
541  *out<< "x.get_k(0) == 1 : ";
542  r = x.get_k(0);
543  update_success( result = r == 1, &success );
544  if(out)
545  *out<< r << " : " << result << endl;
546 
547  if(out)
548  *out<< "!x.updated_k(-4) == true : ";
549  update_success( result = x.updated_k(-4) == false, &success );
550  if(out)
551  *out<< result << endl;
552 
553  if(out)
554  *out<< "!x.updated_k(-3) == true : ";
555  update_success( result = x.updated_k(-3) == false, &success );
556  if(out)
557  *out<< result << endl;
558 
559  if(out)
560  *out<< "!x.updated_k(-2) == true : ";
561  update_success( result = x.updated_k(-2) == false, &success );
562  if(out)
563  *out<< result << endl;
564 
565  if(out)
566  *out<< "!x.updated_k(-1) == true : ";
567  update_success( result = x.updated_k(-1) == false, &success );
568  if(out)
569  *out<< result << endl;
570 
571  if(out)
572  *out<< "x.updated_k(0) == true : ";
573  update_success( result = x.updated_k(0) == true, &success );
574  if(out)
575  *out<< result << endl;
576 
577  if(out)
578  *out<< "!x.updated_k(1) == true : ";
579  update_success( result = x.updated_k(1) == false, &success );
580  if(out)
581  *out<< result << endl;
582 
583  if(out)
584  *out<< "!x.has_storage_k(-4) == true : ";
585  update_success( result = x.has_storage_k(-4) == false, &success );
586  if(out)
587  *out<< result << endl;
588 
589  if(out)
590  *out<< "x.has_storage_k(-3) == true : ";
591  update_success( result = x.has_storage_k(-3) == true, &success );
592  if(out)
593  *out<< result << endl;
594 
595  if(out)
596  *out<< "x.has_storage_k(-2) == true : ";
597  update_success( result = x.has_storage_k(-2) == true, &success );
598  if(out)
599  *out<< result << endl;
600 
601  if(out)
602  *out<< "x.has_storage_k(-1) == true : ";
603  update_success( result = x.has_storage_k(-1) == true, &success );
604  if(out)
605  *out<< result << endl;
606 
607  if(out)
608  *out<< "x.has_storage_k(0) == true : ";
609  update_success( result = x.has_storage_k(0) == true, &success );
610  if(out)
611  *out<< result << endl;
612 
613  if(out)
614  *out<< "x.has_storage_k(1) == true : ";
615  update_success( result = x.has_storage_k(1) == true, &success );
616  if(out)
617  *out<< result << endl;
618 
619  if(out)
620  *out<< "\nx.set_k(-1) = 2;\n\n";
621  x.set_k(-1) = 2;
622 
623  if(out)
624  *out<< "x.get_k(-1) == 2 : ";
625  r = x.get_k(-1);
626  update_success( result = r == 2, &success );
627  if(out)
628  *out<< r << " : " << result << endl;
629 
630  if(out)
631  *out<< "\nx.set_k(-2) = 3;\n"
632  << "x.set_k(-3) = 4;\n\n";
633  x.set_k(-2) = 3;
634  x.set_k(-3) = 4;
635 
636  if(out)
637  *out<< "x.get_k(-2) == 3 : ";
638  r = x.get_k(-2);
639  update_success( result = r == 3, &success );
640  if(out)
641  *out<< r << " : " << result << endl;
642 
643  if(out)
644  *out<< "x.get_k(-3) == 4 : ";
645  r = x.get_k(-3);
646  update_success( result = r == 4, &success );
647  if(out)
648  *out<< r << " : " << result << endl;
649 
650 
651  if(out)
652  *out<< "\n** Do illegal set_k(), should throw NoStorageAvailable: x.set_k(-4) = 4 : ";
653  try {
654  x.set_k(-4) = 4;
655  success = false;
656  if(out)
657  *out<< "false\n";
658  }
659  catch(const IterQuantity::NoStorageAvailable& excpt) {
660  if(out)
661  *out<< "As expected! Caught IterQuantity::NoStorageAvailable: " << excpt.what() << " : true\n" << endl;
662  }
663 
664  if(out)
665  *out<< "\n** Do illegal get_k(), should throw QuanityNotSet: x.get_k(1) : ";
666  try {
667  x.get_k(1);
668  success = false;
669  if(out)
670  *out<< "false\n";
671  }
672  catch(const IterQuantity::QuanityNotSet& excpt) {
673  if(out)
674  *out<< "As expected! Caught IterQuantity::QuanityNotSet: " << excpt.what() << " : true" << endl;
675  }
676 
677  if(out)
678  *out<< "\nx.next_iteration();\n\n";
679  x.next_iteration();
680 
681  if(out)
682  *out<< "x.get_k(-4) == 4 : ";
683  r = x.get_k(-4);
684  update_success( result = r == 4, &success );
685  if(out)
686  *out<< r << " : " << result << endl;
687 
688  if(out)
689  *out<< "x.get_k(-3) == 3 : ";
690  r = x.get_k(-3);
691  update_success( result = r == 3, &success );
692  if(out)
693  *out<< r << " : " << result << endl;
694 
695  if(out)
696  *out<< "x.get_k(-2) == 2 : ";
697  r = x.get_k(-2);
698  update_success( result = r == 2, &success );
699  if(out)
700  *out<< r << " : " << result << endl;
701 
702  if(out)
703  *out<< "x.get_k(-1) == 1 : ";
704  r = x.get_k(-1);
705  update_success( result = r == 1, &success );
706  if(out)
707  *out<< r << " : " << result << endl;
708 
709  if(out)
710  *out<< "!x.updated_k(-5) == true : ";
711  update_success( result = x.updated_k(-5) == false, &success );
712  if(out)
713  *out<< result << endl;
714 
715  if(out)
716  *out<< "!x.updated_k(0) == true : ";
717  update_success( result = x.updated_k(0) == false, &success );
718  if(out)
719  *out<< result << endl;
720 
721  if(out)
722  *out<< "!x.has_storage_k(-5) == true : ";
723  update_success( result = x.has_storage_k(-5) == false, &success );
724  if(out)
725  *out<< result << endl;
726 
727  if(out)
728  *out<< "x.has_storage_k(0) == true : ";
729  update_success( result = x.has_storage_k(0) == true, &success );
730  if(out)
731  *out<< result << endl;
732 
733  if(out)
734  *out<< "\nx.set_k(0,-1);\n\n";
735  {
736  x.set_k(0,-1);
737  }
738 
739  if(out)
740  *out<< "x.get_k(-3) == 3 : ";
741  r = x.get_k(-3);
742  update_success( result = r == 3, &success );
743  if(out)
744  *out<< r << " : " << result << endl;
745 
746  if(out)
747  *out<< "x.get_k(-2) == 2 : ";
748  r = x.get_k(-2);
749  update_success( result = r == 2, &success );
750  if(out)
751  *out<< r << " : " << result << endl;
752 
753  if(out)
754  *out<< "x.get_k(-1) == 1 : ";
755  r = x.get_k(-1);
756  update_success( result = r == 1, &success );
757  if(out)
758  *out<< r << " : " << result << endl;
759 
760  if(out)
761  *out<< "x.get_k(0) == 1 : ";
762  r = x.get_k(0);
763  update_success( result = r == 1, &success );
764  if(out)
765  *out<< r << " : " << result << endl;
766 
767  if(out)
768  *out<< "!x.updated_k(-4) == true : ";
769  update_success( result = x.updated_k(-4) == false, &success );
770  if(out)
771  *out<< result << endl;
772 
773  if(out)
774  *out<< "!x.will_loose_mem(-2,1) == true : ";
775  update_success( result = x.will_loose_mem(-2,1) == false, &success );
776  if(out)
777  *out<< result << endl;
778 
779  if(out)
780  *out<< "x.will_loose_mem(-3,1) == true : ";
781  update_success( result = x.will_loose_mem(-3,1) == true, &success );
782  if(out)
783  *out<< result << endl;
784 
785  if(out)
786  *out<< "\nx.set_k(1) = -4;\n\n";
787  x.set_k(1) = -4;
788 
789  if(out)
790  *out<< "x.get_k(-2) == 2 : ";
791  r = x.get_k(-2);
792  update_success( result = r == 2, &success );
793  if(out)
794  *out<< r << " : " << result << endl;
795 
796  if(out)
797  *out<< "x.get_k(-1) == 1 : ";
798  r = x.get_k(-1);
799  update_success( result = r == 1, &success );
800  if(out)
801  *out<< r << " : " << result << endl;
802 
803  if(out)
804  *out<< "x.get_k(0) == 1 : ";
805  r = x.get_k(0);
806  update_success( result = r == 1, &success );
807  if(out)
808  *out<< r << " : " << result << endl;
809 
810  if(out)
811  *out<< "x.get_k(1) == -4 : ";
812  r = x.get_k(1);
813  update_success( result = r == -4, &success );
814  if(out)
815  *out<< r << " : " << result << endl;
816 
817  if(out)
818  *out<< "\nx.next_iteration();\n\n";
819  x.next_iteration();
820 
821  if(out)
822  *out<< "x.get_k(-2) == 1 : ";
823  r = x.get_k(-2);
824  update_success( result = r == 1, &success );
825  if(out)
826  *out<< r << " : " << result << endl;
827 
828  if(out)
829  *out<< "x.get_k(-1) == 1 : ";
830  r = x.get_k(-1);
831  update_success( result = r == 1, &success );
832  if(out)
833  *out<< r << " : " << result << endl;
834 
835  if(out)
836  *out<< "x.get_k(0) == -4 : ";
837  r = x.get_k(0);
838  update_success( result = r == -4, &success );
839  if(out)
840  *out<< r << " : " << result << endl;
841  }
842 
843  if(success) {
844  if(out)
845  *out<< "\n*** Congradulations, all of the tests returned the expected results ***\n";
846  }
847  else {
848  if(out)
849  *out<< "\n*** Oops, at least one of the above tests did not return the expected results ***\n";
850  }
851 
852  return success;
853 
854  } // end try
855  catch(const std::exception& excpt) {
856  if(out)
857  *out<< "\nCaught a std::exception: " << excpt.what() << endl;
858  }
859  catch(...) {
860  if(out)
861  *out<< "\nCaught and unknown exception\n";
862  }
863 
864  return false;
865 }
Interface to typed iteration quantities.
virtual T_info & get_k(int offset)=0
Return a reference for the k + offset iteration quanity.
Thrown when memory access is attempted when it has not yet been updated.
virtual bool has_storage_k(int offset) const =0
Determine if there is storage advailable for the k offset iteration quanity.
Thrown memory if attempted to be set that storage can not be allocated to.
virtual void next_iteration()=0
Shift the reference point from the k to the k+1 iteration.
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
virtual bool updated_k(int offset) const =0
Determine if the quanity for the k offset iteration has been accessed by a call to set_k() (see IterQ...
virtual T_info & set_k(int offset)=0
Return a reference to the storage location for the k + offset iteration quanity.
virtual bool will_loose_mem(int offset, int set_offset) const =0
Determine if the memory for the k + offset quantityy will be lost if set_k(set_offset) is called (see...
std::ostream * out
Iteration Quanities subclass for contiguous iterations.
bool update_success(bool result_check, bool *success)
Helper function for updating a flag for if an operation returned false.