From 52abb0d78f7a8728d0cd7b6e6c7e9836bb6eebf7 Mon Sep 17 00:00:00 2001 From: Shramee Srivastav Date: Fri, 12 Jan 2024 19:18:09 +0530 Subject: [PATCH] div mod tests (#238) Adds basic tests for div_mod ## Pull Request type 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 ## Other information For 30 / 10 test, ![image](https://github.com/keep-starknet-strange/alexandria/assets/11048263/efe3e0a5-5a3e-45ca-92fb-7b27cdb6ef7f) --- src/math/src/tests/mod_arithmetics_test.cairo | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/math/src/tests/mod_arithmetics_test.cairo b/src/math/src/tests/mod_arithmetics_test.cairo index 85eda2be..0bc9e5b9 100644 --- a/src/math/src/tests/mod_arithmetics_test.cairo +++ b/src/math/src/tests/mod_arithmetics_test.cairo @@ -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() {