Show
Ignore:
Timestamp:
12/24/06 07:27:43 (2 years ago)
Author:
cneumann
Message:

Added copyright headers,
wrapped test contents in SUITEs

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/Source/System/NodeCores/Drawables/Geometry/Base/WS/OSGGeometryTest.cpp

    r264 r457  
     1/*---------------------------------------------------------------------------*\ 
     2 *                                OpenSG                                     * 
     3 *                                                                           * 
     4 *                                                                           * 
     5 *               Copyright (C) 2000-2006 by the OpenSG Forum                 * 
     6 *                                                                           * 
     7 *   contact: dirk@opensg.org, gerrit.voss@vossg.org, jbehr@zgdv.de          * 
     8 *                                                                           * 
     9\*---------------------------------------------------------------------------*/ 
     10/*---------------------------------------------------------------------------*\ 
     11 *                                License                                    * 
     12 *                                                                           * 
     13 * This library is free software; you can redistribute it and/or modify it   * 
     14 * under the terms of the GNU Library General Public License as published    * 
     15 * by the Free Software Foundation, version 2.                               * 
     16 *                                                                           * 
     17 * This library is distributed in the hope that it will be useful, but       * 
     18 * WITHOUT ANY WARRANTY; without even the implied warranty of                * 
     19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU         * 
     20 * Library General Public License for more details.                          * 
     21 *                                                                           * 
     22 * You should have received a copy of the GNU Library General Public         * 
     23 * License along with this library; if not, write to the Free Software       * 
     24 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.                 * 
     25 *                                                                           * 
     26\*---------------------------------------------------------------------------*/ 
     27/*---------------------------------------------------------------------------*\ 
     28 *                                Changes                                    * 
     29 *                                                                           * 
     30 *                                                                           * 
     31 *                                                                           * 
     32 *                                                                           * 
     33 *                                                                           * 
     34 *                                                                           * 
     35\*---------------------------------------------------------------------------*/ 
     36 
    137#include <UnitTest++.h> 
    238 
     
    945#include <OpenSG/OSGTypedGeoVectorProperty.h> 
    1046 
     47SUITE(GeometryTests) 
     48{ 
    1149 
    1250TEST(CreateGeometry) 
    1351{ 
    14    OSG::GeometryPtr g = OSG::Geometry::create(); 
    15    CHECK(g != OSG::NullFC); 
     52    OSG::GeometryPtr g = OSG::Geometry::create(); 
     53    CHECK(g != OSG::NullFC); 
    1654} 
    1755 
    1856TEST(TestInitialValues) 
    1957{ 
    20    OSG::GeometryPtr g = OSG::Geometry::create(); 
    21    CHECK(g != OSG::NullFC); 
    22  
    23    for(unsigned i=0;i<OSG::Geometry::MaxAttribs;i++) 
    24    
    25       CHECK(g->getProperty(i) == OSG::NullFC); 
    26       CHECK(g->getIndex(i) == OSG::NullFC); 
    27    
    28  
    29    CHECK(g->getMaterial() == OSG::NullFC); 
     58    OSG::GeometryPtr g = OSG::Geometry::create(); 
     59    CHECK(g != OSG::NullFC); 
     60 
     61    for(unsigned i=0;i<OSG::Geometry::MaxAttribs;i++) 
     62   
     63        CHECK(g->getProperty(i) == OSG::NullFC); 
     64        CHECK(g->getIndex(i) == OSG::NullFC); 
     65   
     66 
     67    CHECK(g->getMaterial() == OSG::NullFC); 
    3068} 
    3169 
     
    3371TEST(TestGenericInterfaces) 
    3472{ 
    35    OSG::GeometryPtr g = OSG::Geometry::create(); 
    36    CHECK(g != OSG::NullFC); 
    37  
    38    OSG::GeoPnt3fPropertyPtr  pnts  = OSG::GeoPnt3fProperty ::create(); 
    39    pnts->addValue(OSG::Pnt3f(0,0,0)); 
    40  
    41    g->setPositions(pnts); 
    42  
    43    OSG::GeoVectorPropertyPtr pnts_g = g->getPositions(); 
    44    pnts_g->setValue(OSG::Pnt3f(1,1,1), 0); 
    45    pnts_g->setValue(OSG::Pnt3s(1,1,1), 0); 
    46    pnts_g->setValue(OSG::Pnt2f(1,1  ), 0); 
    47    pnts_g->setValue(OSG::Vec3f(1,1,1), 0); 
    48    pnts_g->setValue(OSG::Vec2f(1,2  ), 0); 
    49    pnts_g->setValue(OSG::Vec4f(1,2,3,4), 0); 
    50    pnts_g->setValue(OSG::Color3f(1,2,3), 0); 
    51    pnts_g->setValue(OSG::Color4f(1,2,3,4), 0); 
     73    OSG::GeometryPtr g = OSG::Geometry::create(); 
     74    CHECK(g != OSG::NullFC); 
     75 
     76    OSG::GeoPnt3fPropertyPtr  pnts  = OSG::GeoPnt3fProperty ::create(); 
     77    pnts->addValue(OSG::Pnt3f(0,0,0)); 
     78 
     79    g->setPositions(pnts); 
     80 
     81    OSG::GeoVectorPropertyPtr pnts_g = g->getPositions(); 
     82    pnts_g->setValue(OSG::Pnt3f(1,1,1), 0); 
     83    pnts_g->setValue(OSG::Pnt3s(1,1,1), 0); 
     84    pnts_g->setValue(OSG::Pnt2f(1,1  ), 0); 
     85    pnts_g->setValue(OSG::Vec3f(1,1,1), 0); 
     86    pnts_g->setValue(OSG::Vec2f(1,2  ), 0); 
     87    pnts_g->setValue(OSG::Vec4f(1,2,3,4), 0); 
     88    pnts_g->setValue(OSG::Color3f(1,2,3), 0); 
     89    pnts_g->setValue(OSG::Color4f(1,2,3,4), 0); 
    5290} 
    5391 
     
    5593TEST(TestSettingVecAttribs) 
    5694{ 
    57    // Test setting attributes to all possible value types 
    58    OSG::GeometryPtr g = OSG::Geometry::create(); 
    59    CHECK(g != OSG::NullFC); 
    60  
    61    // Copied-and-macroed from OSGTypedGeoVectorPropertyFields 
    62    char* allowed_vec_prop_types[] = 
    63    
    64 "GeoVec1ubProperty", 
    65 "GeoVec2ubProperty", 
    66 "GeoVec3ubProperty", 
    67 "GeoVec4ubProperty", 
    68  
    69 "GeoPnt1ubProperty", 
    70 "GeoPnt2ubProperty", 
    71 "GeoPnt3ubProperty", 
    72 "GeoPnt4ubProperty", 
    73  
    74 "GeoVec1NubProperty", 
    75 "GeoVec2NubProperty", 
    76 "GeoVec3NubProperty", 
    77 "GeoVec4NubProperty", 
    78  
    79 "GeoPnt1NubProperty", 
    80 "GeoPnt2NubProperty", 
    81 "GeoPnt3NubProperty", 
    82 "GeoPnt4NubProperty", 
    83  
    84  
    85 "GeoVec1bProperty", 
    86 "GeoVec2bProperty", 
    87 "GeoVec3bProperty", 
    88 "GeoVec4bProperty", 
    89  
    90 "GeoPnt1bProperty", 
    91 "GeoPnt2bProperty", 
    92 "GeoPnt3bProperty", 
    93 "GeoPnt4bProperty", 
    94  
    95 "GeoVec1NbProperty", 
    96 "GeoVec2NbProperty", 
    97 "GeoVec3NbProperty", 
    98 "GeoVec4NbProperty", 
    99  
    100 "GeoPnt1NbProperty", 
    101 "GeoPnt2NbProperty", 
    102 "GeoPnt3NbProperty", 
    103 "GeoPnt4NbProperty", 
    104  
    105  
    106 "GeoVec1usProperty", 
    107 "GeoVec2usProperty", 
    108 "GeoVec3usProperty", 
    109 "GeoVec4usProperty", 
    110  
    111 "GeoPnt1usProperty", 
    112 "GeoPnt2usProperty", 
    113 "GeoPnt3usProperty", 
    114 "GeoPnt4usProperty", 
    115  
    116 "GeoVec1NusProperty", 
    117 "GeoVec2NusProperty", 
    118 "GeoVec3NusProperty", 
    119 "GeoVec4NusProperty", 
    120  
    121 "GeoPnt1NusProperty", 
    122 "GeoPnt2NusProperty", 
    123 "GeoPnt3NusProperty", 
    124 "GeoPnt4NusProperty", 
    125  
    126  
    127 "GeoVec1sProperty", 
    128 "GeoVec2sProperty", 
    129 "GeoVec3sProperty", 
    130 "GeoVec4sProperty", 
    131  
    132 "GeoPnt1sProperty", 
    133 "GeoPnt2sProperty", 
    134 "GeoPnt3sProperty", 
    135 "GeoPnt4sProperty", 
    136  
    137 "GeoVec1NsProperty", 
    138 "GeoVec2NsProperty", 
    139 "GeoVec3NsProperty", 
    140 "GeoVec4NsProperty", 
    141  
    142 "GeoPnt1NsProperty", 
    143 "GeoPnt2NsProperty", 
    144 "GeoPnt3NsProperty", 
    145 "GeoPnt4NsProperty", 
     95    // Test setting attributes to all possible value types 
     96    OSG::GeometryPtr g = OSG::Geometry::create(); 
     97    CHECK(g != OSG::NullFC); 
     98 
     99    // Copied-and-macroed from OSGTypedGeoVectorPropertyFields 
     100    char* allowed_vec_prop_types[] = 
     101   
     102        "GeoVec1ubProperty", 
     103        "GeoVec2ubProperty", 
     104        "GeoVec3ubProperty", 
     105        "GeoVec4ubProperty", 
     106 
     107        "GeoPnt1ubProperty", 
     108        "GeoPnt2ubProperty", 
     109        "GeoPnt3ubProperty", 
     110        "GeoPnt4ubProperty", 
     111 
     112        "GeoVec1NubProperty", 
     113        "GeoVec2NubProperty", 
     114        "GeoVec3NubProperty", 
     115        "GeoVec4NubProperty", 
     116 
     117        "GeoPnt1NubProperty", 
     118        "GeoPnt2NubProperty", 
     119        "GeoPnt3NubProperty", 
     120        "GeoPnt4NubProperty", 
     121 
     122 
     123        "GeoVec1bProperty", 
     124        "GeoVec2bProperty", 
     125        "GeoVec3bProperty", 
     126        "GeoVec4bProperty", 
     127 
     128        "GeoPnt1bProperty", 
     129        "GeoPnt2bProperty", 
     130        "GeoPnt3bProperty", 
     131        "GeoPnt4bProperty", 
     132 
     133        "GeoVec1NbProperty", 
     134        "GeoVec2NbProperty", 
     135        "GeoVec3NbProperty", 
     136        "GeoVec4NbProperty", 
     137 
     138        "GeoPnt1NbProperty", 
     139        "GeoPnt2NbProperty", 
     140        "GeoPnt3NbProperty", 
     141        "GeoPnt4NbProperty", 
     142 
     143 
     144        "GeoVec1usProperty", 
     145        "GeoVec2usProperty", 
     146        "GeoVec3usProperty", 
     147        "GeoVec4usProperty", 
     148 
     149        "GeoPnt1usProperty", 
     150        "GeoPnt2usProperty", 
     151        "GeoPnt3usProperty", 
     152        "GeoPnt4usProperty", 
     153 
     154        "GeoVec1NusProperty", 
     155        "GeoVec2NusProperty", 
     156        "GeoVec3NusProperty", 
     157        "GeoVec4NusProperty", 
     158 
     159        "GeoPnt1NusProperty", 
     160        "GeoPnt2NusProperty", 
     161        "GeoPnt3NusProperty", 
     162        "GeoPnt4NusProperty", 
     163 
     164 
     165        "GeoVec1sProperty", 
     166        "GeoVec2sProperty", 
     167        "GeoVec3sProperty", 
     168        "GeoVec4sProperty", 
     169 
     170        "GeoPnt1sProperty", 
     171        "GeoPnt2sProperty", 
     172        "GeoPnt3sProperty", 
     173        "GeoPnt4sProperty", 
     174 
     175        "GeoVec1NsProperty", 
     176        "GeoVec2NsProperty", 
     177        "GeoVec3NsProperty", 
     178        "GeoVec4NsProperty", 
     179 
     180        "GeoPnt1NsProperty", 
     181        "GeoPnt2NsProperty", 
     182        "GeoPnt3NsProperty", 
     183        "GeoPnt4NsProperty", 
    146184 
    147185#ifndef OSG_WINCE 
    148 "GeoVec1fProperty", 
    149 "GeoVec2fProperty", 
    150 "GeoVec3fProperty", 
    151 "GeoVec4fProperty", 
    152  
    153 "GeoPnt1fProperty", 
    154 "GeoPnt2fProperty", 
    155 "GeoPnt3fProperty", 
    156 "GeoPnt4fProperty", 
     186        "GeoVec1fProperty", 
     187        "GeoVec2fProperty", 
     188        "GeoVec3fProperty", 
     189        "GeoVec4fProperty", 
     190 
     191        "GeoPnt1fProperty", 
     192        "GeoPnt2fProperty", 
     193        "GeoPnt3fProperty", 
     194        "GeoPnt4fProperty", 
    157195#endif 
    158196 
    159197#ifdef OSG_WINCE 
    160 "GeoVec1fxProperty", 
    161 "GeoVec2fxProperty", 
    162 "GeoVec3fxProperty", 
    163 "GeoVec4fxProperty", 
    164  
    165 "GeoPnt1fxProperty", 
    166 "GeoPnt2fxProperty", 
    167 "GeoPnt3fxProperty", 
    168 "GeoPnt4fxProperty", 
     198        "GeoVec1fxProperty", 
     199        "GeoVec2fxProperty", 
     200        "GeoVec3fxProperty", 
     201        "GeoVec4fxProperty", 
     202 
     203        "GeoPnt1fxProperty", 
     204        "GeoPnt2fxProperty", 
     205        "GeoPnt3fxProperty", 
     206        "GeoPnt4fxProperty", 
    169207#endif 
    170208 
    171209#ifndef OSG_WINCE 
    172 "GeoVec1dProperty", 
    173 "GeoVec2dProperty", 
    174 "GeoVec3dProperty", 
    175 "GeoVec4dProperty", 
    176  
    177 "GeoPnt1dProperty", 
    178 "GeoPnt2dProperty", 
    179 "GeoPnt3dProperty", 
    180 "GeoPnt4dProperty", 
     210        "GeoVec1dProperty", 
     211        "GeoVec2dProperty", 
     212        "GeoVec3dProperty", 
     213        "GeoVec4dProperty", 
     214 
     215        "GeoPnt1dProperty", 
     216        "GeoPnt2dProperty", 
     217        "GeoPnt3dProperty", 
     218        "GeoPnt4dProperty", 
    181219#endif 
    182220 
    183 "GeoColor3ubProperty", 
    184 "GeoColor4ubProperty", 
    185 "GeoColor3NubProperty", 
    186 "GeoColor4NubProperty", 
    187  
    188 "GeoColor3fProperty", 
    189 "GeoColor4fProperty" 
    190    }; 
    191  
    192    OSG::GeoVectorPropertyPtr att; 
    193  
    194    unsigned num_vec_props = sizeof(allowed_vec_prop_types)/sizeof(char*); 
    195  
    196    for(unsigned i=0; i<num_vec_props;++i) 
    197    { 
    198       att = OSG::cast_dynamic<OSG::GeoVectorPropertyPtr>( 
    199                 OSG::FieldContainerFactory::the()->createContainer( 
    200                     allowed_vec_prop_types[i])); 
    201       unsigned prop_index = i%16; 
    202       g->setProperty(att,prop_index); 
    203       CHECK(true); 
    204    } 
    205  
    206 
    207  
    208  
    209  
    210  
     221        "GeoColor3ubProperty", 
     222        "GeoColor4ubProperty", 
     223        "GeoColor3NubProperty", 
     224        "GeoColor4NubProperty", 
     225 
     226        "GeoColor3fProperty", 
     227        "GeoColor4fProperty" 
     228    }; 
     229 
     230    OSG::GeoVectorPropertyPtr att; 
     231 
     232    unsigned num_vec_props = sizeof(allowed_vec_prop_types) / sizeof(char*); 
     233 
     234    for(unsigned i = 0; i < num_vec_props;++i) 
     235    { 
     236        att = OSG::cast_dynamic<OSG::GeoVectorPropertyPtr>( 
     237                    OSG::FieldContainerFactory::the()->createContainer( 
     238                        allowed_vec_prop_types[i])); 
     239        unsigned prop_index = i % 16; 
     240        g->setProperty(att,prop_index); 
     241        CHECK(true); 
     242    } 
     243 
     244
     245 
     246} // SUITE 
     247