Skip to content

Commit 1d3de9e

Browse files
authored
add a test for #507 (#508)
* add a test for #507 * CI: test uint on a big-endian platform * a workaround for gmp * grumbles * bump byteorder to 1.4.2
1 parent 24893ac commit 1d3de9e

File tree

4 files changed

+13
-3
lines changed

4 files changed

+13
-3
lines changed

.travis.yml

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ matrix:
1818
- cargo install cross
1919
script:
2020
- cross test --target=aarch64-linux-android -p parity-util-mem
21+
- cross test --target=mips64-unknown-linux-gnuabi64 -p uint
2122
- os: osx
2223
osx_image: xcode11.3
2324
addons:

fixed-hash/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ edition = "2018"
1414
features = ["quickcheck", "api-dummy"]
1515

1616
[dependencies]
17-
byteorder = { version = "1.3.2", optional = true, default-features = false }
17+
byteorder = { version = "1.4.2", optional = true, default-features = false }
1818
quickcheck = { version = "0.9.0", optional = true }
1919
rand = { version = "0.8.0", optional = true, default-features = false }
2020
rustc-hex = { version = "2.0.1", optional = true, default-features = false }

uint/Cargo.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ readme = "README.md"
1010
edition = "2018"
1111

1212
[dependencies]
13-
byteorder = { version = "1.3.2", default-features = false }
13+
byteorder = { version = "1.4.2", default-features = false }
1414
crunchy = { version = "0.2.2", default-features = false }
1515
qc = { package = "quickcheck", version = "0.9.0", optional = true }
1616
rand07 = { package = "rand", version = "0.7", default-features = false, optional = true }
@@ -34,7 +34,7 @@ required-features = ["std"]
3434
criterion = "0.3.0"
3535
num-bigint = "0.3.1"
3636

37-
[target.'cfg(unix)'.dev-dependencies]
37+
[target.'cfg(all(unix, target_arch = "x86_64"))'.dev-dependencies]
3838
rug = { version = "1.6.0", default-features = false, features = ["integer"] }
3939

4040
[[bench]]

uint/tests/uint_tests.rs

+9
Original file line numberDiff line numberDiff line change
@@ -1018,6 +1018,15 @@ fn leading_zeros() {
10181018
assert_eq!(U256::from("0000000000000000000000000000000000000000000000000000000000000000").leading_zeros(), 256);
10191019
}
10201020

1021+
#[test]
1022+
fn issue_507_roundtrip() {
1023+
let mut b32 = <[u8; 32]>::default();
1024+
let a = U256::from(10);
1025+
a.to_little_endian(&mut b32);
1026+
let b = U256::from_little_endian(&b32[..]);
1027+
assert_eq!(a, b);
1028+
}
1029+
10211030
#[test]
10221031
fn trailing_zeros() {
10231032
assert_eq!(U256::from("1adbdd6bd6ff027485484b97f8a6a4c7129756dd100000000000000000000000").trailing_zeros(), 92);

0 commit comments

Comments
 (0)