Repository: BurntSushi/byteorder (language: rust)

Issue:
byteorder test fails on BE architectures
```
failures:
---- stdtests::prop_ext_int_1::native_endian stdout ----
	thread 'stdtests::prop_ext_int_1::native_endian' panicked at '[quickcheck] TEST FAILED. Arguments: (1)', /usr/share/cargo/registry/quickcheck-0.4.1/src/tester.rs:147:27
note: Run with `RUST_BACKTRACE=1` for a backtrace.
---- stdtests::prop_ext_int_2::native_endian stdout ----
	thread 'stdtests::prop_ext_int_2::native_endian' panicked at '[quickcheck] TEST FAILED. Arguments: (1)', /usr/share/cargo/registry/quickcheck-0.4.1/src/tester.rs:147:27
---- stdtests::prop_ext_int_3::native_endian stdout ----
	thread 'stdtests::prop_ext_int_3::native_endian' panicked at '[quickcheck] TEST FAILED. Arguments: (1)', /usr/share/cargo/registry/quickcheck-0.4.1/src/tester.rs:147:27
---- stdtests::prop_ext_int_4::native_endian stdout ----
	thread 'stdtests::prop_ext_int_4::native_endian' panicked at '[quickcheck] TEST FAILED. Arguments: (1)', /usr/share/cargo/registry/quickcheck-0.4.1/src/tester.rs:147:27
---- stdtests::prop_ext_int_5::native_endian stdout ----
	thread 'stdtests::prop_ext_int_5::native_endian' panicked at '[quickcheck] TEST FAILED. Arguments: (1)', /usr/share/cargo/registry/quickcheck-0.4.1/src/tester.rs:147:27
---- stdtests::prop_ext_int_6::native_endian stdout ----
	thread 'stdtests::prop_ext_int_6::native_endian' panicked at '[quickcheck] TEST FAILED. Arguments: (1)', /usr/share/cargo/registry/quickcheck-0.4.1/src/tester.rs:147:27
---- stdtests::prop_ext_int_7::native_endian stdout ----
	thread 'stdtests::prop_ext_int_7::native_endian' panicked at '[quickcheck] TEST FAILED. Arguments: (1)', /usr/share/cargo/registry/quickcheck-0.4.1/src/tester.rs:147:27
---- stdtests::prop_ext_uint_1::native_endian stdout ----
	thread 'stdtests::prop_ext_uint_1::native_endian' panicked at '[quickcheck] TEST FAILED. Arguments: (1)', /usr/share/cargo/registry/quickcheck-0.4.1/src/tester.rs:147:27
---- stdtests::prop_ext_uint_2::native_endian stdout ----
	thread 'stdtests::prop_ext_uint_2::native_endian' panicked at '[quickcheck] TEST FAILED. Arguments: (1)', /usr/share/cargo/registry/quickcheck-0.4.1/src/tester.rs:147:27
---- stdtests::prop_ext_uint_3::native_endian stdout ----
	thread 'stdtests::prop_ext_uint_3::native_endian' panicked at '[quickcheck] TEST FAILED. Arguments: (1)', /usr/share/cargo/registry/quickcheck-0.4.1/src/tester.rs:147:27
---- stdtests::prop_ext_uint_4::native_endian stdout ----
	thread 'stdtests::prop_ext_uint_4::native_endian' panicked at '[quickcheck] TEST FAILED. Arguments: (1)', /usr/share/cargo/registry/quickcheck-0.4.1/src/tester.rs:147:27
---- stdtests::prop_ext_uint_5::native_endian stdout ----
	thread 'stdtests::prop_ext_uint_5::native_endian' panicked at '[quickcheck] TEST FAILED. Arguments: (1)', /usr/share/cargo/registry/quickcheck-0.4.1/src/tester.rs:147:27
---- stdtests::prop_ext_uint_7::native_endian stdout ----
	thread 'stdtests::prop_ext_uint_7::native_endian' panicked at '[quickcheck] TEST FAILED. Arguments: (1)', /usr/share/cargo/registry/quickcheck-0.4.1/src/tester.rs:147:27
---- stdtests::prop_ext_uint_6::native_endian stdout ----
	thread 'stdtests::prop_ext_uint_6::native_endian' panicked at '[quickcheck] TEST FAILED. Arguments: (1)', /usr/share/cargo/registry/quickcheck-0.4.1/src/tester.rs:147:27
failures:
    stdtests::prop_ext_int_1::native_endian
    stdtests::prop_ext_int_2::native_endian
    stdtests::prop_ext_int_3::native_endian
    stdtests::prop_ext_int_4::native_endian
    stdtests::prop_ext_int_5::native_endian
    stdtests::prop_ext_int_6::native_endian
    stdtests::prop_ext_int_7::native_endian
    stdtests::prop_ext_uint_1::native_endian
    stdtests::prop_ext_uint_2::native_endian
    stdtests::prop_ext_uint_3::native_endian
    stdtests::prop_ext_uint_4::native_endian
    stdtests::prop_ext_uint_5::native_endian
    stdtests::prop_ext_uint_6::native_endian
    stdtests::prop_ext_uint_7::native_endian
test result: FAILED. 324 passed; 14 failed; 0 ignored; 0 measured; 0 filtered out
```

This one was from s390x machine.


Discussion / hints:
The [`big_endian` test](https://github.com/BurntSushi/byteorder/blob/master/src/lib.rs#L2863-L2874) creates a new `rdr` vector with just the later bytes, but the following `native_endian` test behaves just like the `little_endian` test -- which is inappropriate on actual big-endian machines.

Fix patch:
diff --git a/src/lib.rs b/src/lib.rs
index b60fe7c..35c0069 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -2865,9 +2865,8 @@ mod stdtests {
                     fn prop(n: $ty_int) -> bool {
                         let mut wtr = vec![];
                         wtr.$write::<BigEndian>(n.clone()).unwrap();
-                        let mut rdr = Vec::new();
-                        rdr.extend(wtr[wtr.len()-$bytes..].iter().map(|&x| x));
-                        let mut rdr = Cursor::new(rdr);
+                        let offset = wtr.len() - $bytes;
+                        let mut rdr = Cursor::new(&mut wtr[offset..]);
                         n == rdr.$read::<BigEndian>($bytes).unwrap()
                     }
                     qc_sized(prop as fn($ty_int) -> bool, $max);
@@ -2889,7 +2888,12 @@ mod stdtests {
                     fn prop(n: $ty_int) -> bool {
                         let mut wtr = vec![];
                         wtr.$write::<NativeEndian>(n.clone()).unwrap();
-                        let mut rdr = Cursor::new(wtr);
+                        let offset = if cfg!(target_endian = "big") {
+                            wtr.len() - $bytes
+                        } else {
+                            0
+                        };
+                        let mut rdr = Cursor::new(&mut wtr[offset..]);
                         n == rdr.$read::<NativeEndian>($bytes).unwrap()
                     }
                     qc_sized(prop as fn($ty_int) -> bool, $max);


Test patch: