Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* S P H E R E . C P P
- * BRL-CAD
- *
- * Copyright (c) 2014 United States Government as represented by
- * the U.S. Army Research Laboratory.
- *
- * This file is in the public domain.
- *
- * DISCLAIMER OF LIABILITY
- *
- * THIS FILE WAS CAREFULLY TESTED BY THE AUTHOR AND IS MADE AVAILABLE TO YOU
- * FREE-OF-CHARGE IN A HIGH-GRADE ACTUAL STATUS. REFERENCE IS MADE HEREWITH TO
- * THE FACT THAT IT IS NOT POSSIBLE TO DEVELOP SOFTWARE PROGRAMS SO THAT THEY
- * ARE ERROR-FREE FOR ALL APPLICATION CONDITIONS. AS THE FILE IS LICENSED FREE
- * OF CHARGE THERE IS NO WARRANTY FOR IT, INSOFAR AS SUCH WARRANTY IS NOT A
- * MANDATORY REQUIREMENT OF THE APPLICABLE LAW, SUCH AS IN CASE OF WILFUL ACTS.
- * IN ADDITION THERE IS NO LIABILITY ALSO INSOFAR AS SUCH LIABILITY IS NOT A
- * MANDATORY REQUIREMENT OF THE APPLICABLE LAW, SUCH AS IN CASE OF WILFUL ACTS.
- *
- * YOU DECLARE YOU ARE IN AGREEMENT WITH THE USE OF THIS FILE UNDER THE
- * ABOVE-LISTED USAGE CONDITIONS AND THE EXCLUSION OF A GUARANTEE AND OF
- * LIABILITY. SHOULD INDIVIDUAL PROVISIONS IN THESE CONDITIONS BE IN FULL OR IN
- * PART VOID, INVALID OR CONTESTABLE, THE VALIDITY OF ALL OTHER PROVISIONS OR
- * AGREEMENTS ARE UNAFFECTED BY THIS. FURTHER THE PARTIES UNDERTAKE AT THIS
- * JUNCTURE TO AGREE A LEGALLY VALID REPLACEMENT CLAUSE WHICH MOST CLOSELY
- * APPROXIMATES THE ECONOMIC OBJECTIVES.
- */
- /** @file Sphere.cpp
- * This file is a coreInterface test for Sphere.cpp.
- */
- #include <iostream>
- #include <brlcad/Sphere.h>
- using namespace BRLCAD;
- int testSphereCenter(BRLCAD::sphere sph, double expectedX, double expectedY, double expectedZ) /* Tests Sphere's Center function */
- {
- if(sph.Center().coordinates[0]==expectedX && sph.center().coordinates[1]==expectedY && sph.center().coordinates[2]==expectedZ) return 0;
- return 1;
- }
- int testSphereClassName(BRLCAD::sphere sph) /* Tests Sphere's ClassName function */
- {
- if(sph.ClassName()=="Sphere") return 0;
- return 1;
- }
- int testSphereType(BRLCAD::sphere sph) /* Tests Sphere's Type function */
- {
- if(sph.Type()=="Sphere") return 0;
- return 1;
- }
- int testSphereIsValid(BRLCAD::sphere sph) /* Tests Sphere's SphereIsValid function */
- {
- if(sph.IsValid()==true) return 0;
- return 1;
- }
- int testSphereRadius(BRLCAD::sphere sph,double expectedRadius) /* Tests Sphere's SphereRadius function */
- {
- if(sph.Radius()==expectedRadius) return 0;
- return 1;
- }
- int testSphereClone(BRLCAD::Sphere sph) /* Tests Sphere's Clone function */
- {
- BRLCAD::Sphere sph2;
- sph2=sph.clone();
- if(sph2.Center().coordinates[0]==sph.Center().coordinates[0] && sph2.Center().coordinates[1]==sph.Center().coordinates[1] && sph2.Center().coordinates[2]==sph.Center().coordinates[2] && sph2.Radius()==sph.Radius() ) return 0; /* Checks if the two Spheres are equal */
- return 1;
- }
- int testSphereSet() /* Tests Sphere's Set function */
- {
- BRLCAD::Sphere sph2;
- sph2.set(Vector3D(1.0,1.0,1.0),3.0);
- if(sph2.Center().coordinates[0]==1.0 && sph2.Center().coordinates[1]==1.0 && sph2.Center().coordinates[2]==1.0 && sph2.Radius()==3.0) return 0; /* Checks if Set worked properly */
- return 1;
- }
- void test_sphere(BRLCAD::Database& database)
- {
- BRLCAD::sphere sph; /* Initialize a Sphere to test on */
- sph.SetCenter(Vector3D(1.0,1.0,1.0));
- sph.SetRadius(30.0);
- if( testSphereIsValid(sph)==0 )
- if( testSphereType(sph)==0 )
- if( testSphereClassName(sph)==0 )
- if( testSphereCenter(sph, 1.0, 1.0, 1.0)==0 )
- if( testSphereRadius(sph, 30.0)==0 )
- if( testSphereClone(sph)==0 )
- if( testSphereSet()==0 )
- database.add(sph);
- else std::cout<<"Failed test at : Set()";
- else std::cout<<"Failed test at : Clone()";
- else std::cout<<"Failed test at : Radius()";
- else std::cout<<"Failed test at : Center()";
- else std::cout<<"Failed test at : ClassName()";
- else std::cout<<"Failed test at : Type()";
- else std::cout<<"Failed test at : IsValid()";
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement