// // $Id: CylindricalShell_t.cpp,v 1.3 2001/03/21 17:57:11 melanson Exp $ // // File: CylindricalShell_t.cpp // Purpose: Test CylindricalShell class // Created: 03-SEP-1998 Harry L. Melanson // // $Revision: 1.3 $ // // #include #include #include #include #include #include #include using namespace std; using namespace dgs; using namespace D0Material; //////////////////////////////////////////////////////////////////////// // // Need to make a test cylindrical surface // class TestCylinder : public CylindricalSurface { public: TestCylinder(const float r, const float z): CylindricalSurface(r, z){} const list get_children() { list empty; // No childern return empty; } }; // //////////////////////////////////////////////////////////////////////// // int main() { cout << "Testing class: CylindricalShell" << endl << endl; //////////////////////////////////////////////////////////////////////// // // Make sure assert is enabled. // bool assert_flag = false; assert ( ( assert_flag = true, assert_flag ) ); if ( ! assert_flag ) { cerr << "Assert is disabled" << endl; return 1; } //////////////////////////////////////////////////////////////////////// // // Constructor // // Create Handle to CylindricalSurface HandleCache theCache; const TestCylinder* theSurface = new TestCylinder(10.0,20.0); Handle theHandle = theCache.create_handle(1,theSurface); cout << endl; cout << "Check Handle to TestCylinder" << endl << "This should be a cylinder with rad = 10.0, Zlen/2 = 20.0" << endl << *theHandle << endl; assert (theHandle->get_radius() == 10.0); assert (theHandle->get_zhalf() == 20.0); // Create Material carbon const Material theMaterial("Carbon", "C", 6.0, 12.01, 2.265); cout << endl; cout << "Check Material" << endl << "This should be carbon" << endl << theMaterial << endl; // Finally create CylindricalShell, 1 cm thick cout << endl; cout << "Check CylindricalSurface" << endl; cout << endl; cout << " Constructor..." << endl; const float thickness = 1.0; CylindricalShell theShell(theHandle, theMaterial, thickness); cout << " ...OK"; cout << endl; cout << "The CylindricalShell:" << endl << theShell << endl; cout << endl << "Accessors:" << endl; cout << "get_Material() = " << *(theShell.get_Material()) << endl; cout << "get_X0_frac() = " << theShell.get_X0_frac() << endl; cout << "get_Thickness() = " << theShell.get_Thickness() << endl; cout << "get_Surface() = " << *(theShell.get_Surface()) << endl; assert ( *(theShell.get_Material()) == theMaterial ); assert ( theShell.get_Thickness() == thickness ); assert ( abs(theShell.get_X0_frac() - thickness/(theShell.get_Material())->getX0_cm()) < 0.00001 ); assert ((theShell.get_Surface())->get_radius() == 10.0); assert ((theShell.get_Surface())->get_zhalf() == 20.0); return 0; }