Skip to content

Commit

Permalink
Fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
delaaxe committed Jan 31, 2024
1 parent 07f13ab commit f625f61
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/math/src/tests/lcm_of_n_numbers_test.cairo
Original file line number Diff line number Diff line change
@@ -1,45 +1,45 @@
use alexandria_math::lcm_of_n_numbers::{lcm, LCMError};
use core::traits::Into;

// the following trait is not safe, it is only used for testing.
impl u128_to_u32 of Into<u128, u32> {
impl u128_into_u32 of Into<u128, u32> {
fn into(self: u128) -> u32 {
let self: felt252 = self.into();
self.try_into().unwrap()
}
}

#[test]
#[available_gas(1000000000)]
fn lcm_test() {
let arr = array![2_u128, 4_u128, 6_u128, 8_u128, 10_u128];
let arr = array![2_u128, 4, 6, 8, 10];
assert(lcm(arr.span()).unwrap() == 120, 'invalid result');
}

#[test]
#[available_gas(1000000000)]
fn lcm_test_tryinto() {
let arr = array![2_u32, 4_u32, 6_u32, 8_u32, 10_u32];
let arr = array![2_u32, 4, 6, 8, 10];
assert(lcm(arr.span()).unwrap() == 120, 'invalid result');
}

#[test]
#[available_gas(1000000000)]
fn lcm_test_inverse() {
let arr = array![10_u128, 8_u128, 6_u128, 4_u128, 2_u128];
let arr = array![10_u128, 8, 6, 4, 2];
assert(lcm(arr.span()).unwrap() == 120, 'invalid result');
}

#[test]
#[available_gas(1000000000)]
fn lcm_test_3() {
let arr = array![3_u128, 6_u128, 12_u128, 99_u128];
let arr = array![3_u128, 6, 12, 99];
assert(lcm(arr.span()).unwrap() == 396, 'invalid result');
}

#[test]
#[available_gas(1000000000)]
fn lcm_test_4() {
let arr = array![1_u128, 2_u128, 8_u128, 3_u128];
let arr = array![1_u128, 2, 8, 3];
assert(lcm(arr.span()).unwrap() == 24, 'invalid result');
}

Expand Down

0 comments on commit f625f61

Please sign in to comment.