LCOV - code coverage report
Current view: top level - atmosphere/ATM/test - LengthTest.cc (source / functions) Hit Total Coverage
Test: casacpp_coverage.info Lines: 67 67 100.0 %
Date: 2024-10-10 19:51:30 Functions: 1 1 100.0 %

          Line data    Source code
       1             : /*******************************************************************************
       2             :  * ALMA - Atacama Large Millimeter Array
       3             :  * (c) Instituto de Estructura de la Materia, 2011
       4             :  * (in the framework of the ALMA collaboration).
       5             :  * All rights reserved.
       6             :  * 
       7             :  * This library is free software; you can redistribute it and/or
       8             :  * modify it under the terms of the GNU Lesser General Public
       9             :  * License as published by the Free Software Foundation; either
      10             :  * version 2.1 of the License, or (at your option) any later version.
      11             :  * 
      12             :  * This library is distributed in the hope that it will be useful,
      13             :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      14             :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
      15             :  * Lesser General Public License for more details.
      16             :  * 
      17             :  * You should have received a copy of the GNU Lesser General Public
      18             :  * License along with this library; if not, write to the Free Software
      19             :  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
      20             :  *******************************************************************************/
      21             : 
      22             : using namespace std;
      23             : 
      24             : #include <iostream>
      25             : #include <atmosphere/ATM/ATMLength.h>
      26             : #include <string>
      27             : 
      28             :  
      29             : using namespace atm;
      30             : 
      31           1 : int main()
      32             : {
      33           1 :   Length longueur(10); 
      34           1 :   cout << "longueur=" << longueur.get("km") << "km" << endl;
      35           1 :   cout << "longueur=" << longueur.get() << "m" << endl;
      36             :   
      37           3 :   Length h(10,"km"), dh(10,"m"), hsum, hdif;
      38           1 :   cout << h.get()+dh.get() << endl;
      39           1 :   hsum = h+dh;
      40           1 :   cout << hsum.get() << endl;
      41           1 :   cout << hsum.get("KM") << "KM" << endl;
      42           1 :   cout << hsum.get("km") << "km" << endl;
      43           1 :   Length z;
      44           1 :   z = 20;
      45           2 :   Length dz(20,"mm");
      46           1 :   hdif = z-dz; 
      47           1 :   cout << hdif.get() << " SI units" << endl;
      48           1 :   cout << hdif.get("mm") << "mm" <<  endl;
      49             :   
      50           1 :   Length hscaled;
      51           1 :   int scf=3;
      52             :   
      53           1 :   hscaled = h*scf;
      54           1 :   cout <<h.get("km")<<"km * "<< scf <<" = "<< hscaled.get() << "m" << endl;
      55             :   
      56             :   
      57           1 :   Length P(10); cout<< "Length P(10) ==> P="<<P.get() << endl;
      58             :   
      59           1 :   Length p = P; cout<< "Length p=P; ==> p="<<p.get() << endl;
      60           1 :   cout << "Test for the relational operators:" << endl;
      61           1 :   if(p>=P)cout << "p>=P" << endl;
      62           1 :   if(p<=P)cout << "p<=P" << endl;
      63           1 :   if(p==P)cout << "p==P" << endl;
      64           1 :   cout << "Arithmetic operations:" << endl;
      65           1 :   p = P+p; cout<< "p=P+p ==> p=" << p.get() << endl;
      66           1 :   cout << "P=" <<P.get() << " must not change of value!" << endl;
      67           1 :   p = p+P; cout<< "p=p+P ==> p=" << p.get() << endl;
      68           1 :   cout << "P=" <<P.get() << " must not change of value!" << endl;
      69           1 :   Length p0; cout << "Let declare p0 be of type Length using the default constructor: Length p0;" << endl;
      70           1 :   p0 = p+P; cout <<"p0 = p+P with p="<<p.get()<<" and P="<<P.get()<<" ==> p0=p+P="<<p0.get()<<endl; 
      71           1 :   Length p1; cout << "Let declare p0 be of type Length using the default constructor: Length p1;" << endl;
      72           1 :   cout << "With no assignement its value must be 0: p1="<<p1.get() << endl;
      73           1 :   if(P<p){
      74           1 :     cout << "Test relational operator P>p: OK" << endl;
      75             :   }
      76           1 :   if(p!=P){
      77           1 :     cout << "Test relational operator p!=P: OK" << endl;
      78             :   } 
      79           1 :   if(p<P)cout << "p<P" << endl;
      80           1 :   cout << "Some more tests for arithmetic expressions " << endl;
      81           1 :   p1 = P; cout << "Assign the value of P to p1: p1=P ==> p1=" << p1.get() << endl;
      82           1 :   p1 = p1+p+P;cout << "Arithmetic sum: p1+p+P=" << p1.get() << endl;
      83           1 :   p1 = p1-p-P;cout << "Arithmetic difference: p1-p-P=" << p1.get() << endl;
      84           1 :   p1 = p1*2.0;cout << "Product by a scalar p1=p1*2.0=" << p1.get("mm") << "mm" << endl;
      85           1 :   cout <<"p0="<<p0.get()<<endl;
      86           1 :   p1 = p0*2.0;cout << "p1=p0*2.0=" << p1.get("mm") << "mm" << endl;
      87           1 :   cout <<"--------------------------------------------------------------------------" << endl;
      88           1 :   cout <<"| Note that the commutativity of the oprator * has not been implemented! |" << endl;
      89           1 :   cout <<"--------------------------------------------------------------------------" << endl;
      90           1 :   cout <<"p0="<<p0.get()<<" must have not changed of value" << endl;
      91           1 :   cout <<"p1="<<p1.get()<<endl;
      92           1 :   p1 = p1/2.0e0;cout << "p1=p1/2.0=" << p1.get("mm") << "mm" << endl;
      93           1 :   p1 = p0/2.0;cout << "p1=p0/2.0=" << p1.get("mm") << "mm" << endl;
      94           1 :   cout <<"-----------------------------------------------------------------------" << endl;
      95           1 :   cout <<"| Note that dividing by a physical quantity has not been implemented! |" << endl;
      96           1 :   cout <<"-----------------------------------------------------------------------" << endl;
      97           1 :   cout << endl;
      98           1 :   cout << "Some more tests for arithmetic expressions " << endl;
      99           1 :   cout <<"p0="<<p0.get()<<"  must have not changed of value" << endl;
     100           1 :   cout << "P=" << P.get() << endl;
     101           1 :   p1 = p0*2.0e0+P;
     102           1 :   cout <<"p1=p0*2.0E0+P="<<p1.get()<<endl;
     103           1 :   cout << endl;
     104           1 :   cout << "TESTBED done " << endl;
     105             :   
     106           1 :   return 0;
     107           1 : }
     108             : 

Generated by: LCOV version 1.16