generated from eigerco/beerus
-
Notifications
You must be signed in to change notification settings - Fork 105
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
<!--- Please provide a general summary of your changes in the title above --> ## Pull Request type <!-- Please try to limit your pull request to one type; submit multiple pull requests if needed. --> Please check the type of change your PR introduces: - [ ] Bugfix - [ ] Feature - [x] Code style update (formatting, renaming) - [ ] Refactoring (no functional changes, no API changes) - [x] Build-related changes - [ ] Documentation content changes - [ ] Other (please describe): ## What is the new behavior? Made some function deprecated. Upgrade the code to 2.7 Fixed all warnings Tried to make some fn generic (didn't look through all of em) Replaced some while pop_front to for loop Updated all assert to assert! and removed their error message as the default one is a good enough default value
- Loading branch information
Showing
117 changed files
with
2,595 additions
and
2,819 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
scarb 2.6.4 | ||
scarb 2.7.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,99 +1,99 @@ | ||
use alexandria_ascii::ToAsciiTrait; | ||
use core::integer::BoundedInt; | ||
use core::num::traits::Bounded; | ||
|
||
#[test] | ||
#[available_gas(2000000000)] | ||
fn u256_to_ascii() { | ||
// ------------------------------ max u256 test ----------------------------- // | ||
// max u256 int in cairo is GitHub Copilot: The maximum u256 number in Cairo is ` | ||
// 115792089237316195423570985008687907853269984665640564039457584007913129639935`. | ||
let num: u256 = BoundedInt::max(); | ||
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 = BoundedInt::min(); | ||
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] | ||
#[available_gas(2000000)] | ||
fn u128_to_ascii() { | ||
// ------------------------------ max u128 test ----------------------------- // | ||
// max u128 int in cairo is 340282366920938463463374607431768211455 | ||
let num: u128 = BoundedInt::max(); | ||
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 = BoundedInt::min(); | ||
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 = BoundedInt::max(); | ||
assert_eq!(num.to_ascii(), '18446744073709551615', "incorrect u64 max felt"); | ||
let num: u64 = Bounded::MAX; | ||
assert_eq!(num.to_ascii(), '18446744073709551615'); | ||
// ------------------------------ min u64 test ------------------------------ // | ||
let num: u64 = BoundedInt::min(); | ||
assert_eq!(num.to_ascii(), '0', "incorrect u64 min felt"); | ||
let num: u64 = Bounded::MIN; | ||
assert_eq!(num.to_ascii(), '0'); | ||
} | ||
|
||
#[test] | ||
#[available_gas(2000000)] | ||
fn u32_to_ascii() { | ||
// ------------------------------ max u32 test ------------------------------ // | ||
let num: u32 = BoundedInt::max(); | ||
assert_eq!(num.to_ascii(), '4294967295', "incorrect u32 max felt"); | ||
let num: u32 = Bounded::MAX; | ||
assert_eq!(num.to_ascii(), '4294967295'); | ||
// ------------------------------ min u32 test ------------------------------ // | ||
let num: u32 = BoundedInt::min(); | ||
assert_eq!(num.to_ascii(), '0', "incorrect u32 min felt"); | ||
let num: u32 = Bounded::MIN; | ||
assert_eq!(num.to_ascii(), '0'); | ||
} | ||
|
||
#[test] | ||
#[available_gas(2000000)] | ||
fn u16_to_ascii() { | ||
// ------------------------------ max u16 test ------------------------------ // | ||
let num: u16 = BoundedInt::max(); | ||
assert_eq!(num.to_ascii(), '65535', "incorrect u16 max felt"); | ||
let num: u16 = Bounded::MAX; | ||
assert_eq!(num.to_ascii(), '65535'); | ||
// ------------------------------ min u16 test ------------------------------ // | ||
let num: u16 = BoundedInt::min(); | ||
assert_eq!(num.to_ascii(), '0', "incorrect u16 min felt"); | ||
let num: u16 = Bounded::MIN; | ||
assert_eq!(num.to_ascii(), '0'); | ||
} | ||
|
||
#[test] | ||
#[available_gas(2000000)] | ||
fn u8_to_ascii() { | ||
// ------------------------------- max u8 test ------------------------------ // | ||
let num: u8 = BoundedInt::max(); | ||
assert_eq!(num.to_ascii(), '255', "incorrect u8 max felt"); | ||
let num: u8 = Bounded::MAX; | ||
assert_eq!(num.to_ascii(), '255'); | ||
// ------------------------------- min u8 test ------------------------------ // | ||
let num: u8 = BoundedInt::min(); | ||
assert_eq!(num.to_ascii(), '0', "incorrect u8 min felt"); | ||
let num: u8 = Bounded::MIN; | ||
assert_eq!(num.to_ascii(), '0'); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.