Skip to content

Commit

Permalink
Organize uint new/zero/one tests
Browse files Browse the repository at this point in the history
  • Loading branch information
webmaster128 committed Jun 11, 2022
1 parent 81af6ee commit 83965b2
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 43 deletions.
16 changes: 5 additions & 11 deletions packages/std/src/math/uint128.rs
Original file line number Diff line number Diff line change
Expand Up @@ -509,22 +509,16 @@ mod tests {
use crate::{from_slice, to_vec};

#[test]
fn uint128_one_works() {
let one = Uint128::one();
assert_eq!(
one.to_be_bytes(),
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]
);
}

#[test]
fn uint128_zero_and_one_works() {
fn uint128_zero_works() {
let zero = Uint128::zero();
assert_eq!(
zero.to_be_bytes(),
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,]
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
);
}

#[test]
fn uint128_one_works() {
let one = Uint128::one();
assert_eq!(
one.to_be_bytes(),
Expand Down
21 changes: 6 additions & 15 deletions packages/std/src/math/uint256.rs
Original file line number Diff line number Diff line change
Expand Up @@ -606,19 +606,7 @@ mod tests {
use crate::{from_slice, to_vec};

#[test]
fn uin256_one_works() {
let one = Uint256::one();
assert_eq!(
one.to_be_bytes(),
[
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 1,
]
);
}

#[test]
fn uint256_construct() {
fn uint256_new_works() {
let num = Uint256::new([1; 32]);
let a: [u8; 32] = num.to_be_bytes();
assert_eq!(a, [1; 32]);
Expand All @@ -633,7 +621,7 @@ mod tests {
}

#[test]
fn uint256_zero_and_one_works() {
fn uint256_zero_works() {
let zero = Uint256::zero();
assert_eq!(
zero.to_be_bytes(),
Expand All @@ -642,13 +630,16 @@ mod tests {
0, 0, 0, 0
]
);
}

#[test]
fn uin256_one_works() {
let one = Uint256::one();
assert_eq!(
one.to_be_bytes(),
[
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 1
0, 0, 0, 1,
]
);
}
Expand Down
20 changes: 5 additions & 15 deletions packages/std/src/math/uint512.rs
Original file line number Diff line number Diff line change
Expand Up @@ -567,20 +567,7 @@ mod tests {
use crate::{from_slice, to_vec};

#[test]
fn uin512_one_works() {
let one = Uint512::one();
assert_eq!(
one.to_be_bytes(),
[
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 1
]
);
}

#[test]
fn uint512_construct() {
fn uint512_new_works() {
let num = Uint512::new([1; 64]);
let a: [u8; 64] = num.to_be_bytes();
assert_eq!(a, [1; 64]);
Expand All @@ -597,7 +584,7 @@ mod tests {
}

#[test]
fn uint512_zero_and_one_works() {
fn uint512_zero_works() {
let zero = Uint512::zero();
assert_eq!(
zero.to_be_bytes(),
Expand All @@ -607,7 +594,10 @@ mod tests {
0, 0, 0, 0, 0, 0, 0, 0
]
);
}

#[test]
fn uin512_one_works() {
let one = Uint512::one();
assert_eq!(
one.to_be_bytes(),
Expand Down
7 changes: 5 additions & 2 deletions packages/std/src/math/uint64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -463,10 +463,13 @@ mod tests {
use crate::{from_slice, to_vec};

#[test]
fn uint64_zero_and_one_works() {
fn uint64_zero_works() {
let zero = Uint64::zero();
assert_eq!(zero.to_be_bytes(), [0, 0, 0, 0, 0, 0, 0, 0,]);
assert_eq!(zero.to_be_bytes(), [0, 0, 0, 0, 0, 0, 0, 0]);
}

#[test]
fn uint64_one_works() {
let one = Uint64::one();
assert_eq!(one.to_be_bytes(), [0, 0, 0, 0, 0, 0, 0, 1]);
}
Expand Down

0 comments on commit 83965b2

Please sign in to comment.