jamespthomas / googletest

Automatically exported from code.google.com/p/googletest
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

gtest-printers_test fails on big-endian systems #286

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
From user email:

> ---------- Forwarded message ----------
> From: Fredrik Hallenberg <>
> Date: Thu, May 20, 2010 at 8:46 AM
> Subject: Print test fails on big endian architectures
> To: googlemock@googlegroups.com
>
>
> Hi, google-mock is now included in Debian. While building the package I
> discovered that some tests related to
> "UnprintableInFoo" in gmock-printers_test.cc only worked on little endian
> machines.
>
> On Debians configurations of HPPA, PowerPC, S390, Sparc, and MIPS to
> following tests failed::
>
> test/gmock-printers_test.cc:866: Failure
> Value of: Print(::foo::UnprintableInFoo())
>  Actual: "16-byte object <0000 12EF 0000 AB34 0000 0000 0000 0000>"
> Expected: "16-byte object <EF12 0000 34AB 0000 0000 0000 0000 0000>"
>
> ...
>
> test/gmock-printers_test.cc:967: Failure
> Value of: PrintByRef(x)
>  Actual: "@0xfaff0628 16-byte object <0000 12EF 0000 AB34 0000 0000 0000
> 0000>"
> Expected: "@" + PrintPointer(&x) + " 16-byte object " "<EF12 0000 34AB 
0000
> 0000 0000 0000 0000>"
> Which is: "@0xfaff0628 16-byte object <EF12 0000 34AB 0000 0000 0000 0000
> 0000>"
>
>
> I did the following simple patch:
>
> --- google-mock-1.4.0.orig/test/gmock-printers_test.cc
> +++ google-mock-1.4.0/test/gmock-printers_test.cc
> @@ -86,7 +87,8 @@ namespace foo {
>  // A user-defined unprintable type in a user namespace.
>  class UnprintableInFoo {
>   public:
> -  UnprintableInFoo() : x_(0x12EF), y_(0xAB34), z_(0) {}
> +
> +  UnprintableInFoo() : x_(htole32(0x12EF)), y_(htole32(0xAB34)), z_(0) 
{}
>   private:
>    testing::internal::Int32 x_;
>    testing::internal::Int32 y_;
>
> and the package now builds correctly.
>
> I suppose this can be done in a better way by changing the printer thingy
> instead but I have not looked at this in detail.
> If someone can advise on how to do a better fix I can incorporate that in
> the package. Of course, if it is fixed in the
> upstream code that is even better.

Original issue reported on code.google.com by vladlosev on 20 May 2010 at 7:32

GoogleCodeExporter commented 9 years ago
This issue was closed by revision r437.

Original comment by vladlosev on 22 May 2010 at 12:27

GoogleCodeExporter commented 9 years ago
Fixed in revision 437.

Original comment by vladlosev on 22 May 2010 at 12:27