Skip to content

Commit

Permalink
div mod tests (#238)
Browse files Browse the repository at this point in the history
Adds basic tests for div_mod

## 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
- [ ] Code style update (formatting, renaming)
- [x] Refactoring (no functional changes, no API changes)
- [ ] Build-related changes
- [ ] Documentation content changes
- [ ] Other (please describe):

## What is the current behavior?

No div_mod test.

## What is the new behavior?

Basic div_mod test added.

## Does this introduce a breaking change?

- [ ] Yes
- [x] No

<!-- If this does introduce a breaking change, please describe the
impact and migration path for existing applications below. -->

## Other information

For 30 / 10 test,


![image](https://github.com/keep-starknet-strange/alexandria/assets/11048263/efe3e0a5-5a3e-45ca-92fb-7b27cdb6ef7f)
  • Loading branch information
shramee authored Jan 12, 2024
1 parent 085f17c commit 52abb0d
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/math/src/tests/mod_arithmetics_test.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,16 @@ fn mult_mod_2_test() {
assert(mult_mod(pow_256_minus_1, 1, 2) == 1, 'Incorrect result');
}

#[test]
#[available_gas(500000000)]
fn div_mod_test() {
let div_10_30_mod_p =
38597363079105398474523661669562635951089994888546854679819194669304376546633;
assert(div_mod(p, 1, p) == 0, 'Incorrect result');
assert(div_mod(30, 10, p) == 3, 'Incorrect result');
assert(div_mod(10, 30, p) == div_10_30_mod_p, 'Incorrect result');
}

#[test]
#[available_gas(500000000)]
fn pow_mod_test() {
Expand Down

0 comments on commit 52abb0d

Please sign in to comment.