CLHEP VERSION Reference Documentation
   
CLHEP Home Page     CLHEP Documentation     CLHEP Bug Reports

testUnits.cc

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 // $Id: testUnits.cc,v 1.4 2011/07/20 23:00:04 garren Exp $
00003 // ---------------------------------------------------------------------------
00004 //
00005 // This file is a part of the CLHEP - a Class Library for High Energy Physics.
00006 //
00007 // This is a small program for testing the Units module
00008 //
00009 
00010 #include <assert.h>
00011 #include "CLHEP/Units/defs.h"
00012 #include "CLHEP/Units/PhysicalConstants.h"
00013 #include <iostream>
00014 #include <iomanip>
00015 #include <sstream>
00016 #include <cmath>
00017 
00018 int main() {
00019 
00020   int nbad=0;
00021 
00022   // Check that local m does not interfere with global m
00023 
00024   double m=0;
00025   for (int i=0; i<7; i++, m++) { assert(m == double(i)); } 
00026   assert(m != CLHEP::meter);  
00027 
00028   //std::cout << "Speed of light is " << std::setw(10) << std::setprecision(8)
00029   //        << CLHEP::c_light << std::endl;
00030   //output: Speed of light is  299.79246
00031 
00032   std::ostringstream os1, os2, os3, os4;
00033   os1 << std::setprecision(8) << CLHEP::c_light;
00034   os2 << "299.79246";
00035   if( os1.str() != os2.str() ) {
00036     std::cout << "compare --" << os1.str() << "-- to --" << os2.str() << "--" << std::endl;
00037     nbad++;
00038   }
00039   os3 << std::setprecision(16) << CLHEP::pi ;
00040   os4 << "3.141592653589793";
00041   if( os3.str() != os4.str() ) {
00042     nbad++;
00043     std::cout << "compare --" << os3.str() << "--" << std::endl;
00044     std::cout << "     to --" << os4.str() << "--" << std::endl;
00045 #ifndef USING_VISUAL
00046     std::cout << "M_PI    --" << std::setprecision(16) << M_PI << "--" << std::endl;
00047 #endif
00048   }
00049   
00050   return nbad;
00051   
00052 }

Generated on 15 Nov 2012 for CLHEP by  doxygen 1.4.7