Skip to content

Commit

Permalink
update some assert_ea! to remove error message
Browse files Browse the repository at this point in the history
  • Loading branch information
gaetbout committed Aug 5, 2024
1 parent caa630d commit 6eb901b
Show file tree
Hide file tree
Showing 43 changed files with 1,229 additions and 1,229 deletions.
52 changes: 26 additions & 26 deletions packages/ascii/src/tests/test_ascii_integer.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -9,26 +9,26 @@ fn u256_to_ascii() {
// 115792089237316195423570985008687907853269984665640564039457584007913129639935`.
let num: u256 = Bounded::MAX;
let ascii: Array<felt252> = num.to_ascii();
assert_eq!(ascii.len(), 3, "max u256 wrong len");
assert_eq!(*ascii.at(0), '1157920892373161954235709850086', "max u256 wrong first felt");
assert_eq!(*ascii.at(1), '8790785326998466564056403945758', "max u256 wrong second felt");
assert_eq!(*ascii.at(2), '4007913129639935', "max u256 wrong third felt");
assert_eq!(ascii.len(), 3);
assert_eq!(*ascii.at(0), '1157920892373161954235709850086');
assert_eq!(*ascii.at(1), '8790785326998466564056403945758');
assert_eq!(*ascii.at(2), '4007913129639935');
// ------------------------------ min u256 test ----------------------------- //
let num: u256 = Bounded::MIN;
let ascii: Array<felt252> = num.to_ascii();

assert_eq!(ascii.len(), 1, "min u256 wrong len");
assert_eq!(*ascii.at(0), '0', "min u256 wrong felt");
assert_eq!(ascii.len(), 1);
assert_eq!(*ascii.at(0), '0');
// ---------------------------- 31 char u256 test --------------------------- //
let ascii: Array<felt252> = 1157920892373161954235709850086_u256.to_ascii();
assert_eq!(ascii.len(), 1, "u256 31 char wrong len");
assert_eq!(*ascii.at(0), '1157920892373161954235709850086', "31 char u256 wrong felt");
assert_eq!(ascii.len(), 1);
assert_eq!(*ascii.at(0), '1157920892373161954235709850086');
// ---------------------------- 62 char u256 test --------------------------- //
let ascii: Array<felt252> = 11579208923731619542357098500868790785326998466564056403945758_u256
.to_ascii();
assert_eq!(ascii.len(), 2, "u256 31 char wrong len");
assert_eq!(*ascii.at(0), '1157920892373161954235709850086', "31 char u256 wrong felt");
assert_eq!(*ascii.at(1), '8790785326998466564056403945758', "62 char u256 wrong felt");
assert_eq!(ascii.len(), 2);
assert_eq!(*ascii.at(0), '1157920892373161954235709850086');
assert_eq!(*ascii.at(1), '8790785326998466564056403945758');
}

#[test]
Expand All @@ -39,61 +39,61 @@ fn u128_to_ascii() {
let num: u128 = Bounded::MAX;
let ascii: Array<felt252> = num.to_ascii();

assert_eq!(ascii.len(), 2, "max u128 wrong len");
assert_eq!(*ascii.at(0), '3402823669209384634633746074317', "max u128 wrong first felt");
assert_eq!(*ascii.at(1), '68211455', "max u128 wrong second felt");
assert_eq!(ascii.len(), 2);
assert_eq!(*ascii.at(0), '3402823669209384634633746074317');
assert_eq!(*ascii.at(1), '68211455');
// ------------------------------ min u128 test ----------------------------- //
let num: u128 = Bounded::MIN;
let ascii: Array<felt252> = num.to_ascii();

assert_eq!(ascii.len(), 1, "min u128 wrong len");
assert_eq!(*ascii.at(0), '0', "min u128 wrong felt");
assert_eq!(ascii.len(), 1);
assert_eq!(*ascii.at(0), '0');
// ---------------------------- 31 char u128 test --------------------------- //
let ascii: Array<felt252> = 3402823669209384634633746074317_u128.to_ascii();
assert_eq!(ascii.len(), 1, "u128 31 char wrong len");
assert_eq!(*ascii.at(0), '3402823669209384634633746074317', "31 char u128 wrong felt");
assert_eq!(ascii.len(), 1);
assert_eq!(*ascii.at(0), '3402823669209384634633746074317');
}

#[test]
#[available_gas(2000000)]
fn u64_to_ascii() {
// ------------------------------ max u64 test ------------------------------ //
let num: u64 = Bounded::MAX;
assert_eq!(num.to_ascii(), '18446744073709551615', "incorrect u64 max felt");
assert_eq!(num.to_ascii(), '18446744073709551615');
// ------------------------------ min u64 test ------------------------------ //
let num: u64 = Bounded::MIN;
assert_eq!(num.to_ascii(), '0', "incorrect u64 min felt");
assert_eq!(num.to_ascii(), '0');
}

#[test]
#[available_gas(2000000)]
fn u32_to_ascii() {
// ------------------------------ max u32 test ------------------------------ //
let num: u32 = Bounded::MAX;
assert_eq!(num.to_ascii(), '4294967295', "incorrect u32 max felt");
assert_eq!(num.to_ascii(), '4294967295');
// ------------------------------ min u32 test ------------------------------ //
let num: u32 = Bounded::MIN;
assert_eq!(num.to_ascii(), '0', "incorrect u32 min felt");
assert_eq!(num.to_ascii(), '0');
}

#[test]
#[available_gas(2000000)]
fn u16_to_ascii() {
// ------------------------------ max u16 test ------------------------------ //
let num: u16 = Bounded::MAX;
assert_eq!(num.to_ascii(), '65535', "incorrect u16 max felt");
assert_eq!(num.to_ascii(), '65535');
// ------------------------------ min u16 test ------------------------------ //
let num: u16 = Bounded::MIN;
assert_eq!(num.to_ascii(), '0', "incorrect u16 min felt");
assert_eq!(num.to_ascii(), '0');
}

#[test]
#[available_gas(2000000)]
fn u8_to_ascii() {
// ------------------------------- max u8 test ------------------------------ //
let num: u8 = Bounded::MAX;
assert_eq!(num.to_ascii(), '255', "incorrect u8 max felt");
assert_eq!(num.to_ascii(), '255');
// ------------------------------- min u8 test ------------------------------ //
let num: u8 = Bounded::MIN;
assert_eq!(num.to_ascii(), '0', "incorrect u8 min felt");
assert_eq!(num.to_ascii(), '0');
}
Loading

0 comments on commit 6eb901b

Please sign in to comment.