Mercurial > hg > orthanc
comparison UnitTestsSources/main.cpp @ 674:d76b747aec1b
improved check for big endianness
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 03 Dec 2013 13:50:08 +0100 |
parents | 900274ed996f |
children | 203157cb4fde |
comparison
equal
deleted
inserted
replaced
673:ca528c365a39 | 674:d76b747aec1b |
---|---|
520 ASSERT_EQ("ef", t[2]); | 520 ASSERT_EQ("ef", t[2]); |
521 ASSERT_EQ("", t[3]); | 521 ASSERT_EQ("", t[3]); |
522 } | 522 } |
523 | 523 |
524 | 524 |
525 | |
526 #if defined(__linux) | |
527 #include <endian.h> | |
528 #endif | |
529 | |
525 TEST(Toolbox, Endianness) | 530 TEST(Toolbox, Endianness) |
526 { | 531 { |
527 #if defined(__powerpc__) || defined(__powerpc64__) | 532 // Parts of this test come from Adam Conrad |
528 ASSERT_EQ(Endianness_Big, Toolbox::DetectEndianness()); | 533 // http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=728822#5 |
529 #endif | |
530 | 534 |
531 #if defined(_WIN32) | 535 #if defined(_WIN32) |
532 ASSERT_EQ(Endianness_Little, Toolbox::DetectEndianness()); | 536 ASSERT_EQ(Endianness_Little, Toolbox::DetectEndianness()); |
537 | |
538 #elif defined(__linux) | |
539 | |
540 #if !defined(__BYTE_ORDER) | |
541 # error Support your platform here | |
533 #endif | 542 #endif |
534 | 543 |
535 #if defined(__amd64__) || defined(__i386__) | 544 # if __BYTE_ORDER == __BIG_ENDIAN |
545 ASSERT_EQ(Endianness_Big, Toolbox::DetectEndianness()); | |
546 # else // __LITTLE_ENDIAN | |
536 ASSERT_EQ(Endianness_Little, Toolbox::DetectEndianness()); | 547 ASSERT_EQ(Endianness_Little, Toolbox::DetectEndianness()); |
548 # endif | |
549 | |
550 #else | |
551 #error Support your platform here | |
537 #endif | 552 #endif |
538 } | 553 } |
539 | 554 |
540 | 555 |
541 | 556 |