Changeset 82

Show
Ignore:
Timestamp:
10/15/07 22:29:56 (1 year ago)
Author:
baxissimo
Message:

Fixed error in new swap_endian function. Added unittests for it.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/OpenMeshD/OpenMesh/Core/IO/BinaryHelper.d

    r79 r82  
    275275    const uint N_2 = N/2; 
    276276    for (uint i=0; i<N/2; i++) { 
    277         util.swap((cast(byte*)&v)[i],(cast(byte*)&v)[N-i]); 
     277        util.swap((cast(byte*)&v)[i], (cast(byte*)&v)[N-i-1]); 
    278278    } 
    279279} 
     
    283283 
    284284unittest { 
     285 
     286    int i = 1; 
     287    swap_endian(i); 
     288    assert(i == 0x01_00_00_00, "int swapped incorrectly"); 
     289    long l = 1; 
     290    swap_endian(l); 
     291    assert(l == 0x01_00_00_00__00_00_00_00L, "long swapped incorrectly"); 
     292    l = 0x01_02_03_04__05_06_07_08L; 
     293    swap_endian(l); 
     294    assert(l == 0x08_07_06_05__04_03_02_01L, "long swapped incorrectly"); 
    285295 
    286296}