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