IterationPack_TestIterQuantityAccessContinuous.cpp

Go to the documentation of this file.
00001 // @HEADER
00002 // ***********************************************************************
00003 // 
00004 // Moocho: Multi-functional Object-Oriented arCHitecture for Optimization
00005 //                  Copyright (2003) Sandia Corporation
00006 // 
00007 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
00008 // license for use of this work by or on behalf of the U.S. Government.
00009 // 
00010 // This library is free software; you can redistribute it and/or modify
00011 // it under the terms of the GNU Lesser General Public License as
00012 // published by the Free Software Foundation; either version 2.1 of the
00013 // License, or (at your option) any later version.
00014 //  
00015 // This library is distributed in the hope that it will be useful, but
00016 // WITHOUT ANY WARRANTY; without even the implied warranty of
00017 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00018 // Lesser General Public License for more details.
00019 //  
00020 // You should have received a copy of the GNU Lesser General Public
00021 // License along with this library; if not, write to the Free Software
00022 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
00023 // USA
00024 // Questions? Contact Roscoe A. Bartlett (rabartl@sandia.gov) 
00025 // 
00026 // ***********************************************************************
00027 // @HEADER
00028 
00029 #include <ostream>
00030 #include <iomanip>
00031 #include <vector>
00032 
00033 #include "IterationPack_TestIterationPack.hpp"
00034 #include "IterationPack_IterQuantityAccessContiguous.hpp"
00035 #include "TestingHelperPack_update_success.hpp"
00036 
00037 bool IterationPack::TestingPack::TestIterQuantityAccessContiguous(std::ostream* out)
00038 {
00039   namespace rcp = MemMngPack;
00040 
00041   {
00042     // explicit instantiation test
00043     typedef std::vector<int> T;
00044     IterQuantityAccessContiguous<T> iq_v(
00045       1,"v"
00046 #ifdef _MIPS_CXX
00047       ,Teuchos::RefCountPtr<Teuchos::AbstractFactoryStd<T,T> >(
00048         new Teuchos::AbstractFactoryStd<T,T>())
00049 #endif      
00050       );
00051   }
00052 
00053   using std::endl;
00054   using std::setw;
00055 
00056   using TestingHelperPack::update_success;
00057 
00058   try {
00059   
00060 //  int w = 15;
00061   int prec = 8;
00062   if(out) out->precision(prec);
00063   if(out) *out << std::boolalpha;
00064   bool success = true;
00065   bool result;
00066 
00067   int r;  // result
00068 
00069   if(out)
00070      *out << "\n********************************************\n"
00071         << "*** Testing IterQuantityAccessContiguous ***\n"
00072         << "********************************************\n";
00073 
00074   // Create a 1 storage and test it
00075   {
00076 
00077     if(out) 
00078       *out  << "\n *** Test single storage ***\n"
00079           << "  IterQuantityAccessContiguous<int> x_cont(1,\"x\");\n"
00080           << "  IterQuantityAccess<int>& x = x_cont;\n";
00081     IterQuantityAccessContiguous<int> x_cont(
00082       1, "x"
00083 #ifdef _MIPS_CXX
00084       ,Teuchos::RefCountPtr<Teuchos::AbstractFactoryStd<int,int> >(
00085         new Teuchos::AbstractFactoryStd<int,int>())
00086 #endif      
00087       );
00088     IterQuantityAccess<int>& x = x_cont;
00089 
00090     if(out)
00091       *out<< "\n** Check state\n"
00092         << "x.has_storage_k(-300) == true : ";
00093     update_success( result = (x.has_storage_k(-300) == true), &success );
00094     if(out)
00095       *out<< result << endl;
00096 
00097     if(out)
00098       *out<< "x.has_storage_k(400) == true : ";
00099     update_success( result = x.has_storage_k(400) == true, &success );
00100     if(out)
00101       *out<< result << endl;
00102 
00103     if(out)
00104       *out<< "!x.updated_k(-45) == true : ";
00105     update_success( result = x.updated_k(-45) == false, &success );
00106     if(out)
00107       *out<< result << endl;
00108 
00109     if(out)
00110       *out<< "!x.updated_k(60) == true : ";
00111     update_success( result = x.updated_k(60) == false, &success );
00112     if(out)
00113       *out<< result << endl;
00114 
00115     if(out)
00116       *out<< "\n** Perform an update and check state\n"
00117         << "x.set_k(0) = 5;\n\n";
00118     x.set_k(0) = 5;
00119 
00120     if(out)
00121       *out<< "x.get_k(0) == 5 : ";
00122     r = x.get_k(0);
00123     update_success( result = r == 5, &success );
00124     if(out) 
00125       *out<< r << " : " << result << endl;
00126 
00127     if(out)
00128       *out<< "!x.updated_k(-1) == true : ";
00129     update_success( result = x.updated_k(-1) == false, &success );
00130     if(out)
00131       *out<< result << endl;
00132         
00133     if(out)
00134       *out<< "!x.updated_k(1) == true : ";
00135     update_success( result = x.updated_k(1) == false, &success );
00136     if(out)
00137       *out<< result << endl;
00138         
00139     if(out)
00140       *out<< "!x.has_storage_k(-1) == true : ";
00141     update_success( result = x.has_storage_k(-1) == false, &success );
00142     if(out)
00143       *out<< result << endl;
00144         
00145     if(out)
00146       *out<< "x.has_storage_k(1) == true : ";
00147     update_success( result = x.has_storage_k(1) == true, &success );
00148     if(out)
00149       *out<< result << endl;
00150 
00151     if(out) 
00152       *out<< "\n** Do illegal set_k(), should throw NoStorageAvailable: x.set_k(-1) = 4 : ";
00153     try {
00154       x.set_k(-1) = 4;
00155       success = false;
00156       if(out)
00157         *out<< "false\n";
00158     }
00159     catch(const IterQuantity::NoStorageAvailable& excpt) {
00160       if(out)
00161         *out<< "As expected!  Caught IterQuantity::NoStorageAvailable: " << excpt.what() << " : true\n" << endl;
00162     }
00163 
00164     if(out)
00165       *out<< "\n** Do illegal get_k(), should throw QuanityNotSet: x.get_k(1) : ";
00166     try {
00167       x.get_k(1);
00168       success = false;
00169       if(out)
00170         *out<< "false\n";
00171     }
00172     catch(const IterQuantity::QuanityNotSet& excpt) {
00173       if(out) *out << "As expected!   Caught IterQuantity::QuanityNotSet: " << excpt.what() << " : true\n" << endl;
00174     }
00175 
00176     if(out) *out  << "\nx.next_iteration();\n";
00177     x.next_iteration();
00178 
00179     if(out) *out<< "x.get_k(-1) == 5 : ";
00180     r = x.get_k(-1);
00181     update_success( result = r == 5, &success );
00182     if(out) 
00183       *out<< " : " << result << endl;
00184 
00185     if(out)
00186       *out<< "!x.updated_k(-2) == true : ";
00187     update_success( result = x.updated_k(-2) == false, &success );
00188     if(out)
00189       *out<< result << endl;
00190         
00191     if(out)
00192       *out<< "x.updated_k(0) == true : ";
00193     update_success( result = x.updated_k(0) == false, &success );
00194     if(out)
00195       *out<< result << endl;
00196         
00197     if(out)
00198       *out<< "!x.has_storage_k(-2) == true : ";
00199     update_success( result = x.has_storage_k(-2) == false, &success );
00200     if(out)
00201       *out<< result << endl;
00202         
00203     if(out)
00204       *out<< "x.has_storage_k(0) == true : ";
00205     update_success( result = x.has_storage_k(0) == true, &success );
00206     if(out)
00207       *out<< result << endl;
00208 
00209     if(out) *out  << "\nx.set_k(0,-1);\n\n";
00210     {
00211       x.set_k(0,-1);
00212     }
00213     
00214     if(out) *out  << "x.get_k(0) == 5 : ";
00215     r = x.get_k(0);
00216     update_success( result = r  == 5, &success );
00217     if(out)
00218       *out<< r << " : " << result << endl;
00219   
00220     if(out)
00221       *out<< "x.will_loose_mem(0,1) == true : ";
00222     update_success( result = x.will_loose_mem(0,1) == true, &success );
00223     if(out)
00224       *out<< result << endl;
00225 
00226     if(out) *out  << "\nx.set_k(1) = -4;\n\n";
00227     x.set_k(1) = -4;
00228 
00229     if(out)
00230       *out<< "x.get_k(1) == -4 : ";
00231     r = x.get_k(1);
00232     update_success( result = r == -4, &success );
00233     if(out)
00234       *out<< r << " : " << result << endl;
00235 
00236     if(out)
00237       *out<< "\nx.next_iteration();\n\n";
00238     x.next_iteration();
00239 
00240     if(out)
00241       *out<< "x.get_k(0) == -4 : ";
00242     r = x.get_k(0);
00243     update_success( result = r == -4, &success );
00244     if(out)
00245       *out<< r << " : " << result << endl;
00246     
00247   }
00248 
00249   // Create a 2 storage and test it
00250   {
00251 
00252     if(out)
00253       *out<< "\n*** Test dual storage ***\n"
00254         << "IterQuantityAccessContiguous<int> x_cont(2,\"x\");\n"
00255         << "IterQuantityAccess<int>& x = x_cont;\n";
00256     IterQuantityAccessContiguous<int> x_cont(
00257       2, "x"
00258 #ifdef _MIPS_CXX
00259       ,Teuchos::RefCountPtr<Teuchos::AbstractFactoryStd<int,int> >(
00260         new Teuchos::AbstractFactoryStd<int,int>())
00261 #endif      
00262       );
00263     IterQuantityAccess<int>& x = x_cont;
00264 
00265     if(out)
00266       *out<< "\n** Check state\n"
00267         << "x.has_storage_k(-300) == true : ";
00268     update_success( result = x.has_storage_k(-300) == true, &success );
00269     if(out)
00270       *out<< result << endl;
00271 
00272     if(out)
00273       *out<< "x.has_storage_k(400) == true : ";
00274     update_success( result = x.has_storage_k(400) == true, &success );
00275     if(out)
00276       *out<< result << endl;
00277 
00278     if(out)
00279       *out<< "!x.updated_k(-45) == true : ";
00280     update_success( result = x.updated_k(-45) == false, &success );
00281     if(out)
00282       *out<< result << endl;
00283         
00284     if(out)
00285       *out<< "!x.updated_k(60) == true : ";
00286     update_success( result = x.updated_k(60) == false, &success );
00287     if(out)
00288       *out<< result << endl;
00289 
00290     if(out)
00291       *out<< "\n** Perform an update and check state\n"
00292         << "x.set_k(0) = 5;\n\n";
00293     x.set_k(0) = 5;
00294 
00295     if(out)
00296       *out<< "x.get_k(0) == 5 : ";
00297     r = x.get_k(0);
00298     update_success( result = r == 5, &success );
00299     if(out)
00300       *out<< r << " : " << result << endl;
00301         
00302     if(out)
00303       *out<< "!x.updated_k(-1) == true : ";
00304     update_success( result = x.updated_k(-1) == false, &success );
00305     if(out)
00306       *out<< result << endl;
00307         
00308     if(out)
00309       *out<< "!x.updated_k(1) == true : ";
00310     update_success( result = x.updated_k(1) == false, &success );
00311     if(out)
00312       *out<< result << endl;
00313         
00314     if(out)
00315       *out<< "!x.has_storage_k(-2) == true : ";
00316     update_success( result = x.has_storage_k(-2) == false, &success );
00317     if(out)
00318       *out<< result << endl;
00319         
00320     if(out)
00321       *out<< "x.has_storage_k(-1) == true : ";
00322     update_success( result = x.has_storage_k(-1) == true, &success );
00323     if(out)
00324       *out<< result << endl;
00325         
00326     if(out)
00327       *out<< "x.has_storage_k(1) == true : ";
00328     update_success( result = x.has_storage_k(1) == true, &success );
00329     if(out)
00330       *out<< result << endl;
00331 
00332     if(out)
00333       *out<< "\nx.set_k(-1) = 4;\n\n";
00334     x.set_k(-1) = 4;
00335 
00336     if(out)
00337       *out<< "x.get_k(-1) == 4 : ";
00338     r = x.get_k(-1);
00339     update_success( result = r == 4, &success );
00340     if(out)
00341       *out<< r << " : " << result << endl;
00342 
00343     if(out)
00344       *out<< "\n** Do illegal set_k(), should throw NoStorageAvailable: x.set_k(-2) = 4 : ";
00345     try {
00346       x.set_k(-2) = 4;
00347       success = false;
00348       if(out)
00349         *out<< "false\n";
00350     }
00351     catch(const IterQuantity::NoStorageAvailable& excpt) {
00352       if(out)
00353         *out<< "As expected!  Caught IterQuantity::NoStorageAvailable: " << excpt.what() << " : true\n" << endl;
00354     }
00355 
00356     if(out)
00357       *out<< "\n** Do illegal get_k(), should throw QuanityNotSet: x.get_k(1) : ";
00358     try {
00359       x.get_k(1);
00360       success = false;
00361       if(out)
00362         *out<< "false\n";
00363     }
00364     catch(const IterQuantity::QuanityNotSet& excpt) {
00365       if(out)
00366       *out<< "As expected!  Caught IterQuantity::QuanityNotSet: " << excpt.what() << " : true\n" << endl;
00367     }
00368 
00369     if(out)
00370       *out<< "\nx.next_iteration();\n\n";
00371     x.next_iteration();
00372 
00373     if(out)
00374       *out<< "x.get_k(-2) == 4 : ";
00375     r = x.get_k(-2);
00376     update_success( result = r == 4, &success );
00377     if(out)
00378       *out<< r << " : " << result << endl;
00379         
00380     if(out)
00381       *out<< "x.get_k(-1) == 5 : ";
00382     r = x.get_k(-1);
00383     update_success( result = r == 5, &success );
00384     if(out)
00385       *out<< r << " : " << result << endl;
00386         
00387     if(out)
00388       *out<< "!x.updated_k(-3) == true : ";
00389     update_success( result = x.updated_k(-3) == false, &success );
00390     if(out)
00391       *out<< result << endl;
00392         
00393     if(out)
00394       *out<< "!x.updated_k(0) == true : ";
00395     update_success( result = x.updated_k(0) == false, &success );
00396     if(out)
00397       *out<< result << endl;
00398         
00399     if(out)
00400       *out<< "!x.has_storage_k(-3) == true : ";
00401     update_success( result = x.has_storage_k(-3) == false, &success );
00402     if(out)
00403       *out<< result << endl;
00404         
00405     if(out)
00406       *out<< "!x.has_storage_k(0) == true : ";
00407     update_success( result = x.has_storage_k(0) == true, &success );
00408     if(out)
00409       *out<< result << endl;
00410 
00411     if(out)
00412       *out<< "x.set_k(0,-1);\n\n";
00413     {
00414       x.set_k(0,-1);
00415     }
00416 
00417     if(out)
00418       *out<< "x.get_k(0) == 5 : ";
00419     r = x.get_k(0);
00420     update_success( result = r == 5, &success );
00421     if(out)
00422       *out<< r << " : " << result << endl;
00423         
00424     if(out)
00425       *out<< "x.get_k(-1) == 5 : ";
00426     r = x.get_k(-1);
00427     update_success( result = r == 5, &success );
00428     if(out)
00429       *out<< r << " : " << result << endl;
00430         
00431     if(out)
00432       *out<< "!x.updated_k(-2) == true : ";
00433     update_success( result = x.updated_k(-2) == false, &success );
00434     if(out)
00435       *out<< result << endl;
00436   
00437     if(out)
00438       *out<< "!x.will_loose_mem(0,1) == true : ";
00439     update_success( result = x.will_loose_mem(0,1) == false, &success );
00440     if(out)
00441       *out<< result << endl;
00442       
00443     if(out)
00444       *out<< "x.will_loose_mem(-1,1) == true : ";
00445     update_success( result = x.will_loose_mem(-1,1) == true, &success );
00446     if(out)
00447       *out<< result << endl;
00448     
00449     if(out)
00450       *out<< "\nx.set_k(1) = -4;\n\n";
00451     x.set_k(1) = -4;
00452     
00453     if(out)
00454       *out<< "x.get_k(1) == -4 : ";
00455     r = x.get_k(1);
00456     update_success( result = r == -4, &success );
00457     if(out)
00458       *out<< r << " : " << result << endl;
00459         
00460     if(out)
00461       *out<< "x.get_k(0) == 5 : ";
00462     r = x.get_k(0);
00463     update_success( result = r == 5, &success );
00464     if(out)
00465       *out<< r << " : " << result << endl;
00466 
00467     if(out)
00468       *out<< "\nx.next_iteration();\n\n";
00469     x.next_iteration();
00470 
00471     if(out)
00472       *out<< "x.get_k(0) == -4 : ";
00473     r = x.get_k(0);
00474     update_success( result = r == -4, &success );
00475     if(out)
00476       *out<< r << " : " << result << endl;
00477     
00478   }
00479 
00480   // Create a 4 storage and test it
00481   {
00482     if(out)
00483       *out<< "\n*** Test 4 storage ***\n"
00484         << "IterQuantityAccessContiguous<int> x_cont(4,\"x\");\n"
00485         << "IterQuantityAccess<int>& x = x_cont;\n";
00486     IterQuantityAccessContiguous<int> x_cont(
00487       4, "x"
00488 #ifdef _MIPS_CXX
00489       ,Teuchos::RefCountPtr<Teuchos::AbstractFactoryStd<int,int> >(
00490         new Teuchos::AbstractFactoryStd<int,int>())
00491 #endif      
00492       );
00493     IterQuantityAccess<int>& x = x_cont;
00494 
00495     if(out)
00496       *out<< "\n** Check state\n";
00497         
00498     if(out)
00499       *out<< "x.has_storage_k(-300) == true : ";
00500     update_success( result = x.has_storage_k(-300) == true, &success );
00501     if(out)
00502       *out<< result << endl;
00503         
00504     if(out)
00505       *out<< "x.has_storage_k(400) == true : ";
00506     update_success( result = x.has_storage_k(400) == true, &success );
00507     if(out)
00508       *out<< result << endl;
00509         
00510     if(out)
00511       *out<< "!x.updated_k(-45) == true : ";
00512     update_success( result = x.updated_k(-45) == false, &success );
00513     if(out)
00514       *out<< result << endl;
00515         
00516     if(out)
00517       *out<< "!x.updated_k(60) == true : ";
00518     update_success( result = x.updated_k(60) == false, &success );
00519     if(out)
00520       *out<< result << endl;
00521 
00522     if(out)
00523       *out<< "\n** Perform an update and check state\n"
00524         << "x.set_k(0) = 1;\n\n";
00525     x.set_k(0) = 1;
00526 
00527     if(out)
00528       *out<< "x.get_k(0) == 1 : ";
00529     r = x.get_k(0);
00530     update_success( result = r == 1, &success );
00531     if(out)
00532       *out<< r << " : " << result << endl;
00533         
00534     if(out)
00535       *out<< "!x.updated_k(-4) == true : ";
00536     update_success( result = x.updated_k(-4) == false, &success );
00537     if(out)
00538       *out<< result << endl;
00539         
00540     if(out)
00541       *out<< "!x.updated_k(-3) == true : ";
00542     update_success( result = x.updated_k(-3) == false, &success );
00543     if(out)
00544       *out<< result << endl;
00545         
00546     if(out)
00547       *out<< "!x.updated_k(-2) == true : ";
00548     update_success( result = x.updated_k(-2) == false, &success );
00549     if(out)
00550       *out<< result << endl;
00551         
00552     if(out)
00553       *out<< "!x.updated_k(-1) == true : ";
00554     update_success( result = x.updated_k(-1) == false, &success );
00555     if(out)
00556       *out<< result << endl;
00557         
00558     if(out)
00559       *out<< "x.updated_k(0) == true : ";
00560     update_success( result = x.updated_k(0) == true, &success );
00561     if(out)
00562       *out<< result << endl;
00563         
00564     if(out)
00565       *out<< "!x.updated_k(1) == true : ";
00566     update_success( result = x.updated_k(1) == false, &success );
00567     if(out)
00568       *out<< result << endl;
00569         
00570     if(out)
00571       *out<< "!x.has_storage_k(-4) == true : ";
00572     update_success( result = x.has_storage_k(-4) == false, &success );
00573     if(out)
00574       *out<< result << endl;
00575         
00576     if(out)
00577       *out<< "x.has_storage_k(-3) == true : ";
00578     update_success( result = x.has_storage_k(-3) == true, &success );
00579     if(out)
00580       *out<< result << endl;
00581         
00582     if(out)
00583       *out<< "x.has_storage_k(-2) == true : ";
00584     update_success( result = x.has_storage_k(-2) == true, &success );
00585     if(out)
00586       *out<< result << endl;
00587         
00588     if(out)
00589       *out<< "x.has_storage_k(-1) == true : ";
00590     update_success( result = x.has_storage_k(-1) == true, &success );
00591     if(out)
00592       *out<< result << endl;
00593         
00594     if(out)
00595       *out<< "x.has_storage_k(0) == true : ";
00596     update_success( result = x.has_storage_k(0) == true, &success );
00597     if(out)
00598       *out<< result << endl;
00599         
00600     if(out)
00601       *out<< "x.has_storage_k(1) == true : ";
00602     update_success( result = x.has_storage_k(1) == true, &success );
00603     if(out)
00604       *out<< result << endl;
00605 
00606     if(out)
00607       *out<< "\nx.set_k(-1) = 2;\n\n";
00608     x.set_k(-1) = 2;
00609     
00610     if(out)
00611       *out<< "x.get_k(-1) == 2 : ";
00612     r = x.get_k(-1);
00613     update_success( result = r == 2, &success );
00614     if(out)
00615       *out<< r << " : " << result << endl;
00616 
00617     if(out)
00618       *out<< "\nx.set_k(-2) = 3;\n"
00619         << "x.set_k(-3) = 4;\n\n";
00620     x.set_k(-2) = 3;
00621     x.set_k(-3) = 4;
00622   
00623     if(out)
00624       *out<< "x.get_k(-2) == 3 : ";
00625     r = x.get_k(-2);
00626     update_success( result = r == 3, &success );
00627     if(out)
00628       *out<< r << " : " << result << endl;
00629         
00630     if(out)
00631       *out<< "x.get_k(-3) == 4 : ";
00632     r = x.get_k(-3);
00633     update_success( result = r == 4, &success );
00634     if(out)
00635       *out<< r << " : " << result << endl;
00636 
00637 
00638     if(out)
00639       *out<< "\n** Do illegal set_k(), should throw NoStorageAvailable: x.set_k(-4) = 4 : ";
00640     try {
00641       x.set_k(-4) = 4;
00642       success = false;
00643       if(out)
00644         *out<< "false\n";
00645     }
00646     catch(const IterQuantity::NoStorageAvailable& excpt) {
00647       if(out)
00648         *out<< "As expected!  Caught IterQuantity::NoStorageAvailable: " << excpt.what() << " : true\n" << endl;
00649     }
00650 
00651     if(out)
00652       *out<< "\n** Do illegal get_k(), should throw QuanityNotSet: x.get_k(1) : ";
00653     try {
00654       x.get_k(1);
00655       success = false;
00656       if(out)
00657         *out<< "false\n";
00658     }
00659     catch(const IterQuantity::QuanityNotSet& excpt) {
00660       if(out)
00661         *out<< "As expected!  Caught IterQuantity::QuanityNotSet: " << excpt.what() << " : true" << endl;
00662     }
00663 
00664     if(out)
00665       *out<< "\nx.next_iteration();\n\n";
00666     x.next_iteration();
00667 
00668     if(out)
00669       *out<< "x.get_k(-4) == 4 : ";
00670     r = x.get_k(-4);
00671     update_success( result = r == 4, &success );
00672     if(out)
00673       *out<< r << " : " << result << endl;
00674         
00675     if(out)
00676       *out<< "x.get_k(-3) == 3 : ";
00677     r = x.get_k(-3);
00678     update_success( result = r == 3, &success );
00679     if(out)
00680       *out<< r << " : " << result << endl;
00681         
00682     if(out)
00683       *out<< "x.get_k(-2) == 2 : ";
00684     r = x.get_k(-2);
00685     update_success( result = r == 2, &success );
00686     if(out)
00687       *out<< r << " : " << result << endl;
00688         
00689     if(out)
00690       *out<< "x.get_k(-1) == 1 : ";
00691     r = x.get_k(-1);
00692     update_success( result = r == 1, &success );
00693     if(out)
00694       *out<< r << " : " << result << endl;
00695         
00696     if(out)
00697       *out<< "!x.updated_k(-5) == true : ";
00698     update_success( result = x.updated_k(-5) == false, &success );
00699     if(out)
00700       *out<< result << endl;
00701         
00702     if(out)
00703       *out<< "!x.updated_k(0) == true : ";
00704     update_success( result = x.updated_k(0) == false, &success );
00705     if(out)
00706       *out<< result << endl;
00707         
00708     if(out)
00709       *out<< "!x.has_storage_k(-5) == true : ";
00710     update_success( result = x.has_storage_k(-5) == false, &success );
00711     if(out)
00712       *out<< result << endl;
00713         
00714     if(out)
00715       *out<< "x.has_storage_k(0) == true : ";
00716     update_success( result = x.has_storage_k(0) == true, &success );
00717     if(out)
00718       *out<< result << endl;
00719 
00720     if(out)
00721       *out<< "\nx.set_k(0,-1);\n\n";
00722     {
00723       x.set_k(0,-1);
00724     }
00725 
00726     if(out)
00727       *out<< "x.get_k(-3) == 3 : ";
00728     r = x.get_k(-3);
00729     update_success( result = r == 3, &success );
00730     if(out)
00731       *out<< r << " : " << result << endl;
00732         
00733     if(out)
00734       *out<< "x.get_k(-2) == 2 : ";
00735     r = x.get_k(-2);
00736     update_success( result = r == 2, &success );
00737     if(out)
00738       *out<< r << " : " << result << endl;
00739         
00740     if(out)
00741       *out<< "x.get_k(-1) == 1 : ";
00742     r = x.get_k(-1);
00743     update_success( result = r == 1, &success );
00744     if(out)
00745       *out<< r << " : " << result << endl;
00746         
00747     if(out)
00748       *out<< "x.get_k(0) == 1 : ";
00749     r = x.get_k(0);
00750     update_success( result = r == 1, &success );
00751     if(out)
00752       *out<< r << " : " << result << endl;
00753         
00754     if(out)
00755       *out<< "!x.updated_k(-4) == true : ";
00756     update_success( result = x.updated_k(-4) == false, &success );
00757     if(out)
00758       *out<< result << endl;
00759         
00760     if(out)
00761       *out<< "!x.will_loose_mem(-2,1) == true : ";
00762     update_success( result = x.will_loose_mem(-2,1) == false, &success );
00763     if(out)
00764       *out<< result << endl;
00765         
00766     if(out)
00767       *out<< "x.will_loose_mem(-3,1) == true : ";
00768     update_success( result = x.will_loose_mem(-3,1) == true, &success );
00769     if(out)
00770       *out<< result << endl;
00771 
00772     if(out)
00773       *out<< "\nx.set_k(1) = -4;\n\n";
00774     x.set_k(1) = -4;
00775 
00776     if(out)
00777       *out<< "x.get_k(-2) == 2 : ";
00778     r = x.get_k(-2);
00779     update_success( result = r == 2, &success );
00780     if(out)
00781       *out<< r << " : " << result << endl;
00782         
00783     if(out)
00784       *out<< "x.get_k(-1) == 1 : ";
00785     r = x.get_k(-1);
00786     update_success( result = r == 1, &success );
00787     if(out)
00788       *out<< r << " : " << result << endl;
00789         
00790     if(out)
00791       *out<< "x.get_k(0) == 1 : ";
00792     r = x.get_k(0);
00793     update_success( result = r == 1, &success );
00794     if(out)
00795       *out<< r << " : " << result << endl;
00796         
00797     if(out)
00798       *out<< "x.get_k(1) == -4 : ";
00799     r = x.get_k(1);
00800     update_success( result = r == -4, &success );
00801     if(out)
00802       *out<< r << " : " << result << endl;
00803 
00804     if(out)
00805       *out<< "\nx.next_iteration();\n\n";
00806     x.next_iteration();
00807 
00808     if(out)
00809       *out<< "x.get_k(-2) == 1 : ";
00810     r = x.get_k(-2);
00811     update_success( result = r == 1, &success );
00812     if(out)
00813       *out<< r << " : " << result << endl;
00814 
00815     if(out)
00816       *out<< "x.get_k(-1) == 1 : ";
00817     r = x.get_k(-1);
00818     update_success( result = r == 1, &success );
00819     if(out)
00820       *out<< r << " : " << result << endl;
00821         
00822     if(out)
00823       *out<< "x.get_k(0) == -4 : ";
00824     r = x.get_k(0);
00825     update_success( result = r == -4, &success );
00826     if(out)
00827       *out<< r << " : " << result << endl;
00828   }
00829 
00830   if(success) {
00831     if(out)
00832       *out<< "\n*** Congradulations, all of the tests returned the expected results ***\n";
00833   }
00834   else {
00835     if(out)
00836       *out<< "\n*** Oops, at least one of the above tests did not return the expected results ***\n";
00837   }
00838 
00839   return success;
00840 
00841   } // end try
00842   catch(const std::exception& excpt) {
00843     if(out)
00844       *out<< "\nCaught a std::exception: " << excpt.what() << endl;
00845   }
00846   catch(...) {
00847     if(out)
00848       *out<< "\nCaught and unknown exception\n";
00849   }
00850 
00851   return false;
00852 }

Generated on Thu Sep 18 12:35:16 2008 for MOOCHO (Single Doxygen Collection) by doxygen 1.3.9.1