Skip to content

Commit

Permalink
add a test for #507 (#508)
Browse files Browse the repository at this point in the history
* add a test for #507

* CI: test uint on a big-endian platform

* a workaround for gmp

* grumbles

* bump byteorder to 1.4.2
  • Loading branch information
ordian authored Jan 20, 2021
1 parent 24893ac commit 1d3de9e
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 3 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ matrix:
- cargo install cross
script:
- cross test --target=aarch64-linux-android -p parity-util-mem
- cross test --target=mips64-unknown-linux-gnuabi64 -p uint
- os: osx
osx_image: xcode11.3
addons:
Expand Down
2 changes: 1 addition & 1 deletion fixed-hash/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ edition = "2018"
features = ["quickcheck", "api-dummy"]

[dependencies]
byteorder = { version = "1.3.2", optional = true, default-features = false }
byteorder = { version = "1.4.2", optional = true, default-features = false }
quickcheck = { version = "0.9.0", optional = true }
rand = { version = "0.8.0", optional = true, default-features = false }
rustc-hex = { version = "2.0.1", optional = true, default-features = false }
Expand Down
4 changes: 2 additions & 2 deletions uint/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ readme = "README.md"
edition = "2018"

[dependencies]
byteorder = { version = "1.3.2", default-features = false }
byteorder = { version = "1.4.2", default-features = false }
crunchy = { version = "0.2.2", default-features = false }
qc = { package = "quickcheck", version = "0.9.0", optional = true }
rand07 = { package = "rand", version = "0.7", default-features = false, optional = true }
Expand All @@ -34,7 +34,7 @@ required-features = ["std"]
criterion = "0.3.0"
num-bigint = "0.3.1"

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

[[bench]]
Expand Down
9 changes: 9 additions & 0 deletions uint/tests/uint_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1018,6 +1018,15 @@ fn leading_zeros() {
assert_eq!(U256::from("0000000000000000000000000000000000000000000000000000000000000000").leading_zeros(), 256);
}

#[test]
fn issue_507_roundtrip() {
let mut b32 = <[u8; 32]>::default();
let a = U256::from(10);
a.to_little_endian(&mut b32);
let b = U256::from_little_endian(&b32[..]);
assert_eq!(a, b);
}

#[test]
fn trailing_zeros() {
assert_eq!(U256::from("1adbdd6bd6ff027485484b97f8a6a4c7129756dd100000000000000000000000").trailing_zeros(), 92);
Expand Down

0 comments on commit 1d3de9e

Please sign in to comment.