1 //-*****************************************************************************
2 //
3 // Copyright (c) 2009-2011,
4 //  Sony Pictures Imageworks Inc. and
5 //  Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd.
6 //
7 // All rights reserved.
8 //
9 // Redistribution and use in source and binary forms, with or without
10 // modification, are permitted provided that the following conditions are
11 // met:
12 // *       Redistributions of source code must retain the above copyright
13 // notice, this list of conditions and the following disclaimer.
14 // *       Redistributions in binary form must reproduce the above
15 // copyright notice, this list of conditions and the following disclaimer
16 // in the documentation and/or other materials provided with the
17 // distribution.
18 // *       Neither the name of Industrial Light & Magic nor the names of
19 // its contributors may be used to endorse or promote products derived
20 // from this software without specific prior written permission.
21 //
22 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
25 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
26 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
27 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
28 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
32 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 //
34 //-*****************************************************************************
35 
36 #include <Alembic/Util/Dimensions.h>
37 
main(int,char **)38 int main( int, char** )
39 {
40     using namespace Alembic::Util;
41 
42     //
43     // Test fundamental BaseDimensions class
44     //
45     {
46         typedef  BaseDimensions<int>   IntScalarDimension;
47 
48         IntScalarDimension rank0;
49 
50         IntScalarDimension rank0_val1( (int) 1);
51 
52         IntScalarDimension rank1;
53         rank1.setRank( 1 );
54     }
55 
56     //
57     // Test Dimensions class
58     //
59     {
60         Dimensions rank00;
61         Dimensions rank0;
62 
63         Dimensions rank1( 1 );
64         assert(rank1.rank() == 1);
65         assert(rank1[0] == 1);
66     }
67     {
68         Dimensions rank2;
69         rank2.setRank(2);
70         assert(rank2.rank() == 2);
71 
72         Alembic::Util::uint64_t *ptr = rank2.rootPtr();
73         ptr[0] = 11;
74         ptr[1] = 12;
75         assert( rank2[0] == 11 );
76         assert( rank2[1] == 12 );
77 
78         Dimensions rank2_copy(rank2);
79         assert(rank2_copy.rank() == 2);
80 
81         assert( rank2_copy[0] == 11 );
82         assert( rank2_copy[1] == 12 );
83 
84         assert( rank2_copy == rank2 );
85 
86         Dimensions rank3;
87         rank3.setRank(3);
88         ptr = rank3.rootPtr();
89         ptr[0] = 20;
90         ptr[1] = 21;
91         ptr[2] = 22;
92 
93         rank2_copy = rank3;
94         assert( rank2_copy == rank3 );
95     }
96 
97     std::cout << "Success!" << std::endl;
98 
99     return 0;
100 }
101