1 /*=========================================================================
2 
3   Program: GDCM (Grassroots DICOM). A DICOM library
4 
5   Copyright (c) 2006-2011 Mathieu Malaterre
6   All rights reserved.
7   See Copyright.txt or http://gdcm.sourceforge.net/Copyright.html for details.
8 
9      This software is distributed WITHOUT ANY WARRANTY; without even
10      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
11      PURPOSE.  See the above copyright notice for more information.
12 
13 =========================================================================*/
14 #include "gdcmSwapper.h"
15 
16 
TestSwapper(int argc,char * argv[])17 int TestSwapper(int argc, char *argv[])
18 {
19   (void)argv; (void)argc;
20   int res = 0;
21 
22   using testswapper = union {
23     uint64_t v64;
24     uint32_t v32[2];
25     uint16_t v16[4];
26     uint8_t  v8[8];
27   };
28   testswapper t;
29   for(uint_fast8_t i = 0; i < 8; ++i) t.v8[i] = i;
30 
31   testswapper val;
32   val.v64 = gdcm::SwapperDoOp::Swap(t.v64);
33   //for(int i = 0; i < 8; ++i) std::cout << (int)val.v8[i] << std::endl;
34   for(int i = 0; i < 8; ++i)
35     {
36     if( val.v8[i] != 8 - i - 1)
37       {
38       ++res;
39       }
40     }
41 
42 
43   return res;
44 }
45