diff --git a/packages/ascii/src/tests/test_ascii_integer.cairo b/packages/ascii/src/tests/test_ascii_integer.cairo index bf5b5a56..9ada074d 100644 --- a/packages/ascii/src/tests/test_ascii_integer.cairo +++ b/packages/ascii/src/tests/test_ascii_integer.cairo @@ -9,26 +9,26 @@ fn u256_to_ascii() { // 115792089237316195423570985008687907853269984665640564039457584007913129639935`. let num: u256 = Bounded::MAX; let ascii: Array = 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 = 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 = 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 = 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] @@ -39,19 +39,19 @@ fn u128_to_ascii() { let num: u128 = Bounded::MAX; let ascii: Array = 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 = 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 = 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] @@ -59,10 +59,10 @@ fn u128_to_ascii() { 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] @@ -70,10 +70,10 @@ fn u64_to_ascii() { 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] @@ -81,10 +81,10 @@ fn u32_to_ascii() { 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] @@ -92,8 +92,8 @@ fn u16_to_ascii() { 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'); } diff --git a/packages/bytes/src/tests/test_bytes.cairo b/packages/bytes/src/tests/test_bytes.cairo index aca7edf9..b7146a5b 100644 --- a/packages/bytes/src/tests/test_bytes.cairo +++ b/packages/bytes/src/tests/test_bytes.cairo @@ -6,19 +6,19 @@ use starknet::ContractAddress; #[available_gas(20000000)] fn test_bytes_zero() { let bytes = BytesTrait::zero(1); - assert_eq!(bytes.size(), 1, "invalid size"); - assert_eq!(*bytes[0], 0, "invalid value"); + assert_eq!(bytes.size(), 1); + assert_eq!(*bytes[0], 0); let bytes = BytesTrait::zero(17); - assert_eq!(bytes.size(), 17, "invalid size"); - assert_eq!(*bytes[0], 0, "invalid value"); - assert_eq!(*bytes[1], 0, "invalid value"); + assert_eq!(bytes.size(), 17); + assert_eq!(*bytes[0], 0); + assert_eq!(*bytes[1], 0); let (_, value) = bytes.read_u8(15); - assert_eq!(value, 0, "invalid value"); + assert_eq!(value, 0); let (_, value) = bytes.read_u8(0); - assert_eq!(value, 0, "invalid value"); + assert_eq!(value, 0); let (_, value) = bytes.read_u8(16); - assert_eq!(value, 0, "invalid value"); + assert_eq!(value, 0); } #[test] @@ -35,24 +35,24 @@ fn test_bytes_update() { let mut bytes = BytesTrait::new(5, array![0x01020304050000000000000000000000]); bytes.update_at(0, 0x05); - assert_eq!(bytes.size(), 5, "update_size1"); - assert_eq!(*bytes[0], 0x05020304050000000000000000000000, "update_value_1"); + assert_eq!(bytes.size(), 5); + assert_eq!(*bytes[0], 0x05020304050000000000000000000000); bytes.update_at(1, 0x06); - assert_eq!(bytes.size(), 5, "update_size2"); - assert_eq!(*bytes[0], 0x05060304050000000000000000000000, "update_value_2"); + assert_eq!(bytes.size(), 5); + assert_eq!(*bytes[0], 0x05060304050000000000000000000000); bytes.update_at(2, 0x07); - assert_eq!(bytes.size(), 5, "update_size3"); - assert_eq!(*bytes[0], 0x05060704050000000000000000000000, "update_value_3"); + assert_eq!(bytes.size(), 5); + assert_eq!(*bytes[0], 0x05060704050000000000000000000000); bytes.update_at(3, 0x08); - assert_eq!(bytes.size(), 5, "update_size4"); - assert_eq!(*bytes[0], 0x05060708050000000000000000000000, "update_value_4"); + assert_eq!(bytes.size(), 5); + assert_eq!(*bytes[0], 0x05060708050000000000000000000000); bytes.update_at(4, 0x09); - assert_eq!(bytes.size(), 5, "update_size5"); - assert_eq!(*bytes[0], 0x05060708090000000000000000000000, "update_value_5"); + assert_eq!(bytes.size(), 5); + assert_eq!(*bytes[0], 0x05060708090000000000000000000000); let mut bytes = BytesTrait::new( 42, @@ -64,16 +64,16 @@ fn test_bytes_update() { ); bytes.update_at(16, 0x16); - assert_eq!(bytes.size(), 42, "update_size6"); - assert_eq!(*bytes[0], 0x01020304050607080910111213141516, "update_value_6"); - assert_eq!(*bytes[1], 0x16020304050607080910111213141516, "update_value_7"); - assert_eq!(*bytes[2], 0x01020304050607080910000000000000, "update_value_8"); + assert_eq!(bytes.size(), 42); + assert_eq!(*bytes[0], 0x01020304050607080910111213141516); + assert_eq!(*bytes[1], 0x16020304050607080910111213141516); + assert_eq!(*bytes[2], 0x01020304050607080910000000000000); bytes.update_at(15, 0x01); - assert_eq!(bytes.size(), 42, "update_size7"); - assert_eq!(*bytes[0], 0x01020304050607080910111213141501, "update_value_9"); - assert_eq!(*bytes[1], 0x16020304050607080910111213141516, "update_value_10"); - assert_eq!(*bytes[2], 0x01020304050607080910000000000000, "update_value_11"); + assert_eq!(bytes.size(), 42); + assert_eq!(*bytes[0], 0x01020304050607080910111213141501); + assert_eq!(*bytes[1], 0x16020304050607080910111213141516); + assert_eq!(*bytes[2], 0x01020304050607080910000000000000); } #[test] @@ -88,24 +88,24 @@ fn test_bytes_read_u128_packed() { let bytes = BytesTrait::new(42, array); let (new_offset, value) = bytes.read_u128_packed(0, 1); - assert_eq!(new_offset, 1, "read_u128_packed_1_offset"); - assert_eq!(value, 0x01, "read_u128_packed_1_value"); + assert_eq!(new_offset, 1); + assert_eq!(value, 0x01); let (new_offset, value) = bytes.read_u128_packed(new_offset, 14); - assert_eq!(new_offset, 15, "read_u128_packed_2_offset"); - assert_eq!(value, 0x0203040506070809101112131415, "read_u128_packed_2_value"); + assert_eq!(new_offset, 15); + assert_eq!(value, 0x0203040506070809101112131415); let (new_offset, value) = bytes.read_u128_packed(new_offset, 15); - assert_eq!(new_offset, 30, "read_u128_packed_3_offset"); - assert_eq!(value, 0x160102030405060708091011121314, "read_u128_packed_3_value"); + assert_eq!(new_offset, 30); + assert_eq!(value, 0x160102030405060708091011121314); let (new_offset, value) = bytes.read_u128_packed(new_offset, 8); - assert_eq!(new_offset, 38, "read_u128_packed_4_offset"); - assert_eq!(value, 0x1516010203040506, "read_u128_packed_4_value"); + assert_eq!(new_offset, 38); + assert_eq!(value, 0x1516010203040506); let (new_offset, value) = bytes.read_u128_packed(new_offset, 4); - assert_eq!(new_offset, 42, "read_u128_packed_5_offset"); - assert_eq!(value, 0x07080910, "read_u128_packed_5_value"); + assert_eq!(new_offset, 42); + assert_eq!(value, 0x07080910); } #[test] @@ -150,17 +150,17 @@ fn test_bytes_read_u128_array_packed() { let bytes = BytesTrait::new(42, array); let (new_offset, new_array) = bytes.read_u128_array_packed(0, 3, 3); - assert_eq!(new_offset, 9, "read_u128_array_1_offset"); - assert_eq!(*new_array[0], 0x010203, "read_u128_array_1_value_1"); - assert_eq!(*new_array[1], 0x040506, "read_u128_array_1_value_2"); - assert_eq!(*new_array[2], 0x070809, "read_u128_array_1_value_3"); + assert_eq!(new_offset, 9); + assert_eq!(*new_array[0], 0x010203); + assert_eq!(*new_array[1], 0x040506); + assert_eq!(*new_array[2], 0x070809); let (new_offset, new_array) = bytes.read_u128_array_packed(9, 4, 7); - assert_eq!(new_offset, 37, "read_u128_array_2_offset"); - assert_eq!(*new_array[0], 0x10111213141516, "read_u128_array_2_value_1"); - assert_eq!(*new_array[1], 0x01020304050607, "read_u128_array_2_value_2"); - assert_eq!(*new_array[2], 0x08091011121314, "read_u128_array_2_value_3"); - assert_eq!(*new_array[3], 0x15160102030405, "read_u128_array_2_value_4"); + assert_eq!(new_offset, 37); + assert_eq!(*new_array[0], 0x10111213141516); + assert_eq!(*new_array[1], 0x01020304050607); + assert_eq!(*new_array[2], 0x08091011121314); + assert_eq!(*new_array[3], 0x15160102030405); } #[test] @@ -205,8 +205,8 @@ fn test_bytes_read_felt252_packed() { let bytes = BytesTrait::new(42, array); let (new_offset, value) = bytes.read_felt252_packed(13, 20); - assert_eq!(new_offset, 33, "read_felt252_1_offset"); - assert_eq!(value, 0x1415160102030405060708091011121314151601, "read_felt252_1_value"); + assert_eq!(new_offset, 33); + assert_eq!(value, 0x1415160102030405060708091011121314151601); } #[test] @@ -251,8 +251,8 @@ fn test_bytes_read_u8() { let bytes = BytesTrait::new(42, array); let (new_offset, value) = bytes.read_u8(15); - assert_eq!(new_offset, 16, "read_u8_offset"); - assert_eq!(value, 0x16, "read_u8_value"); + assert_eq!(new_offset, 16); + assert_eq!(value, 0x16); } #[test] @@ -267,8 +267,8 @@ fn test_bytes_read_u16() { let bytes = BytesTrait::new(42, array); let (new_offset, value) = bytes.read_u16(15); - assert_eq!(new_offset, 17, "read_u16_offset"); - assert_eq!(value, 0x1601, "read_u16_value"); + assert_eq!(new_offset, 17); + assert_eq!(value, 0x1601); } #[test] @@ -283,8 +283,8 @@ fn test_bytes_read_u32() { let bytes = BytesTrait::new(42, array); let (new_offset, value) = bytes.read_u32(15); - assert_eq!(new_offset, 19, "read_u32_offset"); - assert_eq!(value, 0x16010203, "read_u32_value"); + assert_eq!(new_offset, 19); + assert_eq!(value, 0x16010203); } #[test] @@ -299,8 +299,8 @@ fn test_bytes_read_usize() { let bytes = BytesTrait::new(42, array); let (new_offset, value) = bytes.read_usize(15); - assert_eq!(new_offset, 19, "read_usize_offset"); - assert_eq!(value, 0x16010203, "read_usize_value"); + assert_eq!(new_offset, 19); + assert_eq!(value, 0x16010203); } #[test] @@ -315,8 +315,8 @@ fn test_bytes_read_u64() { let bytes = BytesTrait::new(42, array); let (new_offset, value) = bytes.read_u64(15); - assert_eq!(new_offset, 23, "read_u64_offset"); - assert_eq!(value, 0x1601020304050607, "read_u64_value"); + assert_eq!(new_offset, 23); + assert_eq!(value, 0x1601020304050607); } #[test] @@ -331,8 +331,8 @@ fn test_bytes_read_u128() { let bytes = BytesTrait::new(42, array); let (new_offset, value) = bytes.read_u128(15); - assert_eq!(new_offset, 31, "read_u128_offset"); - assert_eq!(value, 0x16010203040506070809101112131415, "read_u128_value"); + assert_eq!(new_offset, 31); + assert_eq!(value, 0x16010203040506070809101112131415); } #[test] @@ -347,9 +347,9 @@ fn test_bytes_read_u256() { let bytes = BytesTrait::new(42, array); let (new_offset, value) = bytes.read_u256(4); - assert_eq!(new_offset, 36, "read_u256_1_offset"); - assert_eq!(value.high, 0x05060708091011121314151601020304, "read_u256_1_value_high"); - assert_eq!(value.low, 0x05060708091011121314151601020304, "read_u256_1_value_low"); + assert_eq!(new_offset, 36); + assert_eq!(value.high, 0x05060708091011121314151601020304); + assert_eq!(value.low, 0x05060708091011121314151601020304); } #[test] @@ -359,7 +359,7 @@ fn test_bytes_read_bytes31() { 31, array![0x0102030405060708090a0b0c0d0e0f10, 0x1112131415161718191a1b1c1d1e1f00] ); let (offset, val) = bytes.read_bytes31(0); - assert_eq!(offset, 31, "Offset after read_bytes31 failed"); + assert_eq!(offset, 31); let byte31: bytes31 = 0x0102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f .try_into() .unwrap(); @@ -381,13 +381,13 @@ fn test_bytes_read_u256_array() { let bytes = BytesTrait::new(88, array); let (new_offset, new_array) = bytes.read_u256_array(7, 2); - assert_eq!(new_offset, 71, "read_u256_array_offset"); + assert_eq!(new_offset, 71); let result: u256 = *new_array[0]; - assert_eq!(result.high, 0x08091011121314151616151413121110, "read_256_array_value_1_high"); - assert_eq!(result.low, 0x09080706050403020116151413121110, "read_256_array_value_1_low"); + assert_eq!(result.high, 0x08091011121314151616151413121110); + assert_eq!(result.low, 0x09080706050403020116151413121110); let result: u256 = *new_array[1]; - assert_eq!(result.high, 0x09080706050403020101020304050607, "read_256_array_value_2_high"); - assert_eq!(result.low, 0x08091011121314151601020304050607, "read_256_array_value_2_low"); + assert_eq!(result.high, 0x09080706050403020101020304050607); + assert_eq!(result.low, 0x08091011121314151601020304050607); } #[test] @@ -403,8 +403,8 @@ fn test_bytes_read_address() { let address = 0x015401855d7796176b05d160196ff92381eb7910f5446c2e0e04e13db2194a4f; let (new_offset, value) = bytes.read_address(14); - assert_eq!(new_offset, 46, "read_address_offset"); - assert_eq!(value.into(), address, "read_address_value"); + assert_eq!(new_offset, 46); + assert_eq!(value.into(), address); } #[test] @@ -420,31 +420,31 @@ fn test_bytes_read_bytes() { let (new_offset, sub_bytes) = bytes.read_bytes(4, 37); let sub_bytes_data = @sub_bytes; - assert_eq!(new_offset, 41, "read_bytes_offset"); - assert_eq!(sub_bytes.size(), 37, "read_bytes_size"); - assert_eq!(*sub_bytes_data[0], 0x05060708091011121314015401855d77, "read_bytes_value_1"); - assert_eq!(*sub_bytes_data[1], 0x96176b05d160196ff92381eb7910f544, "read_bytes_value_2"); - assert_eq!(*sub_bytes_data[2], 0x6c2e0e04e10000000000000000000000, "read_bytes_value_3"); + assert_eq!(new_offset, 41); + assert_eq!(sub_bytes.size(), 37); + assert_eq!(*sub_bytes_data[0], 0x05060708091011121314015401855d77); + assert_eq!(*sub_bytes_data[1], 0x96176b05d160196ff92381eb7910f544); + assert_eq!(*sub_bytes_data[2], 0x6c2e0e04e10000000000000000000000); let (new_offset, sub_bytes) = bytes.read_bytes(0, 14); let sub_bytes_data = @sub_bytes; - assert_eq!(new_offset, 14, "read_bytes_offset"); - assert_eq!(sub_bytes.size(), 14, "read_bytes_size"); - assert_eq!(*sub_bytes_data[0], 0x01020304050607080910111213140000, "read_bytes_value_4"); + assert_eq!(new_offset, 14); + assert_eq!(sub_bytes.size(), 14); + assert_eq!(*sub_bytes_data[0], 0x01020304050607080910111213140000); // read first byte let (new_offset, sub_bytes) = bytes.read_bytes(0, 1); let sub_bytes_data = @sub_bytes; - assert_eq!(new_offset, 1, "read_bytes_offset"); - assert_eq!(sub_bytes.size(), 1, "read_bytes_size"); - assert_eq!(*sub_bytes_data[0], 0x01000000000000000000000000000000, "read_bytes_value_5"); + assert_eq!(new_offset, 1); + assert_eq!(sub_bytes.size(), 1); + assert_eq!(*sub_bytes_data[0], 0x01000000000000000000000000000000); // read last byte let (new_offset, sub_bytes) = bytes.read_bytes(45, 1); let sub_bytes_data = @sub_bytes; - assert_eq!(new_offset, 46, "read_bytes_offset"); - assert_eq!(sub_bytes.size(), 1, "read_bytes_size"); - assert_eq!(*sub_bytes_data[0], 0x4f000000000000000000000000000000, "read_bytes_value_6"); + assert_eq!(new_offset, 46); + assert_eq!(sub_bytes.size(), 1); + assert_eq!(*sub_bytes_data[0], 0x4f000000000000000000000000000000); } #[test] @@ -454,70 +454,70 @@ fn test_bytes_append() { // append_u128_packed bytes.append_u128_packed(0x101112131415161718, 9); - assert_eq!(bytes.size(), 9, "append_u128_packed_1_size"); - assert_eq!(*bytes[0], 0x10111213141516171800000000000000, "append_u128_packed_1_value_1"); + assert_eq!(bytes.size(), 9); + assert_eq!(*bytes[0], 0x10111213141516171800000000000000); bytes = BytesTrait::new(bytes.size(), bytes.data()); bytes.append_u128_packed(0x101112131415161718, 9); - assert_eq!(bytes.size(), 18, "append_u128_packed_2_size"); - assert_eq!(*bytes[0], 0x10111213141516171810111213141516, "append_u128_packed_2_value_1"); - assert_eq!(*bytes[1], 0x17180000000000000000000000000000, "append_u128_packed_2_value_2"); + assert_eq!(bytes.size(), 18); + assert_eq!(*bytes[0], 0x10111213141516171810111213141516); + assert_eq!(*bytes[1], 0x17180000000000000000000000000000); bytes = BytesTrait::new(bytes.size(), bytes.data()); // append_u8 bytes.append_u8(0x01); - assert_eq!(bytes.size(), 19, "append_u8_size"); - assert_eq!(*bytes[0], 0x10111213141516171810111213141516, "append_u8_value_1"); - assert_eq!(*bytes[1], 0x17180100000000000000000000000000, "append_u8_value_2"); + assert_eq!(bytes.size(), 19); + assert_eq!(*bytes[0], 0x10111213141516171810111213141516); + assert_eq!(*bytes[1], 0x17180100000000000000000000000000); bytes = BytesTrait::new(bytes.size(), bytes.data()); // append_u16 bytes.append_u16(0x0102); - assert_eq!(bytes.size(), 21, "append_u16_size"); - assert_eq!(*bytes[0], 0x10111213141516171810111213141516, "append_u16_value_1"); - assert_eq!(*bytes[1], 0x17180101020000000000000000000000, "append_u16_value_2"); + assert_eq!(bytes.size(), 21); + assert_eq!(*bytes[0], 0x10111213141516171810111213141516); + assert_eq!(*bytes[1], 0x17180101020000000000000000000000); bytes = BytesTrait::new(bytes.size(), bytes.data()); // append_u32 bytes.append_u32(0x01020304); - assert_eq!(bytes.size(), 25, "append_u32_size"); - assert_eq!(*bytes[0], 0x10111213141516171810111213141516, "append_u32_value_1"); - assert_eq!(*bytes[1], 0x17180101020102030400000000000000, "append_u32_value_2"); + assert_eq!(bytes.size(), 25); + assert_eq!(*bytes[0], 0x10111213141516171810111213141516); + assert_eq!(*bytes[1], 0x17180101020102030400000000000000); bytes = BytesTrait::new(bytes.size(), bytes.data()); // append_usize bytes.append_usize(0x01); - assert_eq!(bytes.size(), 29, "append_usize_size"); - assert_eq!(*bytes[0], 0x10111213141516171810111213141516, "append_usize_value_1"); - assert_eq!(*bytes[1], 0x17180101020102030400000001000000, "append_usize_value_2"); + assert_eq!(bytes.size(), 29); + assert_eq!(*bytes[0], 0x10111213141516171810111213141516); + assert_eq!(*bytes[1], 0x17180101020102030400000001000000); bytes = BytesTrait::new(bytes.size(), bytes.data()); // append_u64 bytes.append_u64(0x030405060708); - assert_eq!(bytes.size(), 37, "append_u64_size"); - assert_eq!(*bytes[0], 0x10111213141516171810111213141516, "append_u64_value_1"); - assert_eq!(*bytes[1], 0x17180101020102030400000001000003, "append_u64_value_2"); - assert_eq!(*bytes[2], 0x04050607080000000000000000000000, "append_u64_value_3"); + assert_eq!(bytes.size(), 37); + assert_eq!(*bytes[0], 0x10111213141516171810111213141516); + assert_eq!(*bytes[1], 0x17180101020102030400000001000003); + assert_eq!(*bytes[2], 0x04050607080000000000000000000000); bytes = BytesTrait::new(bytes.size(), bytes.data()); // append_u128 bytes.append_u128(0x101112131415161718); - assert_eq!(bytes.size(), 53, "append_u128_size"); - assert_eq!(*bytes[0], 0x10111213141516171810111213141516, "append_u128_value_1"); - assert_eq!(*bytes[1], 0x17180101020102030400000001000003, "append_u128_value_2"); - assert_eq!(*bytes[2], 0x04050607080000000000000010111213, "append_u128_value_3"); - assert_eq!(*bytes[3], 0x14151617180000000000000000000000, "append_u128_value_4"); + assert_eq!(bytes.size(), 53); + assert_eq!(*bytes[0], 0x10111213141516171810111213141516); + assert_eq!(*bytes[1], 0x17180101020102030400000001000003); + assert_eq!(*bytes[2], 0x04050607080000000000000010111213); + assert_eq!(*bytes[3], 0x14151617180000000000000000000000); bytes = BytesTrait::new(bytes.size(), bytes.data()); // append_u256 bytes.append_u256(u256 { low: 0x01020304050607, high: 0x010203040506070809 }); - assert_eq!(bytes.size(), 85, "append_u256_size"); - assert_eq!(*bytes[0], 0x10111213141516171810111213141516, "append_u256_value_1"); - assert_eq!(*bytes[1], 0x17180101020102030400000001000003, "append_u256_value_2"); - assert_eq!(*bytes[2], 0x04050607080000000000000010111213, "append_u256_value_3"); - assert_eq!(*bytes[3], 0x14151617180000000000000001020304, "append_u256_value_4"); - assert_eq!(*bytes[4], 0x05060708090000000000000000000102, "append_u256_value_5"); - assert_eq!(*bytes[5], 0x03040506070000000000000000000000, "append_u256_value_6"); + assert_eq!(bytes.size(), 85); + assert_eq!(*bytes[0], 0x10111213141516171810111213141516); + assert_eq!(*bytes[1], 0x17180101020102030400000001000003); + assert_eq!(*bytes[2], 0x04050607080000000000000010111213); + assert_eq!(*bytes[3], 0x14151617180000000000000001020304); + assert_eq!(*bytes[4], 0x05060708090000000000000000000102); + assert_eq!(*bytes[5], 0x03040506070000000000000000000000); bytes = BytesTrait::new(bytes.size(), bytes.data()); // append_address @@ -525,15 +525,15 @@ fn test_bytes_append() { .try_into() .unwrap(); bytes.append_address(address); - assert_eq!(bytes.size(), 117, "append_address_size"); - assert_eq!(*bytes[0], 0x10111213141516171810111213141516, "append_address_value_1"); - assert_eq!(*bytes[1], 0x17180101020102030400000001000003, "append_address_value_2"); - assert_eq!(*bytes[2], 0x04050607080000000000000010111213, "append_address_value_3"); - assert_eq!(*bytes[3], 0x14151617180000000000000001020304, "append_address_value_4"); - assert_eq!(*bytes[4], 0x05060708090000000000000000000102, "append_address_value_5"); - assert_eq!(*bytes[5], 0x0304050607015401855d7796176b05d1, "append_address_value_6"); - assert_eq!(*bytes[6], 0x60196ff92381eb7910f5446c2e0e04e1, "append_address_value_7"); - assert_eq!(*bytes[7], 0x3db2194a4f0000000000000000000000, "append_address_value_8"); + assert_eq!(bytes.size(), 117); + assert_eq!(*bytes[0], 0x10111213141516171810111213141516); + assert_eq!(*bytes[1], 0x17180101020102030400000001000003); + assert_eq!(*bytes[2], 0x04050607080000000000000010111213); + assert_eq!(*bytes[3], 0x14151617180000000000000001020304); + assert_eq!(*bytes[4], 0x05060708090000000000000000000102); + assert_eq!(*bytes[5], 0x0304050607015401855d7796176b05d1); + assert_eq!(*bytes[6], 0x60196ff92381eb7910f5446c2e0e04e1); + assert_eq!(*bytes[7], 0x3db2194a4f0000000000000000000000); } #[test] @@ -559,53 +559,53 @@ fn test_bytes_concat() { let other = BytesTrait::new(46, array); bytes.concat(@other); - assert_eq!(bytes.size(), 163, "concat_size"); - assert_eq!(*bytes[0], 0x10111213141516171810111213141516, "concat_value_1"); - assert_eq!(*bytes[1], 0x17180101020102030400000001000003, "concat_value_2"); - assert_eq!(*bytes[2], 0x04050607080000000000000010111213, "concat_value_3"); - assert_eq!(*bytes[3], 0x14151617180000000000000001020304, "concat_value_4"); - assert_eq!(*bytes[4], 0x05060708090000000000000000000102, "concat_value_5"); - assert_eq!(*bytes[5], 0x0304050607015401855d7796176b05d1, "concat_value_6"); - assert_eq!(*bytes[6], 0x60196ff92381eb7910f5446c2e0e04e1, "concat_value_7"); - assert_eq!(*bytes[7], 0x3db2194a4f0102030405060708091011, "concat_value_8"); - assert_eq!(*bytes[8], 0x121314015401855d7796176b05d16019, "concat_value_9"); - assert_eq!(*bytes[9], 0x6ff92381eb7910f5446c2e0e04e13db2, "concat_value_10"); - assert_eq!(*bytes[10], 0x194a4f00000000000000000000000000, "concat_value_11"); + assert_eq!(bytes.size(), 163); + assert_eq!(*bytes[0], 0x10111213141516171810111213141516); + assert_eq!(*bytes[1], 0x17180101020102030400000001000003); + assert_eq!(*bytes[2], 0x04050607080000000000000010111213); + assert_eq!(*bytes[3], 0x14151617180000000000000001020304); + assert_eq!(*bytes[4], 0x05060708090000000000000000000102); + assert_eq!(*bytes[5], 0x0304050607015401855d7796176b05d1); + assert_eq!(*bytes[6], 0x60196ff92381eb7910f5446c2e0e04e1); + assert_eq!(*bytes[7], 0x3db2194a4f0102030405060708091011); + assert_eq!(*bytes[8], 0x121314015401855d7796176b05d16019); + assert_eq!(*bytes[9], 0x6ff92381eb7910f5446c2e0e04e13db2); + assert_eq!(*bytes[10], 0x194a4f00000000000000000000000000); bytes = BytesTrait::new(bytes.size(), bytes.data()); // empty bytes concat let mut empty_bytes = BytesTrait::new_empty(); empty_bytes.concat(@bytes); - assert_eq!(bytes.size(), 163, "concat_size"); - assert_eq!(*bytes[0], 0x10111213141516171810111213141516, "concat_value_1"); - assert_eq!(*bytes[1], 0x17180101020102030400000001000003, "concat_value_2"); - assert_eq!(*bytes[2], 0x04050607080000000000000010111213, "concat_value_3"); - assert_eq!(*bytes[3], 0x14151617180000000000000001020304, "concat_value_4"); - assert_eq!(*bytes[4], 0x05060708090000000000000000000102, "concat_value_5"); - assert_eq!(*bytes[5], 0x0304050607015401855d7796176b05d1, "concat_value_6"); - assert_eq!(*bytes[6], 0x60196ff92381eb7910f5446c2e0e04e1, "concat_value_7"); - assert_eq!(*bytes[7], 0x3db2194a4f0102030405060708091011, "concat_value_8"); - assert_eq!(*bytes[8], 0x121314015401855d7796176b05d16019, "concat_value_9"); - assert_eq!(*bytes[9], 0x6ff92381eb7910f5446c2e0e04e13db2, "concat_value_10"); - assert_eq!(*bytes[10], 0x194a4f00000000000000000000000000, "concat_value_11"); + assert_eq!(bytes.size(), 163); + assert_eq!(*bytes[0], 0x10111213141516171810111213141516); + assert_eq!(*bytes[1], 0x17180101020102030400000001000003); + assert_eq!(*bytes[2], 0x04050607080000000000000010111213); + assert_eq!(*bytes[3], 0x14151617180000000000000001020304); + assert_eq!(*bytes[4], 0x05060708090000000000000000000102); + assert_eq!(*bytes[5], 0x0304050607015401855d7796176b05d1); + assert_eq!(*bytes[6], 0x60196ff92381eb7910f5446c2e0e04e1); + assert_eq!(*bytes[7], 0x3db2194a4f0102030405060708091011); + assert_eq!(*bytes[8], 0x121314015401855d7796176b05d16019); + assert_eq!(*bytes[9], 0x6ff92381eb7910f5446c2e0e04e13db2); + assert_eq!(*bytes[10], 0x194a4f00000000000000000000000000); // concat empty_bytes let empty_bytes = BytesTrait::new_empty(); bytes.concat(@empty_bytes); - assert_eq!(bytes.size(), 163, "concat_size"); - assert_eq!(*bytes[0], 0x10111213141516171810111213141516, "concat_value_1"); - assert_eq!(*bytes[1], 0x17180101020102030400000001000003, "concat_value_2"); - assert_eq!(*bytes[2], 0x04050607080000000000000010111213, "concat_value_3"); - assert_eq!(*bytes[3], 0x14151617180000000000000001020304, "concat_value_4"); - assert_eq!(*bytes[4], 0x05060708090000000000000000000102, "concat_value_5"); - assert_eq!(*bytes[5], 0x0304050607015401855d7796176b05d1, "concat_value_6"); - assert_eq!(*bytes[6], 0x60196ff92381eb7910f5446c2e0e04e1, "concat_value_7"); - assert_eq!(*bytes[7], 0x3db2194a4f0102030405060708091011, "concat_value_8"); - assert_eq!(*bytes[8], 0x121314015401855d7796176b05d16019, "concat_value_9"); - assert_eq!(*bytes[9], 0x6ff92381eb7910f5446c2e0e04e13db2, "concat_value_10"); - assert_eq!(*bytes[10], 0x194a4f00000000000000000000000000, "concat_value_11"); + assert_eq!(bytes.size(), 163); + assert_eq!(*bytes[0], 0x10111213141516171810111213141516); + assert_eq!(*bytes[1], 0x17180101020102030400000001000003); + assert_eq!(*bytes[2], 0x04050607080000000000000010111213); + assert_eq!(*bytes[3], 0x14151617180000000000000001020304); + assert_eq!(*bytes[4], 0x05060708090000000000000000000102); + assert_eq!(*bytes[5], 0x0304050607015401855d7796176b05d1); + assert_eq!(*bytes[6], 0x60196ff92381eb7910f5446c2e0e04e1); + assert_eq!(*bytes[7], 0x3db2194a4f0102030405060708091011); + assert_eq!(*bytes[8], 0x121314015401855d7796176b05d16019); + assert_eq!(*bytes[9], 0x6ff92381eb7910f5446c2e0e04e13db2); + assert_eq!(*bytes[10], 0x194a4f00000000000000000000000000); } #[test] @@ -621,7 +621,7 @@ fn test_bytes_keccak() { let bytes = BytesTrait::new_empty(); let hash: u256 = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470; let res = bytes.keccak(); - assert_eq!(res, hash, "bytes_keccak_0"); + assert_eq!(res, hash); // u256{low: 1, high: 0} let mut array = array![]; @@ -630,7 +630,7 @@ fn test_bytes_keccak() { let bytes: Bytes = BytesTrait::new(32, array); let res = bytes.keccak(); let hash: u256 = 0xb10e2d527612073b26eecdfd717e6a320cf44b4afac2b0732d9fcbe2b7fa0cf6; - assert_eq!(res, hash, "bytes_keccak_1"); + assert_eq!(res, hash); // test_bytes_append bytes let mut array = array![]; @@ -647,7 +647,7 @@ fn test_bytes_keccak() { let hash: u256 = 0xcb1bcb5098bb2f588b82ea341e3b1148b7d1eeea2552d624b30f4240b5b85995; let res = bytes.keccak(); - assert_eq!(res, hash, "bytes_keccak_2"); + assert_eq!(res, hash); } #[test] @@ -657,7 +657,7 @@ fn test_bytes_sha256() { let bytes = BytesTrait::new_empty(); let hash: u256 = 0xe3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855; let res = bytes.sha256(); - assert_eq!(res, hash, "bytes_sha256_0"); + assert_eq!(res, hash); // u256{low: 1, high: 0} // 0x0000000000000000000000000000000000000000000000000000000000000001 @@ -665,7 +665,7 @@ fn test_bytes_sha256() { let bytes: Bytes = BytesTrait::new(32, array); let res = bytes.sha256(); let hash: u256 = 0xec4916dd28fc4c10d78e287ca5d9cc51ee1ae73cbfde08c6b37324cbfaac8bc5; - assert_eq!(res, hash, "bytes_sha256_1"); + assert_eq!(res, hash); // test_bytes_append bytes let array = array![ @@ -683,7 +683,7 @@ fn test_bytes_sha256() { let hash: u256 = 0xc3ab2c0ce2c246454f265f531ab14f210215ce72b91c23338405c273dc14ce1d; let res = bytes.sha256(); - assert_eq!(res, hash, "bytes_sha256_2"); + assert_eq!(res, hash); } #[test] @@ -699,5 +699,5 @@ fn test_byte_array_conversions() { ); let byte_array: ByteArray = bytes.clone().into(); let new_bytes: Bytes = byte_array.into(); - assert_eq!(bytes, new_bytes, "byte <-> byte_array conversion failed"); + assert_eq!(bytes, new_bytes); } diff --git a/packages/bytes/src/tests/test_bytes_store.cairo b/packages/bytes/src/tests/test_bytes_store.cairo index fa40c9ef..b4eca5c6 100644 --- a/packages/bytes/src/tests/test_bytes_store.cairo +++ b/packages/bytes/src/tests/test_bytes_store.cairo @@ -45,7 +45,7 @@ mod tests { #[test] fn test_deploy() { let contract = deploy(); - assert_eq!(contract.get_bytes(), BytesTrait::new_empty(), "Initial bytes should be empty"); + assert_eq!(contract.get_bytes(), BytesTrait::new_empty()); } #[test] @@ -53,7 +53,7 @@ mod tests { let contract = deploy(); let bytes = BytesTrait::new(32, array![0x01020304050607080910, 0x11121314151617181920]); contract.set_bytes(bytes.clone()); - assert_eq!(contract.get_bytes(), bytes, "Bytes should be set correctly"); + assert_eq!(contract.get_bytes(), bytes); } #[test] @@ -66,6 +66,6 @@ mod tests { ] ); contract.set_bytes(bytes.clone()); - assert_eq!(contract.get_bytes(), bytes, "Bytes should be set correctly"); + assert_eq!(contract.get_bytes(), bytes); } } diff --git a/packages/data_structures/src/tests/byte_appender.cairo b/packages/data_structures/src/tests/byte_appender.cairo index 0ed859fd..fb70058b 100644 --- a/packages/data_structures/src/tests/byte_appender.cairo +++ b/packages/data_structures/src/tests/byte_appender.cairo @@ -13,7 +13,7 @@ fn test_append_u16() { ba.append_u16(0x0304_u16); ba.append_u16(0x0506_u16); ba.append_u16(0x0708_u16); - assert_eq!(ba, test_byte_array_8(), "u16 differs"); + assert_eq!(ba, test_byte_array_8()); } #[test] @@ -24,7 +24,7 @@ fn test_append_u16_arr() { ba.append_u16(0x0304_u16); ba.append_u16(0x0506_u16); ba.append_u16(0x0708_u16); - assert_eq!(ba, test_array_8(), "u16 differs"); + assert_eq!(ba, test_array_8()); } #[test] @@ -35,7 +35,7 @@ fn test_append_u16_le() { ba.append_u16_le(0x0403_u16); ba.append_u16_le(0x0605_u16); ba.append_u16_le(0x0807_u16); - assert_eq!(ba, test_byte_array_8(), "u16 differs"); + assert_eq!(ba, test_byte_array_8()); } #[test] @@ -46,7 +46,7 @@ fn test_append_u16_le_arr() { ba.append_u16_le(0x0403_u16); ba.append_u16_le(0x0605_u16); ba.append_u16_le(0x0807_u16); - assert_eq!(ba, test_array_8(), "u16 differs"); + assert_eq!(ba, test_array_8()); } #[test] @@ -55,7 +55,7 @@ fn test_append_u32() { let mut ba: ByteArray = Default::default(); ba.append_u32(0x01020304_u32); ba.append_u32(0x05060708_u32); - assert_eq!(ba, test_byte_array_8(), "u32 differs"); + assert_eq!(ba, test_byte_array_8()); } #[test] @@ -64,7 +64,7 @@ fn test_append_u32_arr() { let mut ba: Array = array![]; ba.append_u32(0x01020304_u32); ba.append_u32(0x05060708_u32); - assert_eq!(ba, test_array_8(), "u32 differs"); + assert_eq!(ba, test_array_8()); } #[test] @@ -73,7 +73,7 @@ fn test_append_u32_le() { let mut ba: ByteArray = Default::default(); ba.append_u32_le(0x04030201_u32); ba.append_u32_le(0x08070605_u32); - assert_eq!(ba, test_byte_array_8(), "u32 differs"); + assert_eq!(ba, test_byte_array_8()); } #[test] @@ -82,7 +82,7 @@ fn test_append_u32_le_arr() { let mut ba: Array = array![]; ba.append_u32_le(0x04030201_u32); ba.append_u32_le(0x08070605_u32); - assert_eq!(ba, test_array_8(), "u32 differs"); + assert_eq!(ba, test_array_8()); } #[test] @@ -91,7 +91,7 @@ fn test_append_u64() { let mut ba: ByteArray = Default::default(); ba.append_u64(0x0102030405060708_u64); ba.append_u64(0x090a0b0c0d0e0f10_u64); - assert_eq!(ba, test_byte_array_16(), "u64 differs"); + assert_eq!(ba, test_byte_array_16()); } #[test] @@ -100,7 +100,7 @@ fn test_append_u64_arr() { let mut ba: Array = array![]; ba.append_u64(0x0102030405060708_u64); ba.append_u64(0x090a0b0c0d0e0f10_u64); - assert_eq!(ba, test_array_16(), "u64 differs"); + assert_eq!(ba, test_array_16()); } #[test] @@ -109,7 +109,7 @@ fn test_append_u64_le() { let mut ba: ByteArray = Default::default(); ba.append_u64_le(0x0807060504030201_u64); ba.append_u64_le(0x100f0e0d0c0b0a09_u64); - assert_eq!(ba, test_byte_array_16(), "u64 differs"); + assert_eq!(ba, test_byte_array_16()); } #[test] @@ -118,7 +118,7 @@ fn test_append_u64_le_arr() { let mut ba: Array = array![]; ba.append_u64_le(0x0807060504030201_u64); ba.append_u64_le(0x100f0e0d0c0b0a09_u64); - assert_eq!(ba, test_array_16(), "u64 differs"); + assert_eq!(ba, test_array_16()); } #[test] @@ -127,7 +127,7 @@ fn test_append_u128() { let mut ba: ByteArray = Default::default(); ba.append_u128(0x0102030405060708090a0b0c0d0e0f10_u128); ba.append_u128(0x1112131415161718191a1b1c1d1e1f20_u128); - assert_eq!(ba, test_byte_array_32(), "u128 differs"); + assert_eq!(ba, test_byte_array_32()); } #[test] @@ -136,7 +136,7 @@ fn test_append_u128_arr() { let mut ba: Array = array![]; ba.append_u128(0x0102030405060708090a0b0c0d0e0f10_u128); ba.append_u128(0x1112131415161718191a1b1c1d1e1f20_u128); - assert_eq!(ba, test_array_32(), "u128 differs"); + assert_eq!(ba, test_array_32()); } #[test] @@ -145,7 +145,7 @@ fn test_append_u128_le() { let mut ba: ByteArray = Default::default(); ba.append_u128_le(0x100f0e0d0c0b0a090807060504030201_u128); ba.append_u128_le(0x201f1e1d1c1b1a191817161514131211_u128); - assert_eq!(ba, test_byte_array_32(), "u128 differs"); + assert_eq!(ba, test_byte_array_32()); } #[test] @@ -154,7 +154,7 @@ fn test_append_u128_le_arr() { let mut ba: Array = array![]; ba.append_u128_le(0x100f0e0d0c0b0a090807060504030201_u128); ba.append_u128_le(0x201f1e1d1c1b1a191817161514131211_u128); - assert_eq!(ba, test_array_32(), "u128 differs"); + assert_eq!(ba, test_array_32()); } #[test] @@ -165,7 +165,7 @@ fn test_append_u256() { high: 0x0102030405060708090a0b0c0d0e0f10_u128, low: 0x1112131415161718191a1b1c1d1e1f20_u128, }; ba.append_u256(word); - assert_eq!(ba, test_byte_array_32(), "u256 differs"); + assert_eq!(ba, test_byte_array_32()); } #[test] @@ -176,7 +176,7 @@ fn test_append_u256_arr() { high: 0x0102030405060708090a0b0c0d0e0f10_u128, low: 0x1112131415161718191a1b1c1d1e1f20_u128, }; ba.append_u256(word); - assert_eq!(ba, test_array_32(), "u256 differs"); + assert_eq!(ba, test_array_32()); } #[test] @@ -187,7 +187,7 @@ fn test_append_u256_le() { low: 0x100f0e0d0c0b0a090807060504030201_u128, high: 0x201f1e1d1c1b1a191817161514131211_u128, }; ba.append_u256_le(word); - assert_eq!(ba, test_byte_array_32(), "u256 differs"); + assert_eq!(ba, test_byte_array_32()); } #[test] @@ -198,7 +198,7 @@ fn test_append_u256_le_arr() { low: 0x100f0e0d0c0b0a090807060504030201_u128, high: 0x201f1e1d1c1b1a191817161514131211_u128, }; ba.append_u256_le(word); - assert_eq!(ba, test_array_32(), "u256 differs"); + assert_eq!(ba, test_array_32()); } #[test] @@ -213,7 +213,7 @@ fn test_append_u512() { let mut ba: ByteArray = Default::default(); ba.append_u512(test64); - assert_eq!(ba, test_byte_array_64(), "test64 differs"); + assert_eq!(ba, test_byte_array_64()); } #[test] @@ -228,7 +228,7 @@ fn test_append_u512_arr() { let mut ba: Array = array![]; ba.append_u512(test64); - assert_eq!(ba, test_array_64(), "test64 differs"); + assert_eq!(ba, test_array_64()); } #[test] @@ -243,7 +243,7 @@ fn test_append_u512_le() { let mut ba: ByteArray = Default::default(); ba.append_u512_le(test64); - assert_eq!(ba, test_byte_array_64(), "test64 differs"); + assert_eq!(ba, test_byte_array_64()); } #[test] @@ -258,7 +258,7 @@ fn test_append_u512_le_arr() { let mut ba: Array = array![]; ba.append_u512_le(test64); - assert_eq!(ba, test_array_64(), "test64 differs"); + assert_eq!(ba, test_array_64()); } #[test] @@ -268,7 +268,7 @@ fn test_append_i8() { ba1.append_i8(127_i8); let mut ba2: ByteArray = Default::default(); ba2.append_byte(0x7f_u8); - assert_eq!(ba1, ba2, "i8 differs"); + assert_eq!(ba1, ba2); } #[test] @@ -278,7 +278,7 @@ fn test_append_i8_arr() { ba1.append_i8(127_i8); let mut ba2: Array = array![]; ba2.append(0x7f_u8); - assert_eq!(ba1, ba2, "i8 differs"); + assert_eq!(ba1, ba2); } #[test] @@ -288,7 +288,7 @@ fn test_append_i8_neg() { ba1.append_i8(-128_i8); let mut ba2: ByteArray = Default::default(); ba2.append_byte(0x80_u8); - assert_eq!(ba1, ba2, "negative i8 differs"); + assert_eq!(ba1, ba2); } #[test] @@ -298,7 +298,7 @@ fn test_append_i8_neg_arr() { ba1.append_i8(-128_i8); let mut ba2: Array = array![]; ba2.append(0x80_u8); - assert_eq!(ba1, ba2, "negative i8 differs"); + assert_eq!(ba1, ba2); } #[test] @@ -309,7 +309,7 @@ fn test_append_i16() { ba1.append_i16(0x0304_i16); ba1.append_i16(0x0506_i16); ba1.append_i16(0x0708_i16); - assert_eq!(ba1, test_byte_array_8(), "i16 differs"); + assert_eq!(ba1, test_byte_array_8()); } #[test] @@ -320,7 +320,7 @@ fn test_append_i16_arr() { ba1.append_i16(0x0304_i16); ba1.append_i16(0x0506_i16); ba1.append_i16(0x0708_i16); - assert_eq!(ba1, test_array_8(), "i16 differs"); + assert_eq!(ba1, test_array_8()); } #[test] @@ -331,7 +331,7 @@ fn test_append_i16_le() { ba1.append_i16_le(0x0403_i16); ba1.append_i16_le(0x0605_i16); ba1.append_i16_le(0x0807_i16); - assert_eq!(ba1, test_byte_array_8(), "i16 differs"); + assert_eq!(ba1, test_byte_array_8()); } #[test] @@ -342,7 +342,7 @@ fn test_append_i16_le_arr() { ba1.append_i16_le(0x0403_i16); ba1.append_i16_le(0x0605_i16); ba1.append_i16_le(0x0807_i16); - assert_eq!(ba1, test_array_8(), "i16 differs"); + assert_eq!(ba1, test_array_8()); } #[test] @@ -357,7 +357,7 @@ fn test_append_i16_neg() { ba1.append_i16(-1_i16); ba1.append_i16(-1_i16); ba1.append_i16(-2_i16); - assert_eq!(ba1, test_byte_array_16_neg(), "negative i16 differs"); + assert_eq!(ba1, test_byte_array_16_neg()); } #[test] @@ -372,7 +372,7 @@ fn test_append_i16_neg_arr() { ba1.append_i16(-1_i16); ba1.append_i16(-1_i16); ba1.append_i16(-2_i16); - assert_eq!(ba1, test_array_16_neg(), "negative i16 differs"); + assert_eq!(ba1, test_array_16_neg()); } #[test] @@ -387,7 +387,7 @@ fn test_append_i16_le_neg() { ba1.append_i16_le(-1_i16); ba1.append_i16_le(-1_i16); ba1.append_i16_le(-257_i16); - assert_eq!(ba1, test_byte_array_16_neg(), "negative i16 differs"); + assert_eq!(ba1, test_byte_array_16_neg()); } #[test] @@ -402,7 +402,7 @@ fn test_append_i16_le_neg_arr() { ba1.append_i16_le(-1_i16); ba1.append_i16_le(-1_i16); ba1.append_i16_le(-257_i16); - assert_eq!(ba1, test_array_16_neg(), "negative i16 differs"); + assert_eq!(ba1, test_array_16_neg()); } #[test] @@ -411,7 +411,7 @@ fn test_append_i32() { let mut ba: ByteArray = Default::default(); ba.append_i32(0x01020304_i32); ba.append_i32(0x05060708_i32); - assert_eq!(ba, test_byte_array_8(), "i32 differs"); + assert_eq!(ba, test_byte_array_8()); } #[test] @@ -420,7 +420,7 @@ fn test_append_i32_arr() { let mut ba: Array = array![]; ba.append_i32(0x01020304_i32); ba.append_i32(0x05060708_i32); - assert_eq!(ba, test_array_8(), "i32 differs"); + assert_eq!(ba, test_array_8()); } #[test] @@ -429,7 +429,7 @@ fn test_append_i32_le() { let mut ba: ByteArray = Default::default(); ba.append_i32_le(0x04030201_i32); ba.append_i32_le(0x08070605_i32); - assert_eq!(ba, test_byte_array_8(), "i32 differs"); + assert_eq!(ba, test_byte_array_8()); } #[test] @@ -438,7 +438,7 @@ fn test_append_i32_le_arr() { let mut ba: Array = array![]; ba.append_i32_le(0x04030201_i32); ba.append_i32_le(0x08070605_i32); - assert_eq!(ba, test_array_8(), "i32 differs"); + assert_eq!(ba, test_array_8()); } #[test] @@ -449,7 +449,7 @@ fn test_append_i32_neg() { ba.append_i32(-1_i32); ba.append_i32(-1_i32); ba.append_i32(-2_i32); - assert_eq!(ba, test_byte_array_16_neg(), "negative i32 differs"); + assert_eq!(ba, test_byte_array_16_neg()); } #[test] #[available_gas(1000000)] @@ -459,7 +459,7 @@ fn test_append_i32_neg_arr() { ba.append_i32(-1_i32); ba.append_i32(-1_i32); ba.append_i32(-2_i32); - assert_eq!(ba, test_array_16_neg(), "negative i32 differs"); + assert_eq!(ba, test_array_16_neg()); } #[test] @@ -470,7 +470,7 @@ fn test_append_i32_le_neg() { ba.append_i32_le(-1_i32); ba.append_i32_le(-1_i32); ba.append_i32_le(-16777217_i32); - assert_eq!(ba, test_byte_array_16_neg(), "negative i32 differs"); + assert_eq!(ba, test_byte_array_16_neg()); } #[test] @@ -481,7 +481,7 @@ fn test_append_i32_le_neg_arr() { ba.append_i32_le(-1_i32); ba.append_i32_le(-1_i32); ba.append_i32_le(-16777217_i32); - assert_eq!(ba, test_array_16_neg(), "negative i32 differs"); + assert_eq!(ba, test_array_16_neg()); } #[test] @@ -490,7 +490,7 @@ fn test_append_i64() { let mut ba: ByteArray = Default::default(); ba.append_i64(0x0102030405060708_i64); ba.append_i64(0x090a0b0c0d0e0f10_i64); - assert_eq!(ba, test_byte_array_16(), "i64 differs"); + assert_eq!(ba, test_byte_array_16()); } #[test] @@ -499,7 +499,7 @@ fn test_append_i64_arr() { let mut ba: Array = array![]; ba.append_i64(0x0102030405060708_i64); ba.append_i64(0x090a0b0c0d0e0f10_i64); - assert_eq!(ba, test_array_16(), "i64 differs"); + assert_eq!(ba, test_array_16()); } #[test] @@ -508,7 +508,7 @@ fn test_append_i64_le() { let mut ba: ByteArray = Default::default(); ba.append_i64_le(0x0807060504030201_i64); ba.append_i64_le(0x100f0e0d0c0b0a09_i64); - assert_eq!(ba, test_byte_array_16(), "i64 differs"); + assert_eq!(ba, test_byte_array_16()); } #[test] @@ -517,7 +517,7 @@ fn test_append_i64_le_arr() { let mut ba: Array = array![]; ba.append_i64_le(0x0807060504030201_i64); ba.append_i64_le(0x100f0e0d0c0b0a09_i64); - assert_eq!(ba, test_array_16(), "i64 differs"); + assert_eq!(ba, test_array_16()); } #[test] @@ -526,7 +526,7 @@ fn test_append_i64_neg() { let mut ba: ByteArray = Default::default(); ba.append_i64(-1_i64); ba.append_i64(-2_i64); - assert_eq!(ba, test_byte_array_16_neg(), "negative i64 differs"); + assert_eq!(ba, test_byte_array_16_neg()); } #[test] @@ -535,7 +535,7 @@ fn test_append_i64_neg_arr() { let mut ba: Array = array![]; ba.append_i64(-1_i64); ba.append_i64(-2_i64); - assert_eq!(ba, test_array_16_neg(), "negative i64 differs"); + assert_eq!(ba, test_array_16_neg()); } #[test] @@ -544,7 +544,7 @@ fn test_append_i64_le_neg() { let mut ba: ByteArray = Default::default(); ba.append_i64_le(-1_i64); ba.append_i64_le(-72057594037927937_i64); - assert_eq!(ba, test_byte_array_16_neg(), "negative i64 differs"); + assert_eq!(ba, test_byte_array_16_neg()); } #[test] @@ -553,7 +553,7 @@ fn test_append_i64_le_neg_arr() { let mut ba: Array = array![]; ba.append_i64_le(-1_i64); ba.append_i64_le(-72057594037927937_i64); - assert_eq!(ba, test_array_16_neg(), "negative i64 differs"); + assert_eq!(ba, test_array_16_neg()); } #[test] @@ -562,7 +562,7 @@ fn test_append_i128() { let mut ba: ByteArray = Default::default(); ba.append_i128(0x0102030405060708090a0b0c0d0e0f10_i128); ba.append_i128(0x1112131415161718191a1b1c1d1e1f20_i128); - assert_eq!(ba, test_byte_array_32(), "i128 differs"); + assert_eq!(ba, test_byte_array_32()); } #[test] @@ -571,7 +571,7 @@ fn test_append_i128_arr() { let mut ba: Array = array![]; ba.append_i128(0x0102030405060708090a0b0c0d0e0f10_i128); ba.append_i128(0x1112131415161718191a1b1c1d1e1f20_i128); - assert_eq!(ba, test_array_32(), "i128 differs"); + assert_eq!(ba, test_array_32()); } #[test] @@ -580,7 +580,7 @@ fn test_append_i128_le() { let mut ba: ByteArray = Default::default(); ba.append_i128_le(0x100f0e0d0c0b0a090807060504030201_i128); ba.append_i128_le(0x201f1e1d1c1b1a191817161514131211_i128); - assert_eq!(ba, test_byte_array_32(), "i128 differs"); + assert_eq!(ba, test_byte_array_32()); } #[test] @@ -589,7 +589,7 @@ fn test_append_i128_le_arr() { let mut ba: Array = array![]; ba.append_i128_le(0x100f0e0d0c0b0a090807060504030201_i128); ba.append_i128_le(0x201f1e1d1c1b1a191817161514131211_i128); - assert_eq!(ba, test_array_32(), "i128 differs"); + assert_eq!(ba, test_array_32()); } #[test] @@ -597,7 +597,7 @@ fn test_append_i128_le_arr() { fn test_append_i128_neg() { let mut ba: ByteArray = Default::default(); ba.append_i128(-2_i128); - assert_eq!(ba, test_byte_array_16_neg(), "negative i128 differs"); + assert_eq!(ba, test_byte_array_16_neg()); } #[test] @@ -605,7 +605,7 @@ fn test_append_i128_neg() { fn test_append_i128_neg_arr() { let mut ba: Array = array![]; ba.append_i128(-2_i128); - assert_eq!(ba, test_array_16_neg(), "negative i128 differs"); + assert_eq!(ba, test_array_16_neg()); } #[test] @@ -613,7 +613,7 @@ fn test_append_i128_neg_arr() { fn test_append_i128_le_neg() { let mut ba: ByteArray = Default::default(); ba.append_i128_le(-1329227995784915872903807060280344577_i128); - assert_eq!(ba, test_byte_array_16_neg(), "negative i128 differs"); + assert_eq!(ba, test_byte_array_16_neg()); } #[test] @@ -621,5 +621,5 @@ fn test_append_i128_le_neg() { fn test_append_i128_le_neg_arr() { let mut ba: Array = array![]; ba.append_i128_le(-1329227995784915872903807060280344577_i128); - assert_eq!(ba, test_array_16_neg(), "negative i128 differs"); + assert_eq!(ba, test_array_16_neg()); } diff --git a/packages/data_structures/src/tests/queue.cairo b/packages/data_structures/src/tests/queue.cairo index 90b73208..2387e7e5 100644 --- a/packages/data_structures/src/tests/queue.cairo +++ b/packages/data_structures/src/tests/queue.cairo @@ -6,7 +6,7 @@ fn queue_new_test() { let queue = QueueTrait::::new(); let result_len = queue.len(); - assert_eq!(result_len, 0, "wrong length"); + assert_eq!(result_len, 0); } #[test] @@ -26,7 +26,7 @@ fn queue_enqueue_test() { queue.enqueue(2); assert!(!queue.is_empty(), "must not be empty"); - assert_eq!(queue.len(), 2, "len should be 2"); + assert_eq!(queue.len(), 2); } #[test] @@ -38,12 +38,12 @@ fn queue_peek_front_test() { queue.enqueue(3); match queue.peek_front() { - Option::Some(result) => { assert_eq!(*(result.unbox()), 1, "wrong result"); }, + Option::Some(result) => { assert_eq!(*(result.unbox()), 1); }, Option::None => { assert!(false, "should return value"); }, }; let result_len = queue.len(); - assert_eq!(result_len, 3, "should not remove items"); + assert_eq!(result_len, 3); } #[test] @@ -55,10 +55,10 @@ fn queue_dequeue_test() { queue.enqueue(3); match queue.dequeue() { - Option::Some(result) => { assert_eq!(result, 1, "wrong result"); }, + Option::Some(result) => { assert_eq!(result, 1); }, Option::None => { assert!(false, "should return a value"); }, }; let result_len = queue.len(); - assert_eq!(result_len, 2, "should remove item"); + assert_eq!(result_len, 2); } diff --git a/packages/encoding/src/tests/base64_felt_test.cairo b/packages/encoding/src/tests/base64_felt_test.cairo index bb566663..9d64a92a 100644 --- a/packages/encoding/src/tests/base64_felt_test.cairo +++ b/packages/encoding/src/tests/base64_felt_test.cairo @@ -26,7 +26,7 @@ fn base64encode_empty_test() { let input = 0; let result = Base64FeltEncoder::encode(input); let check = Base64Encoder::encode(bytes_be(input)); - assert_eq!(result, check, "Expected equal"); + assert_eq!(result, check); } #[test] @@ -35,7 +35,7 @@ fn base64encode_simple_test() { let input = 'a'; let result = Base64FeltEncoder::encode(input); let check = Base64Encoder::encode(bytes_be(input)); - assert_eq!(result, check, "Expected equal"); + assert_eq!(result, check); } #[test] @@ -44,7 +44,7 @@ fn base64encode_hello_world_test() { let input = 'hello world'; let result = Base64FeltEncoder::encode(input); let check = Base64Encoder::encode(bytes_be(input)); - assert_eq!(result, check, "Expected equal"); + assert_eq!(result, check); } @@ -55,7 +55,7 @@ fn base64encode_with_plus_and_slash() { let result = Base64FeltEncoder::encode(input); let check = Base64Encoder::encode(bytes_be(input)); - assert_eq!(result, check, "Expected equal"); + assert_eq!(result, check); } #[test] @@ -65,5 +65,5 @@ fn base64urlencode_with_plus_and_slash() { let result = Base64UrlFeltEncoder::encode(input); let check = Base64UrlEncoder::encode(bytes_be(input)); - assert_eq!(result, check, "Expected equal"); + assert_eq!(result, check); } diff --git a/packages/encoding/src/tests/base64_test.cairo b/packages/encoding/src/tests/base64_test.cairo index 5b1be4fb..34e16f75 100644 --- a/packages/encoding/src/tests/base64_test.cairo +++ b/packages/encoding/src/tests/base64_test.cairo @@ -5,7 +5,7 @@ use alexandria_encoding::base64::{Base64Encoder, Base64Decoder, Base64UrlEncoder fn base64encode_empty_test() { let input = array![]; let result = Base64Encoder::encode(input); - assert_eq!(result.len(), 0, "invalid result length"); + assert_eq!(result.len(), 0); } #[test] @@ -14,11 +14,11 @@ fn base64encode_simple_test() { let input = array!['a']; let result = Base64Encoder::encode(input); - assert_eq!(result.len(), 4, "invalid result length"); - assert_eq!(*result[0], 'Y', "invalid result[0]"); - assert_eq!(*result[1], 'Q', "invalid result[1]"); - assert_eq!(*result[2], '=', "invalid result[2]"); - assert_eq!(*result[3], '=', "invalid result[3]"); + assert_eq!(result.len(), 4); + assert_eq!(*result[0], 'Y'); + assert_eq!(*result[1], 'Q'); + assert_eq!(*result[2], '='); + assert_eq!(*result[3], '='); } #[test] @@ -27,23 +27,23 @@ fn base64encode_hello_world_test() { let input = array!['h', 'e', 'l', 'l', 'o', ' ', 'w', 'o', 'r', 'l', 'd']; let result = Base64Encoder::encode(input); - assert_eq!(result.len(), 16, "invalid result length"); - assert_eq!(*result[0], 'a', "invalid result[0]"); - assert_eq!(*result[1], 'G', "invalid result[1]"); - assert_eq!(*result[2], 'V', "invalid result[2]"); - assert_eq!(*result[3], 's', "invalid result[3]"); - assert_eq!(*result[4], 'b', "invalid result[4]"); - assert_eq!(*result[5], 'G', "invalid result[5]"); - assert_eq!(*result[6], '8', "invalid result[6]"); - assert_eq!(*result[7], 'g', "invalid result[7]"); - assert_eq!(*result[8], 'd', "invalid result[8]"); - assert_eq!(*result[9], '2', "invalid result[9]"); - assert_eq!(*result[10], '9', "invalid result[10]"); - assert_eq!(*result[11], 'y', "invalid result[11]"); - assert_eq!(*result[12], 'b', "invalid result[12]"); - assert_eq!(*result[13], 'G', "invalid result[13]"); - assert_eq!(*result[14], 'Q', "invalid result[14]"); - assert_eq!(*result[15], '=', "invalid result[15]"); + assert_eq!(result.len(), 16); + assert_eq!(*result[0], 'a'); + assert_eq!(*result[1], 'G'); + assert_eq!(*result[2], 'V'); + assert_eq!(*result[3], 's'); + assert_eq!(*result[4], 'b'); + assert_eq!(*result[5], 'G'); + assert_eq!(*result[6], '8'); + assert_eq!(*result[7], 'g'); + assert_eq!(*result[8], 'd'); + assert_eq!(*result[9], '2'); + assert_eq!(*result[10], '9'); + assert_eq!(*result[11], 'y'); + assert_eq!(*result[12], 'b'); + assert_eq!(*result[13], 'G'); + assert_eq!(*result[14], 'Q'); + assert_eq!(*result[15], '='); } #[test] @@ -52,7 +52,7 @@ fn base64decode_empty_test() { let input = array![]; let result = Base64Decoder::decode(input); - assert_eq!(result.len(), 0, "invalid result length"); + assert_eq!(result.len(), 0); } #[test] @@ -61,8 +61,8 @@ fn base64decode_simple_test() { let input = array!['Y', 'Q', '=', '=']; let result = Base64Decoder::decode(input); - assert_eq!(result.len(), 1, "invalid result length"); - assert_eq!(*result[0], 'a', "invalid result[0]"); + assert_eq!(result.len(), 1); + assert_eq!(*result[0], 'a'); } #[test] @@ -73,18 +73,18 @@ fn base64decode_hello_world_test() { ]; let result = Base64Decoder::decode(input); - assert_eq!(result.len(), 11, "invalid result length"); - assert_eq!(*result[0], 'h', "invalid result[0]"); - assert_eq!(*result[1], 'e', "invalid result[1]"); - assert_eq!(*result[2], 'l', "invalid result[2]"); - assert_eq!(*result[3], 'l', "invalid result[3]"); - assert_eq!(*result[4], 'o', "invalid result[4]"); - assert_eq!(*result[5], ' ', "invalid result[5]"); - assert_eq!(*result[6], 'w', "invalid result[6]"); - assert_eq!(*result[7], 'o', "invalid result[7]"); - assert_eq!(*result[8], 'r', "invalid result[8]"); - assert_eq!(*result[9], 'l', "invalid result[9]"); - assert_eq!(*result[10], 'd', "invalid result[10]"); + assert_eq!(result.len(), 11); + assert_eq!(*result[0], 'h'); + assert_eq!(*result[1], 'e'); + assert_eq!(*result[2], 'l'); + assert_eq!(*result[3], 'l'); + assert_eq!(*result[4], 'o'); + assert_eq!(*result[5], ' '); + assert_eq!(*result[6], 'w'); + assert_eq!(*result[7], 'o'); + assert_eq!(*result[8], 'r'); + assert_eq!(*result[9], 'l'); + assert_eq!(*result[10], 'd'); } #[test] @@ -93,11 +93,11 @@ fn base64encode_with_plus_and_slash() { let input = array![255, 239]; let result = Base64Encoder::encode(input); - assert_eq!(result.len(), 4, "invalid result length"); - assert_eq!(*result[0], '/', "invalid result[0]"); - assert_eq!(*result[1], '+', "invalid result[1]"); - assert_eq!(*result[2], '8', "invalid result[2]"); - assert_eq!(*result[3], '=', "invalid result[3]"); + assert_eq!(result.len(), 4); + assert_eq!(*result[0], '/'); + assert_eq!(*result[1], '+'); + assert_eq!(*result[2], '8'); + assert_eq!(*result[3], '='); } #[test] @@ -106,11 +106,11 @@ fn base64urlencode_with_plus_and_slash() { let input = array![255, 239]; let result = Base64UrlEncoder::encode(input); - assert_eq!(result.len(), 4, "invalid result length"); - assert_eq!(*result[0], '_', "invalid result[0]"); - assert_eq!(*result[1], '-', "invalid result[1]"); - assert_eq!(*result[2], '8', "invalid result[2]"); - assert_eq!(*result[3], '=', "invalid result[3]"); + assert_eq!(result.len(), 4); + assert_eq!(*result[0], '_'); + assert_eq!(*result[1], '-'); + assert_eq!(*result[2], '8'); + assert_eq!(*result[3], '='); } #[test] @@ -119,9 +119,9 @@ fn base64decode_with_plus_and_slash() { let input = array!['/', '+', '8', '=']; let result = Base64UrlDecoder::decode(input); - assert_eq!(result.len(), 2, "invalid result length"); - assert_eq!(*result[0], 255, "invalid result[0]"); - assert_eq!(*result[1], 239, "invalid result[1]"); + assert_eq!(result.len(), 2); + assert_eq!(*result[0], 255); + assert_eq!(*result[1], 239); } #[test] @@ -130,7 +130,7 @@ fn base64urldecode_with_plus_and_slash() { let input = array!['_', '-', '8', '=']; let result = Base64UrlDecoder::decode(input); - assert_eq!(result.len(), 2, "invalid result length"); - assert_eq!(*result[0], 255, "invalid result[0]"); - assert_eq!(*result[1], 239, "invalid result[1]"); + assert_eq!(result.len(), 2); + assert_eq!(*result[0], 255); + assert_eq!(*result[1], 239); } diff --git a/packages/encoding/src/tests/sol_abi.cairo b/packages/encoding/src/tests/sol_abi.cairo index 03b5f663..e3f2d278 100644 --- a/packages/encoding/src/tests/sol_abi.cairo +++ b/packages/encoding/src/tests/sol_abi.cairo @@ -88,7 +88,7 @@ fn encode_test() { .encode(sba) .encode(address) .encode(eth_address); - assert_eq!(encoded, expected, "Encode uints failed"); + assert_eq!(encoded, expected); } #[test] @@ -134,7 +134,7 @@ fn encode_packed_test() { .encode_packed(address) .encode_packed(eth_address) .encode_packed(bytesArray); - assert_eq!(encoded, expected, "Encode packed uints failed"); + assert_eq!(encoded, expected); } #[test] @@ -147,7 +147,7 @@ fn encoded_as_test() { .encode_as(3, 0x101112_u128) .encode_as(21, 0xaabbcc_felt252) .encode_as(5, 0xa0b1c2_u256); - assert_eq!(encoded, expected, "Encode as failed"); + assert_eq!(encoded, expected); let sba: ByteArray = SolBytesTrait::bytes10(0x0000a0b1c2c3c4c5c6c8).into(); let bytes_31: bytes31 = 0xaabbcc.try_into().unwrap(); @@ -156,7 +156,7 @@ fn encoded_as_test() { .encode_as(3, SolBytesTrait::bytes10(0x10111213141516171910)) .encode_as(21, bytes_31) .encode_as(5, sba); - assert_eq!(encoded, expected, "Encode as from bytes failed"); + assert_eq!(encoded, expected); } #[test] @@ -165,7 +165,7 @@ fn selector_test() { let expected: Bytes = BytesTrait::new(4, array![0xa9059cbb000000000000000000000000]); let mut encoded: Bytes = BytesTrait::new_empty(); encoded = encoded.encode_selector(0xa9059cbb_u32); - assert_eq!(encoded, expected, "Encode selector failed"); + assert_eq!(encoded, expected); // encode call : transfer(0xDeaDbeefdEAdbeefdEadbEEFdeadbeEFdEaDbeeF, 10000) let expected: Bytes = BytesTrait::new( @@ -181,7 +181,7 @@ fn selector_test() { let mut encoded: Bytes = BytesTrait::new_empty(); let eth_address: EthAddress = 0xDeaDbeefdEAdbeefdEadbEEFdeadbeEFdEaDbeeF_u256.into(); encoded = encoded.encode_selector(0xa9059cbb_u32).encode(eth_address).encode(10000_u256); - assert_eq!(encoded, expected, "Encode selector full failed"); + assert_eq!(encoded, expected); } #[test] @@ -218,20 +218,20 @@ fn decode_test() { let mut offset = 0; let decoded: u16 = encoded.decode(ref offset); - assert_eq!(decoded, 0xa0a1, "Decode uint16 failed"); - assert_eq!(offset, 32, "Offset after decode uint16 failed"); + assert_eq!(decoded, 0xa0a1); + assert_eq!(offset, 32); let decoded: u32 = encoded.decode(ref offset); - assert_eq!(decoded, 0xa2a3a4a5, "Decode uint32 failed"); - assert_eq!(offset, 64, "Offset after decode uint32 failed"); + assert_eq!(decoded, 0xa2a3a4a5); + assert_eq!(offset, 64); let decoded: u8 = encoded.decode(ref offset); - assert_eq!(decoded, 0xa6, "Decode uint8 failed"); - assert_eq!(offset, 96, "Offset after decode uint8 failed"); + assert_eq!(decoded, 0xa6); + assert_eq!(offset, 96); let decoded: u128 = encoded.decode(ref offset); - assert_eq!(decoded, 0xa7a8a9aaabacadaeafb0b1b2b3b4b5b6, "Decode uint128 failed"); - assert_eq!(offset, 128, "Offset after decode uint128 failed"); + assert_eq!(decoded, 0xa7a8a9aaabacadaeafb0b1b2b3b4b5b6); + assert_eq!(offset, 128); let decoded: u256 = encoded.decode(ref offset); assert_eq!( @@ -239,45 +239,45 @@ fn decode_test() { 0xabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcd_u256, "Decode uint256 failed" ); - assert_eq!(offset, 160, "Offset after decode uint256 failed"); + assert_eq!(offset, 160); let decoded: u64 = encoded.decode(ref offset); - assert_eq!(decoded, 0xb7b8b9babbbcbdbe, "Decode uint64 failed"); - assert_eq!(offset, 192, "Offset after decode uint64 failed"); + assert_eq!(decoded, 0xb7b8b9babbbcbdbe); + assert_eq!(offset, 192); let decoded: Bytes = SolBytesTrait::::bytes5(encoded.decode(ref offset)); - assert_eq!(decoded, SolBytesTrait::bytes5(0xa0a1a2a3), "Decode Bytes failed"); - assert_eq!(offset, 224, "Offset after decode Bytes failed"); + assert_eq!(decoded, SolBytesTrait::bytes5(0xa0a1a2a3)); + assert_eq!(offset, 224); let decoded: ByteArray = encoded.decode(ref offset); let expected: ByteArray = SolBytesTrait::bytes32( 0xa0a1a2a3a4a5a6a7a8a9aaabacadaeafb0b1b2b3000000000000000000000000_u256 ) .into(); - assert_eq!(decoded, expected, "Decode ByteArray failed"); - assert_eq!(offset, 256, "Offset after decode ByteArray failed"); + assert_eq!(decoded, expected); + assert_eq!(offset, 256); let decoded: bytes31 = encoded.decode(ref offset); let bytes_31: bytes31 = 0xa0aaab00000000000000000000000000ac.try_into().unwrap(); assert!(decoded == bytes_31, "Decode byte31 failed"); - assert_eq!(offset, 288, "Offset after decode byte31 failed"); + assert_eq!(offset, 288); let decoded: felt252 = encoded.decode(ref offset); - assert_eq!(decoded, 0x1234_felt252, "Decode felt252 failed"); - assert_eq!(offset, 320, "Offset after decode felt252 failed"); + assert_eq!(decoded, 0x1234_felt252); + assert_eq!(offset, 320); let expected: ContractAddress = 0xa0a1a2a3000000000000000000000000000000000000000000000000001234_felt252 .try_into() .expect('Couldn\'t convert to address'); let decoded: ContractAddress = encoded.decode(ref offset); - assert_eq!(decoded, expected, "Decode ContractAddress failed"); - assert_eq!(offset, 352, "Offset after decode ContractAddress failed"); + assert_eq!(decoded, expected); + assert_eq!(offset, 352); let expected: EthAddress = 0xDeadbeefDeaDbeefdEAdbeefdEadbEEFdeadbeEF_u256.into(); let decoded: EthAddress = encoded.decode(ref offset); - assert_eq!(decoded, expected, "Decode EthAddress failed"); - assert_eq!(offset, 384, "Offset after decode EthAddress failed"); + assert_eq!(decoded, expected); + assert_eq!(offset, 384); } #[test] @@ -289,7 +289,7 @@ fn sol_bytes_test() { let mut bytesValAcc: Bytes = BytesTrait::new_empty(); bytesValAcc.concat(@bytesVal5); bytesValAcc.concat(@bytesVal9); - assert_eq!(expectedVal14, bytesValAcc, "Concat bytes ints failed"); + assert_eq!(expectedVal14, bytesValAcc); // Test bytesX with integer types needing `into` calls let expectedVal21: Bytes = SolBytesTrait::bytes21( @@ -300,7 +300,7 @@ fn sol_bytes_test() { let mut bytesValAcc: Bytes = BytesTrait::new_empty(); bytesValAcc.concat(@bytesVal18); bytesValAcc.concat(@bytesVal3); - assert_eq!(expectedVal21, bytesValAcc, "Concat bytes ints into failed"); + assert_eq!(expectedVal21, bytesValAcc); // Test bytesX with Bytes types let expectedVal25: Bytes = SolBytesTrait::bytes25( @@ -317,5 +317,5 @@ fn sol_bytes_test() { let mut bytesValAcc: Bytes = BytesTrait::new_empty(); bytesValAcc.concat(@bytesVal6); bytesValAcc.concat(@bytesVal19); - assert_eq!(expectedVal25, bytesValAcc, "Concat bytes failed"); + assert_eq!(expectedVal25, bytesValAcc); } diff --git a/packages/linalg/src/tests/dot_test.cairo b/packages/linalg/src/tests/dot_test.cairo index e97106a5..fff011d8 100644 --- a/packages/linalg/src/tests/dot_test.cairo +++ b/packages/linalg/src/tests/dot_test.cairo @@ -5,7 +5,7 @@ use alexandria_linalg::dot::dot; fn dot_product_test() { let xs = array![3_u64, 5, 7]; let ys = array![11, 13, 17]; - assert_eq!(dot(xs.span(), ys.span()), 217, "invalid dot product"); + assert_eq!(dot(xs.span(), ys.span()), 217); } #[test] diff --git a/packages/linalg/src/tests/kron_test.cairo b/packages/linalg/src/tests/kron_test.cairo index dac45381..26be4b66 100644 --- a/packages/linalg/src/tests/kron_test.cairo +++ b/packages/linalg/src/tests/kron_test.cairo @@ -6,15 +6,15 @@ fn kron_product_test() { let xs = array![1_u64, 10, 100]; let ys = array![5, 6, 7]; let zs = kron(xs.span(), ys.span()).unwrap(); - assert_eq!(*zs[0], 5, "wrong value at index 0"); - assert_eq!(*zs[1], 6, "wrong value at index 1"); - assert_eq!(*zs[2], 7, "wrong value at index 2"); - assert_eq!(*zs[3], 50, "wrong value at index 3"); - assert_eq!(*zs[4], 60, "wrong value at index 4"); - assert_eq!(*zs[5], 70, "wrong value at index 5"); - assert_eq!(*zs[6], 500, "wrong value at index 6"); - assert_eq!(*zs[7], 600, "wrong value at index 7"); - assert_eq!(*zs[8], 700, "wrong value at index 8"); + assert_eq!(*zs[0], 5); + assert_eq!(*zs[1], 6); + assert_eq!(*zs[2], 7); + assert_eq!(*zs[3], 50); + assert_eq!(*zs[4], 60); + assert_eq!(*zs[5], 70); + assert_eq!(*zs[6], 500); + assert_eq!(*zs[7], 600); + assert_eq!(*zs[8], 700); } #[test] diff --git a/packages/linalg/src/tests/norm_test.cairo b/packages/linalg/src/tests/norm_test.cairo index 023ae75d..d432bbf0 100644 --- a/packages/linalg/src/tests/norm_test.cairo +++ b/packages/linalg/src/tests/norm_test.cairo @@ -4,26 +4,26 @@ use alexandria_linalg::norm::norm; #[available_gas(2000000)] fn norm_test_1() { let array = array![3_u128, 4]; - assert_eq!(norm(array.span(), 2, 10), 5, "invalid l2 norm"); + assert_eq!(norm(array.span(), 2, 10), 5); } #[test] #[available_gas(2000000)] fn norm_test_2() { let array = array![3_u128, 4]; - assert_eq!(norm(array.span(), 1, 10), 7, "invalid l1 norm"); + assert_eq!(norm(array.span(), 1, 10), 7); } #[test] #[available_gas(2000000)] fn norm_test_3() { let array = array![3_u128, 4]; - assert_eq!(norm(array.span(), 0, 10), 2, "invalid l1 norm"); + assert_eq!(norm(array.span(), 0, 10), 2); } #[test] #[available_gas(2000000)] fn norm_test_into() { let array = array![3_u32, 4]; - assert_eq!(norm(array.span(), 2, 10), 5, "invalid l2 norm"); + assert_eq!(norm(array.span(), 2, 10), 5); } diff --git a/packages/math/src/tests/aliquot_sum_test.cairo b/packages/math/src/tests/aliquot_sum_test.cairo index ce80d3d0..608debf2 100644 --- a/packages/math/src/tests/aliquot_sum_test.cairo +++ b/packages/math/src/tests/aliquot_sum_test.cairo @@ -3,41 +3,41 @@ use alexandria_math::aliquot_sum::aliquot_sum; #[test] #[available_gas(200000)] fn zero_test() { - assert_eq!(aliquot_sum(0), 0, "invalid result"); + assert_eq!(aliquot_sum(0), 0); } #[test] #[available_gas(200000)] fn one_test() { - assert_eq!(aliquot_sum(1), 0, "invalid result"); + assert_eq!(aliquot_sum(1), 0); } #[test] #[available_gas(200000)] fn two_test() { - assert_eq!(aliquot_sum(2), 1, "invalid result"); + assert_eq!(aliquot_sum(2), 1); } #[test] #[available_gas(200000)] fn one_digit_number_test() { - assert_eq!(aliquot_sum(6), 6, "invalid result"); + assert_eq!(aliquot_sum(6), 6); } #[test] #[available_gas(2000000)] fn two_digit_number_test() { - assert_eq!(aliquot_sum(15), 9, "invalid result"); + assert_eq!(aliquot_sum(15), 9); } #[test] #[available_gas(20000000)] fn three_digit_number_test() { - assert_eq!(aliquot_sum(343), 57, "invalid result"); + assert_eq!(aliquot_sum(343), 57); } #[test] #[available_gas(2000000)] fn two_digit_prime_number_test() { - assert_eq!(aliquot_sum(17), 1, "invalid result"); + assert_eq!(aliquot_sum(17), 1); } diff --git a/packages/math/src/tests/collatz_sequence_test.cairo b/packages/math/src/tests/collatz_sequence_test.cairo index 6a8a28d7..6c39763a 100644 --- a/packages/math/src/tests/collatz_sequence_test.cairo +++ b/packages/math/src/tests/collatz_sequence_test.cairo @@ -3,17 +3,17 @@ use alexandria_math::collatz_sequence::sequence; #[test] #[available_gas(2000000)] fn collatz_sequence_10_test() { - assert_eq!(sequence(10).len(), 7, "invalid result"); + assert_eq!(sequence(10).len(), 7); } #[test] #[available_gas(2000000)] fn collatz_sequence_15_test() { - assert_eq!(sequence(15).len(), 18, "invalid result"); + assert_eq!(sequence(15).len(), 18); } #[test] #[available_gas(2000000)] fn collatz_sequence_empty_test() { - assert_eq!(sequence(0).len(), 0, "invalid result"); + assert_eq!(sequence(0).len(), 0); } diff --git a/packages/math/src/tests/extended_euclidean_algorithm_test.cairo b/packages/math/src/tests/extended_euclidean_algorithm_test.cairo index 9af38796..af5b4ca6 100644 --- a/packages/math/src/tests/extended_euclidean_algorithm_test.cairo +++ b/packages/math/src/tests/extended_euclidean_algorithm_test.cairo @@ -5,10 +5,10 @@ use core::num::traits::WrappingSub; fn test_case(a: u128, b: u128, expected: (u128, u128, u128)) { let (gcd, x, y) = extended_euclidean_algorithm(a, b); let (expected_gcd, expected_x, expected_y) = expected; - assert_eq!(gcd, expected_gcd, "gcd is incorrect"); + assert_eq!(gcd, expected_gcd); - assert_eq!(x, expected_x, "x is incorrect"); - assert_eq!(y, expected_y, "y is incorrect"); + assert_eq!(x, expected_x); + assert_eq!(y, expected_y); } #[test] diff --git a/packages/math/src/tests/fast_power_test.cairo b/packages/math/src/tests/fast_power_test.cairo index 4ac16292..d6af0bfc 100644 --- a/packages/math/src/tests/fast_power_test.cairo +++ b/packages/math/src/tests/fast_power_test.cairo @@ -3,14 +3,14 @@ use alexandria_math::fast_power::{fast_power, fast_power_mod}; #[test] #[available_gas(1000000000)] fn fast_power_test() { - assert_eq!(fast_power(2_u128, 1_u128), 2, "invalid result"); - assert_eq!(fast_power(2_u128, 2_u128), 4, "invalid result"); - assert_eq!(fast_power(2_u128, 3_u128), 8, "invalid result"); - assert_eq!(fast_power(3_u128, 4_u128), 81, "invalid result"); - assert_eq!(fast_power(2_u128, 100_u128), 0x10000000000000000000000000, "invalid result"); - assert_eq!(fast_power(2_u128, 127_u128), 0x80000000000000000000000000000000, "invalid result"); + assert_eq!(fast_power(2_u128, 1_u128), 2); + assert_eq!(fast_power(2_u128, 2_u128), 4); + assert_eq!(fast_power(2_u128, 3_u128), 8); + assert_eq!(fast_power(3_u128, 4_u128), 81); + assert_eq!(fast_power(2_u128, 100_u128), 0x10000000000000000000000000); + assert_eq!(fast_power(2_u128, 127_u128), 0x80000000000000000000000000000000); - assert_eq!(fast_power(2_u256, 128_u256), 0x100000000000000000000000000000000, "invalid result"); + assert_eq!(fast_power(2_u256, 128_u256), 0x100000000000000000000000000000000); assert_eq!( fast_power(2_u256, 255_u256), @@ -22,18 +22,18 @@ fn fast_power_test() { #[test] #[available_gas(1000000000)] fn fast_power_mod_test() { - assert_eq!(fast_power_mod(2_u128, 1_u128, 17_u128), 2, "invalid result"); - assert_eq!(fast_power_mod(2_u128, 2_u128, 17_u128), 4, "invalid result"); - assert_eq!(fast_power_mod(2_u128, 3_u128, 17_u128), 8, "invalid result"); - assert_eq!(fast_power_mod(3_u128, 4_u128, 17_u128), 13, "invalid result"); - assert_eq!(fast_power_mod(2_u128, 100_u128, 1000000007_u128), 976371285, "invalid result"); + assert_eq!(fast_power_mod(2_u128, 1_u128, 17_u128), 2); + assert_eq!(fast_power_mod(2_u128, 2_u128, 17_u128), 4); + assert_eq!(fast_power_mod(2_u128, 3_u128, 17_u128), 8); + assert_eq!(fast_power_mod(3_u128, 4_u128, 17_u128), 13); + assert_eq!(fast_power_mod(2_u128, 100_u128, 1000000007_u128), 976371285); assert_eq!( fast_power_mod(2_u128, 127_u128, 340282366920938463463374607431768211454_u128), 170141183460469231731687303715884105728 ); assert_eq!(fast_power_mod(2_u128, 127_u128, 34028236692093846346337460743176821144_u128), 8); - assert_eq!(fast_power_mod(2_u128, 128_u128, 9299_u128), 1412, "invalid result"); + assert_eq!(fast_power_mod(2_u128, 128_u128, 9299_u128), 1412); assert_eq!( fast_power_mod(2_u128, 88329_u128, 34028236692093846346337460743176821144_u128), diff --git a/packages/math/src/tests/fast_root_test.cairo b/packages/math/src/tests/fast_root_test.cairo index 565206f5..b12f8b93 100644 --- a/packages/math/src/tests/fast_root_test.cairo +++ b/packages/math/src/tests/fast_root_test.cairo @@ -5,29 +5,29 @@ use alexandria_math::fast_root::fast_sqrt; #[test] #[available_gas(5000000)] fn fast_sqrt_test_1() { - assert_eq!(fast_sqrt(100, 10), 10, "invalid result"); + assert_eq!(fast_sqrt(100, 10), 10); } #[test] #[available_gas(5000000)] fn fast_sqrt_test_2() { - assert_eq!(fast_sqrt(79, 10), 9, "invalid result"); + assert_eq!(fast_sqrt(79, 10), 9); } #[test] #[available_gas(5000000)] fn fast_curt_test_1() { - assert_eq!(fast_cbrt(1000, 10), 10, "invalid result"); + assert_eq!(fast_cbrt(1000, 10), 10); } #[test] #[available_gas(5000000)] fn fast_nr_optimize_test_1() { - assert_eq!(fast_nr_optimize(10000, 4, 30), 10, "invalid result"); + assert_eq!(fast_nr_optimize(10000, 4, 30), 10); } #[test] #[available_gas(5000000)] fn fast_nr_optimize_test_2() { - assert_eq!(fast_nr_optimize(10, 1, 10), 10, "invalid result"); + assert_eq!(fast_nr_optimize(10, 1, 10), 10); } diff --git a/packages/math/src/tests/fibonacci_test.cairo b/packages/math/src/tests/fibonacci_test.cairo index 03b3430a..3ec5c1cc 100644 --- a/packages/math/src/tests/fibonacci_test.cairo +++ b/packages/math/src/tests/fibonacci_test.cairo @@ -3,6 +3,6 @@ use alexandria_math::fibonacci::fib; #[test] #[available_gas(200000)] fn fibonacci_test() { - assert_eq!(fib(0, 1, 10), 55, "invalid result"); - assert_eq!(fib(2, 4, 8), 110, "invalid result"); + assert_eq!(fib(0, 1, 10), 55); + assert_eq!(fib(2, 4, 8), 110); } diff --git a/packages/math/src/tests/gcd_of_n_numbers_test.cairo b/packages/math/src/tests/gcd_of_n_numbers_test.cairo index 43293afd..25c6d8a7 100644 --- a/packages/math/src/tests/gcd_of_n_numbers_test.cairo +++ b/packages/math/src/tests/gcd_of_n_numbers_test.cairo @@ -4,21 +4,21 @@ use alexandria_math::gcd_of_n_numbers::gcd; #[available_gas(1000000000)] fn gcd_test() { let arr = array![2, 4, 6, 8, 10]; - assert_eq!(gcd(arr.span()), 2, "invalid result"); + assert_eq!(gcd(arr.span()), 2); } #[test] #[available_gas(1000000000)] fn gcd_test_inverse() { let arr = array![10, 8, 6, 4, 2]; - assert_eq!(gcd(arr.span()), 2, "invalid result"); + assert_eq!(gcd(arr.span()), 2); } #[test] #[available_gas(1000000000)] fn gcd_test_3() { let arr = array![3, 6, 12, 99]; - assert_eq!(gcd(arr.span()), 3, "invalid result"); + assert_eq!(gcd(arr.span()), 3); } @@ -26,7 +26,7 @@ fn gcd_test_3() { #[available_gas(1000000000)] fn gcd_single_test() { let arr = array![10]; - assert_eq!(gcd(arr.span()), 10, "invalid result"); + assert_eq!(gcd(arr.span()), 10); } #[test] diff --git a/packages/math/src/tests/i257_test.cairo b/packages/math/src/tests/i257_test.cairo index 2d5a732a..91a80804 100644 --- a/packages/math/src/tests/i257_test.cairo +++ b/packages/math/src/tests/i257_test.cairo @@ -7,35 +7,35 @@ fn i257_test_add() { let a = I257Impl::new(42, false); let b = I257Impl::new(13, false); let result = a + b; - assert_eq!(result.abs(), 55, "42 + 13 = 55"); + assert_eq!(result.abs(), 55); assert!(!result.is_negative(), "42 + 13 -> positive"); // Test addition of two negative integers let a = I257Impl::new(42, true); let b = I257Impl::new(13, true); let result = a + b; - assert_eq!(result.abs(), 55, "-42 - 13 = -55"); + assert_eq!(result.abs(), 55); assert!(result.is_negative(), "-42 - 13 -> negative"); // Test addition of a positive integer and a negative integer with the same magnitude let a = I257Impl::new(42, false); let b = I257Impl::new(42, true); let result = a + b; - assert_eq!(result.abs(), 0, "42 - 42 = 0"); + assert_eq!(result.abs(), 0); assert!(!result.is_negative(), "42 - 42 -> positive"); // Test addition of a positive integer and a negative integer with different magnitudes let a = I257Impl::new(42, false); let b = I257Impl::new(13, true); let result = a + b; - assert_eq!(result.abs(), 29, "42 - 13 = 29"); + assert_eq!(result.abs(), 29); assert!(!result.is_negative(), "42 - 13 -> positive"); // Test addition of a negative integer and a positive integer with different magnitudes let a = I257Impl::new(42, true); let b = I257Impl::new(13, false); let result = a + b; - assert_eq!(result.abs(), 29, "-42 + 13 = -29"); + assert_eq!(result.abs(), 29); assert!(result.is_negative(), "-42 + 13 -> negative"); } @@ -45,63 +45,63 @@ fn i257_test_sub() { let a = I257Impl::new(42, false); let b = I257Impl::new(13, false); let result = a - b; - assert_eq!(result.abs(), 29, "42 - 13 = 29"); + assert_eq!(result.abs(), 29); assert!(!result.is_negative(), "42 - 13 -> positive"); // Test subtraction of two positive integers with larger second let a = I257Impl::new(13, false); let b = I257Impl::new(42, false); let result = a - b; - assert_eq!(result.abs(), 29, "13 - 42 = -29"); + assert_eq!(result.abs(), 29); assert!(result.is_negative(), "13 - 42 -> negative"); // Test subtraction of two negative integers with larger first let a = I257Impl::new(42, true); let b = I257Impl::new(13, true); let result = a - b; - assert_eq!(result.abs(), 29, "-42 - -13 = 29"); + assert_eq!(result.abs(), 29); assert!(result.is_negative(), "-42 - -13 -> negative"); // Test subtraction of two negative integers with larger second let a = I257Impl::new(13, true); let b = I257Impl::new(42, true); let result = a - b; - assert_eq!(result.abs(), 29, "-13 - -42 = 29"); + assert_eq!(result.abs(), 29); assert!(!result.is_negative(), "-13 - -42 -> positive"); // Test subtraction of a positive integer and a negative integer with the same magnitude let a = I257Impl::new(42, false); let b = I257Impl::new(42, true); let result = a - b; - assert_eq!(result.abs(), 84, "42 - -42 = 84"); + assert_eq!(result.abs(), 84); assert!(!result.is_negative(), "42 - -42 -> postive"); // Test subtraction of a negative integer and a positive integer with the same magnitude let a = I257Impl::new(42, true); let b = I257Impl::new(42, false); let result = a - b; - assert_eq!(result.abs(), 84, "-42 - 42 = -84"); + assert_eq!(result.abs(), 84); assert!(result.is_negative(), "-42 - 42 -> negative"); // Test subtraction of a positive integer and a negative integer with different magnitudes let a = I257Impl::new(100, false); let b = I257Impl::new(42, true); let result = a - b; - assert_eq!(result.abs(), 142, "100 - - 42 = 142"); + assert_eq!(result.abs(), 142); assert!(!result.is_negative(), "100 - - 42 -> postive"); // Test subtraction of a negative integer and a positive integer with different magnitudes let a = I257Impl::new(42, true); let b = I257Impl::new(100, false); let result = a - b; - assert_eq!(result.abs(), 142, "-42 - 100 = -142"); + assert_eq!(result.abs(), 142); assert!(result.is_negative(), "-42 - 100 -> negative"); // Test subtraction resulting in zero let a = I257Impl::new(42, false); let b = I257Impl::new(42, false); let result = a - b; - assert_eq!(result.abs(), 0, "42 - 42 = 0"); + assert_eq!(result.abs(), 0); assert!(!result.is_negative(), "42 - 42 -> positive"); } @@ -112,28 +112,28 @@ fn i257_test_mul() { let a = I257Impl::new(10, false); let b = I257Impl::new(5, false); let result = a * b; - assert_eq!(result.abs(), 50, "10 * 5 = 50"); + assert_eq!(result.abs(), 50); assert!(!result.is_negative(), "10 * 5 -> positive"); // Test multiplication of negative integers let a = I257Impl::new(10, true); let b = I257Impl::new(5, true); let result = a * b; - assert_eq!(result.abs(), 50, "-10 * -5 = 50"); + assert_eq!(result.abs(), 50); assert!(!result.is_negative(), "-10 * -5 -> positive"); // Test multiplication of positive and negative integers let a = I257Impl::new(10, false); let b = I257Impl::new(5, true); let result = a * b; - assert_eq!(result.abs(), 50, "10 * -5 = -50"); + assert_eq!(result.abs(), 50); assert!(result.is_negative(), "10 * -5 -> negative"); // Test multiplication by zero let a = I257Impl::new(10, false); let b = I257Impl::new(0, false); let result = a * b; - assert_eq!(result.abs(), 0, "10 * 0 = 0"); + assert_eq!(result.abs(), 0); assert!(!result.is_negative(), "10 * 0 -> positive"); } @@ -149,35 +149,35 @@ fn i257_test_div_no_rem() { let a = I257Impl::new(10, false); let b = I257Impl::new(5, false); let result = a / b; - assert_eq!(result.abs(), 2, "10 // 5 = 2"); + assert_eq!(result.abs(), 2); assert!(!result.is_negative(), "10 // 5 -> positive"); // Test division of negative integers let a = I257Impl::new(10, true); let b = I257Impl::new(5, true); let result = a / b; - assert_eq!(result.abs(), 2, "-10 // -5 = 2"); + assert_eq!(result.abs(), 2); assert!(!result.is_negative(), "-10 // -5 -> positive"); // Test division of positive and negative integers let a = I257Impl::new(10, false); let b = I257Impl::new(5, true); let result = a / b; - assert_eq!(result.abs(), 2, "10 // -5 = -2"); + assert_eq!(result.abs(), 2); assert!(result.is_negative(), "10 // -5 -> negative"); // Test division with a = zero let a = I257Impl::new(0, false); let b = I257Impl::new(10, false); let result = a / b; - assert_eq!(result.abs(), 0, "0 // 10 = 0"); + assert_eq!(result.abs(), 0); assert!(!result.is_negative(), "0 // 10 -> positive"); // Test division with a = zero let a = I257Impl::new(0, false); let b = I257Impl::new(10, false); let result = a / b; - assert_eq!(result.abs(), 0, "0 // 10 = 0"); + assert_eq!(result.abs(), 0); assert!(!result.is_negative(), "0 // 10 -> positive"); } @@ -313,17 +313,17 @@ fn i257_test_equality() { #[test] fn i257_test_div_sign_zero() { let x = I257Impl::new(0, false) / I257Impl::new(3, true); - assert_eq!(x.abs(), 0, "incorrect abs"); + assert_eq!(x.abs(), 0); assert!(!x.is_negative(), "incorrect sign"); } #[test] fn i257_test_into() { let x: i257 = 35.into(); - assert_eq!(x.abs(), 35, "incorrect into value"); + assert_eq!(x.abs(), 35); assert!(!x.is_negative(), "incorrect into sign"); let y: i257 = 258973.into(); - assert_eq!(y.abs(), 258973, "incorrect into value"); + assert_eq!(y.abs(), 258973); assert!(!y.is_negative(), "incorrect into sign"); } diff --git a/packages/math/src/tests/is_power_of_two_test.cairo b/packages/math/src/tests/is_power_of_two_test.cairo index 2d421d6e..26f3ab2f 100644 --- a/packages/math/src/tests/is_power_of_two_test.cairo +++ b/packages/math/src/tests/is_power_of_two_test.cairo @@ -27,5 +27,5 @@ fn is_power_of_two_test_4() { #[test] #[available_gas(200000)] fn is_power_of_two_test_5() { - assert_eq!(is_power_of_two(0), false, "invalid result"); + assert_eq!(is_power_of_two(0), false); } diff --git a/packages/math/src/tests/karatsuba_test.cairo b/packages/math/src/tests/karatsuba_test.cairo index 6bd3b69b..1395ca1f 100644 --- a/packages/math/src/tests/karatsuba_test.cairo +++ b/packages/math/src/tests/karatsuba_test.cairo @@ -8,7 +8,7 @@ fn multiply_same_size_positive_number() { let n1 = 31415; let n2 = 31415; let result = 986902225; - assert_eq!(multiply(n1, n2), result, "invalid result"); + assert_eq!(multiply(n1, n2), result); } @@ -18,7 +18,7 @@ fn multiply_distinct_size_positive_number() { let n1 = 10296; let n2 = 25912511; let result = 266795213256; - assert_eq!(multiply(n1, n2), result, "invalid result"); + assert_eq!(multiply(n1, n2), result); } #[test] @@ -28,7 +28,7 @@ fn multiply_by_zero() { let n1 = 10296; let n2 = 0; let result = 0; - assert_eq!(multiply(n1, n2), result, "invalid result"); + assert_eq!(multiply(n1, n2), result); } #[test] @@ -37,5 +37,5 @@ fn multiply_by_number_lt_ten() { let n1 = 1000; let n2 = 2; let result = 2000; - assert_eq!(multiply(n1, n2), result, "invalid result"); + assert_eq!(multiply(n1, n2), result); } diff --git a/packages/math/src/tests/lcm_of_n_numbers_test.cairo b/packages/math/src/tests/lcm_of_n_numbers_test.cairo index 18ef27b0..265fdd77 100644 --- a/packages/math/src/tests/lcm_of_n_numbers_test.cairo +++ b/packages/math/src/tests/lcm_of_n_numbers_test.cairo @@ -12,35 +12,35 @@ impl u128_into_u32 of Into { #[available_gas(1000000000)] fn lcm_test() { let arr = array![2_u128, 4, 6, 8, 10]; - assert_eq!(lcm(arr.span()).unwrap(), 120, "invalid result"); + assert_eq!(lcm(arr.span()).unwrap(), 120); } #[test] #[available_gas(1000000000)] fn lcm_test_tryinto() { let arr = array![2_u32, 4, 6, 8, 10]; - assert_eq!(lcm(arr.span()).unwrap(), 120, "invalid result"); + assert_eq!(lcm(arr.span()).unwrap(), 120); } #[test] #[available_gas(1000000000)] fn lcm_test_inverse() { let arr = array![10_u128, 8, 6, 4, 2]; - assert_eq!(lcm(arr.span()).unwrap(), 120, "invalid result"); + assert_eq!(lcm(arr.span()).unwrap(), 120); } #[test] #[available_gas(1000000000)] fn lcm_test_3() { let arr = array![3_u128, 6, 12, 99]; - assert_eq!(lcm(arr.span()).unwrap(), 396, "invalid result"); + assert_eq!(lcm(arr.span()).unwrap(), 396); } #[test] #[available_gas(1000000000)] fn lcm_test_4() { let arr = array![1_u128, 2, 8, 3]; - assert_eq!(lcm(arr.span()).unwrap(), 24, "invalid result"); + assert_eq!(lcm(arr.span()).unwrap(), 24); } @@ -48,7 +48,7 @@ fn lcm_test_4() { #[available_gas(1000000000)] fn lcm_single_test() { let arr = array![10_u128]; - assert_eq!(lcm(arr.span()).unwrap(), 10, "invalid result"); + assert_eq!(lcm(arr.span()).unwrap(), 10); } #[test] diff --git a/packages/math/src/tests/math_test.cairo b/packages/math/src/tests/math_test.cairo index db81c9ba..f7a767f3 100644 --- a/packages/math/src/tests/math_test.cairo +++ b/packages/math/src/tests/math_test.cairo @@ -5,145 +5,145 @@ use core::num::traits::Bounded; #[test] #[available_gas(1000000000)] fn test_pow_power_2_all() { - assert_eq!(pow::(2, 0), 1, "0"); - assert_eq!(pow::(2, 1), 2, "1"); - assert_eq!(pow::(2, 2), 4, "2"); - assert_eq!(pow::(2, 3), 8, "3"); - assert_eq!(pow::(2, 4), 16, "4"); - assert_eq!(pow::(2, 5), 32, "5"); - assert_eq!(pow::(2, 6), 64, "6"); - assert_eq!(pow::(2, 7), 128, "7"); - assert_eq!(pow::(2, 8), 256, "8"); - assert_eq!(pow::(2, 9), 512, "9"); - assert_eq!(pow::(2, 10), 1024, "10"); - assert_eq!(pow::(2, 11), 2048, "11"); - assert_eq!(pow::(2, 12), 4096, "12"); - assert_eq!(pow::(2, 13), 8192, "13"); - assert_eq!(pow::(2, 14), 16384, "14"); - assert_eq!(pow::(2, 15), 32768, "15"); - assert_eq!(pow::(2, 16), 65536, "16"); - assert_eq!(pow::(2, 17), 131072, "17"); - assert_eq!(pow::(2, 18), 262144, "18"); - assert_eq!(pow::(2, 19), 524288, "19"); - assert_eq!(pow::(2, 20), 1048576, "20"); - assert_eq!(pow::(2, 21), 2097152, "21"); - assert_eq!(pow::(2, 22), 4194304, "22"); - assert_eq!(pow::(2, 23), 8388608, "23"); - assert_eq!(pow::(2, 24), 16777216, "24"); - assert_eq!(pow::(2, 25), 33554432, "25"); - assert_eq!(pow::(2, 26), 67108864, "26"); - assert_eq!(pow::(2, 27), 134217728, "27"); - assert_eq!(pow::(2, 28), 268435456, "28"); - assert_eq!(pow::(2, 29), 536870912, "29"); - assert_eq!(pow::(2, 30), 1073741824, "30"); - assert_eq!(pow::(2, 31), 2147483648, "31"); - assert_eq!(pow::(2, 32), 4294967296, "32"); - assert_eq!(pow::(2, 33), 8589934592, "33"); - assert_eq!(pow::(2, 34), 17179869184, "34"); - assert_eq!(pow::(2, 35), 34359738368, "35"); - assert_eq!(pow::(2, 36), 68719476736, "36"); - assert_eq!(pow::(2, 37), 137438953472, "37"); - assert_eq!(pow::(2, 38), 274877906944, "38"); - assert_eq!(pow::(2, 39), 549755813888, "39"); - assert_eq!(pow::(2, 40), 1099511627776, "40"); - assert_eq!(pow::(2, 41), 2199023255552, "41"); - assert_eq!(pow::(2, 42), 4398046511104, "42"); - assert_eq!(pow::(2, 43), 8796093022208, "43"); - assert_eq!(pow::(2, 44), 17592186044416, "44"); - assert_eq!(pow::(2, 45), 35184372088832, "45"); - assert_eq!(pow::(2, 46), 70368744177664, "46"); - assert_eq!(pow::(2, 47), 140737488355328, "47"); - assert_eq!(pow::(2, 48), 281474976710656, "48"); - assert_eq!(pow::(2, 49), 562949953421312, "49"); - assert_eq!(pow::(2, 50), 1125899906842624, "50"); - assert_eq!(pow::(2, 51), 2251799813685248, "51"); - assert_eq!(pow::(2, 52), 4503599627370496, "52"); - assert_eq!(pow::(2, 53), 9007199254740992, "53"); - assert_eq!(pow::(2, 54), 18014398509481984, "54"); - assert_eq!(pow::(2, 55), 36028797018963968, "55"); - assert_eq!(pow::(2, 56), 72057594037927936, "56"); - assert_eq!(pow::(2, 57), 144115188075855872, "57"); - assert_eq!(pow::(2, 58), 288230376151711744, "58"); - assert_eq!(pow::(2, 59), 576460752303423488, "59"); - assert_eq!(pow::(2, 60), 1152921504606846976, "60"); - assert_eq!(pow::(2, 61), 2305843009213693952, "61"); - assert_eq!(pow::(2, 62), 4611686018427387904, "62"); - assert_eq!(pow::(2, 63), 9223372036854775808, "63"); - assert_eq!(pow::(2, 64), 18446744073709551616, "64"); - assert_eq!(pow::(2, 65), 36893488147419103232, "65"); - assert_eq!(pow::(2, 66), 73786976294838206464, "66"); - assert_eq!(pow::(2, 67), 147573952589676412928, "67"); - assert_eq!(pow::(2, 68), 295147905179352825856, "68"); - assert_eq!(pow::(2, 69), 590295810358705651712, "69"); - assert_eq!(pow::(2, 70), 1180591620717411303424, "70"); - assert_eq!(pow::(2, 71), 2361183241434822606848, "71"); - assert_eq!(pow::(2, 72), 4722366482869645213696, "72"); - assert_eq!(pow::(2, 73), 9444732965739290427392, "73"); - assert_eq!(pow::(2, 74), 18889465931478580854784, "74"); - assert_eq!(pow::(2, 75), 37778931862957161709568, "75"); - assert_eq!(pow::(2, 76), 75557863725914323419136, "76"); - assert_eq!(pow::(2, 77), 151115727451828646838272, "77"); - assert_eq!(pow::(2, 78), 302231454903657293676544, "78"); - assert_eq!(pow::(2, 79), 604462909807314587353088, "79"); - assert_eq!(pow::(2, 80), 1208925819614629174706176, "80"); - assert_eq!(pow::(2, 81), 2417851639229258349412352, "81"); - assert_eq!(pow::(2, 82), 4835703278458516698824704, "82"); - assert_eq!(pow::(2, 83), 9671406556917033397649408, "83"); - assert_eq!(pow::(2, 84), 19342813113834066795298816, "84"); - assert_eq!(pow::(2, 85), 38685626227668133590597632, "85"); - assert_eq!(pow::(2, 86), 77371252455336267181195264, "86"); - assert_eq!(pow::(2, 87), 154742504910672534362390528, "87"); - assert_eq!(pow::(2, 88), 309485009821345068724781056, "88"); - assert_eq!(pow::(2, 89), 618970019642690137449562112, "89"); - assert_eq!(pow::(2, 90), 1237940039285380274899124224, "90"); - assert_eq!(pow::(2, 91), 2475880078570760549798248448, "91"); - assert_eq!(pow::(2, 92), 4951760157141521099596496896, "92"); - assert_eq!(pow::(2, 93), 9903520314283042199192993792, "93"); - assert_eq!(pow::(2, 94), 19807040628566084398385987584, "94"); - assert_eq!(pow::(2, 95), 39614081257132168796771975168, "95"); - assert_eq!(pow::(2, 96), 79228162514264337593543950336, "96"); - assert_eq!(pow::(2, 97), 158456325028528675187087900672, "97"); - assert_eq!(pow::(2, 98), 316912650057057350374175801344, "98"); - assert_eq!(pow::(2, 99), 633825300114114700748351602688, "99"); - assert_eq!(pow::(2, 100), 1267650600228229401496703205376, "100"); - assert_eq!(pow::(2, 101), 2535301200456458802993406410752, "101"); - assert_eq!(pow::(2, 102), 5070602400912917605986812821504, "102"); - assert_eq!(pow::(2, 103), 10141204801825835211973625643008, "103"); - assert_eq!(pow::(2, 104), 20282409603651670423947251286016, "104"); - assert_eq!(pow::(2, 105), 40564819207303340847894502572032, "105"); - assert_eq!(pow::(2, 106), 81129638414606681695789005144064, "106"); - assert_eq!(pow::(2, 107), 162259276829213363391578010288128, "107"); - assert_eq!(pow::(2, 108), 324518553658426726783156020576256, "108"); - assert_eq!(pow::(2, 109), 649037107316853453566312041152512, "109"); - assert_eq!(pow::(2, 110), 1298074214633706907132624082305024, "110"); - assert_eq!(pow::(2, 111), 2596148429267413814265248164610048, "111"); - assert_eq!(pow::(2, 112), 5192296858534827628530496329220096, "112"); - assert_eq!(pow::(2, 113), 10384593717069655257060992658440192, "113"); - assert_eq!(pow::(2, 114), 20769187434139310514121985316880384, "114"); - assert_eq!(pow::(2, 115), 41538374868278621028243970633760768, "115"); - assert_eq!(pow::(2, 116), 83076749736557242056487941267521536, "116"); - assert_eq!(pow::(2, 117), 166153499473114484112975882535043072, "117"); - assert_eq!(pow::(2, 118), 332306998946228968225951765070086144, "118"); - assert_eq!(pow::(2, 119), 664613997892457936451903530140172288, "119"); - assert_eq!(pow::(2, 120), 1329227995784915872903807060280344576, "120"); - assert_eq!(pow::(2, 121), 2658455991569831745807614120560689152, "121"); - assert_eq!(pow::(2, 122), 5316911983139663491615228241121378304, "122"); - assert_eq!(pow::(2, 123), 10633823966279326983230456482242756608, "123"); - assert_eq!(pow::(2, 124), 21267647932558653966460912964485513216, "124"); - assert_eq!(pow::(2, 125), 42535295865117307932921825928971026432, "125"); - assert_eq!(pow::(2, 126), 85070591730234615865843651857942052864, "126"); - assert_eq!(pow::(2, 127), 170141183460469231731687303715884105728, "127"); + assert_eq!(pow::(2, 0), 1); + assert_eq!(pow::(2, 1), 2); + assert_eq!(pow::(2, 2), 4); + assert_eq!(pow::(2, 3), 8); + assert_eq!(pow::(2, 4), 16); + assert_eq!(pow::(2, 5), 32); + assert_eq!(pow::(2, 6), 64); + assert_eq!(pow::(2, 7), 128); + assert_eq!(pow::(2, 8), 256); + assert_eq!(pow::(2, 9), 512); + assert_eq!(pow::(2, 10), 1024); + assert_eq!(pow::(2, 11), 2048); + assert_eq!(pow::(2, 12), 4096); + assert_eq!(pow::(2, 13), 8192); + assert_eq!(pow::(2, 14), 16384); + assert_eq!(pow::(2, 15), 32768); + assert_eq!(pow::(2, 16), 65536); + assert_eq!(pow::(2, 17), 131072); + assert_eq!(pow::(2, 18), 262144); + assert_eq!(pow::(2, 19), 524288); + assert_eq!(pow::(2, 20), 1048576); + assert_eq!(pow::(2, 21), 2097152); + assert_eq!(pow::(2, 22), 4194304); + assert_eq!(pow::(2, 23), 8388608); + assert_eq!(pow::(2, 24), 16777216); + assert_eq!(pow::(2, 25), 33554432); + assert_eq!(pow::(2, 26), 67108864); + assert_eq!(pow::(2, 27), 134217728); + assert_eq!(pow::(2, 28), 268435456); + assert_eq!(pow::(2, 29), 536870912); + assert_eq!(pow::(2, 30), 1073741824); + assert_eq!(pow::(2, 31), 2147483648); + assert_eq!(pow::(2, 32), 4294967296); + assert_eq!(pow::(2, 33), 8589934592); + assert_eq!(pow::(2, 34), 17179869184); + assert_eq!(pow::(2, 35), 34359738368); + assert_eq!(pow::(2, 36), 68719476736); + assert_eq!(pow::(2, 37), 137438953472); + assert_eq!(pow::(2, 38), 274877906944); + assert_eq!(pow::(2, 39), 549755813888); + assert_eq!(pow::(2, 40), 1099511627776); + assert_eq!(pow::(2, 41), 2199023255552); + assert_eq!(pow::(2, 42), 4398046511104); + assert_eq!(pow::(2, 43), 8796093022208); + assert_eq!(pow::(2, 44), 17592186044416); + assert_eq!(pow::(2, 45), 35184372088832); + assert_eq!(pow::(2, 46), 70368744177664); + assert_eq!(pow::(2, 47), 140737488355328); + assert_eq!(pow::(2, 48), 281474976710656); + assert_eq!(pow::(2, 49), 562949953421312); + assert_eq!(pow::(2, 50), 1125899906842624); + assert_eq!(pow::(2, 51), 2251799813685248); + assert_eq!(pow::(2, 52), 4503599627370496); + assert_eq!(pow::(2, 53), 9007199254740992); + assert_eq!(pow::(2, 54), 18014398509481984); + assert_eq!(pow::(2, 55), 36028797018963968); + assert_eq!(pow::(2, 56), 72057594037927936); + assert_eq!(pow::(2, 57), 144115188075855872); + assert_eq!(pow::(2, 58), 288230376151711744); + assert_eq!(pow::(2, 59), 576460752303423488); + assert_eq!(pow::(2, 60), 1152921504606846976); + assert_eq!(pow::(2, 61), 2305843009213693952); + assert_eq!(pow::(2, 62), 4611686018427387904); + assert_eq!(pow::(2, 63), 9223372036854775808); + assert_eq!(pow::(2, 64), 18446744073709551616); + assert_eq!(pow::(2, 65), 36893488147419103232); + assert_eq!(pow::(2, 66), 73786976294838206464); + assert_eq!(pow::(2, 67), 147573952589676412928); + assert_eq!(pow::(2, 68), 295147905179352825856); + assert_eq!(pow::(2, 69), 590295810358705651712); + assert_eq!(pow::(2, 70), 1180591620717411303424); + assert_eq!(pow::(2, 71), 2361183241434822606848); + assert_eq!(pow::(2, 72), 4722366482869645213696); + assert_eq!(pow::(2, 73), 9444732965739290427392); + assert_eq!(pow::(2, 74), 18889465931478580854784); + assert_eq!(pow::(2, 75), 37778931862957161709568); + assert_eq!(pow::(2, 76), 75557863725914323419136); + assert_eq!(pow::(2, 77), 151115727451828646838272); + assert_eq!(pow::(2, 78), 302231454903657293676544); + assert_eq!(pow::(2, 79), 604462909807314587353088); + assert_eq!(pow::(2, 80), 1208925819614629174706176); + assert_eq!(pow::(2, 81), 2417851639229258349412352); + assert_eq!(pow::(2, 82), 4835703278458516698824704); + assert_eq!(pow::(2, 83), 9671406556917033397649408); + assert_eq!(pow::(2, 84), 19342813113834066795298816); + assert_eq!(pow::(2, 85), 38685626227668133590597632); + assert_eq!(pow::(2, 86), 77371252455336267181195264); + assert_eq!(pow::(2, 87), 154742504910672534362390528); + assert_eq!(pow::(2, 88), 309485009821345068724781056); + assert_eq!(pow::(2, 89), 618970019642690137449562112); + assert_eq!(pow::(2, 90), 1237940039285380274899124224); + assert_eq!(pow::(2, 91), 2475880078570760549798248448); + assert_eq!(pow::(2, 92), 4951760157141521099596496896); + assert_eq!(pow::(2, 93), 9903520314283042199192993792); + assert_eq!(pow::(2, 94), 19807040628566084398385987584); + assert_eq!(pow::(2, 95), 39614081257132168796771975168); + assert_eq!(pow::(2, 96), 79228162514264337593543950336); + assert_eq!(pow::(2, 97), 158456325028528675187087900672); + assert_eq!(pow::(2, 98), 316912650057057350374175801344); + assert_eq!(pow::(2, 99), 633825300114114700748351602688); + assert_eq!(pow::(2, 100), 1267650600228229401496703205376); + assert_eq!(pow::(2, 101), 2535301200456458802993406410752); + assert_eq!(pow::(2, 102), 5070602400912917605986812821504); + assert_eq!(pow::(2, 103), 10141204801825835211973625643008); + assert_eq!(pow::(2, 104), 20282409603651670423947251286016); + assert_eq!(pow::(2, 105), 40564819207303340847894502572032); + assert_eq!(pow::(2, 106), 81129638414606681695789005144064); + assert_eq!(pow::(2, 107), 162259276829213363391578010288128); + assert_eq!(pow::(2, 108), 324518553658426726783156020576256); + assert_eq!(pow::(2, 109), 649037107316853453566312041152512); + assert_eq!(pow::(2, 110), 1298074214633706907132624082305024); + assert_eq!(pow::(2, 111), 2596148429267413814265248164610048); + assert_eq!(pow::(2, 112), 5192296858534827628530496329220096); + assert_eq!(pow::(2, 113), 10384593717069655257060992658440192); + assert_eq!(pow::(2, 114), 20769187434139310514121985316880384); + assert_eq!(pow::(2, 115), 41538374868278621028243970633760768); + assert_eq!(pow::(2, 116), 83076749736557242056487941267521536); + assert_eq!(pow::(2, 117), 166153499473114484112975882535043072); + assert_eq!(pow::(2, 118), 332306998946228968225951765070086144); + assert_eq!(pow::(2, 119), 664613997892457936451903530140172288); + assert_eq!(pow::(2, 120), 1329227995784915872903807060280344576); + assert_eq!(pow::(2, 121), 2658455991569831745807614120560689152); + assert_eq!(pow::(2, 122), 5316911983139663491615228241121378304); + assert_eq!(pow::(2, 123), 10633823966279326983230456482242756608); + assert_eq!(pow::(2, 124), 21267647932558653966460912964485513216); + assert_eq!(pow::(2, 125), 42535295865117307932921825928971026432); + assert_eq!(pow::(2, 126), 85070591730234615865843651857942052864); + assert_eq!(pow::(2, 127), 170141183460469231731687303715884105728); } #[test] #[available_gas(2000000)] fn pow_test() { - assert_eq!(pow::(200, 0), 1, "200^0"); - assert_eq!(pow::(5, 9), 1953125, "5^9"); - assert_eq!(pow::(14, 30), 24201432355484595421941037243826176, "14^30"); - assert_eq!(pow::(3, 8), 6561, "3^8_u128"); - assert_eq!(pow::(3, 8), 6561, "3^8_u256"); + assert_eq!(pow::(200, 0), 1); + assert_eq!(pow::(5, 9), 1953125); + assert_eq!(pow::(14, 30), 24201432355484595421941037243826176); + assert_eq!(pow::(3, 8), 6561); + assert_eq!(pow::(3, 8), 6561); } @@ -151,52 +151,52 @@ fn pow_test() { #[test] #[available_gas(2000000)] fn count_digits_of_base_test() { - assert_eq!(count_digits_of_base(0, 10), 0, "invalid result"); - assert_eq!(count_digits_of_base(2, 10), 1, "invalid result"); - assert_eq!(count_digits_of_base(10, 10), 2, "invalid result"); - assert_eq!(count_digits_of_base(100, 10), 3, "invalid result"); - assert_eq!(count_digits_of_base(0x80, 16), 2, "invalid result"); - assert_eq!(count_digits_of_base(0x800, 16), 3, "invalid result"); - assert_eq!(count_digits_of_base(0x888888888888888888, 16), 18, "invalid result"); + assert_eq!(count_digits_of_base(0, 10), 0); + assert_eq!(count_digits_of_base(2, 10), 1); + assert_eq!(count_digits_of_base(10, 10), 2); + assert_eq!(count_digits_of_base(100, 10), 3); + assert_eq!(count_digits_of_base(0x80, 16), 2); + assert_eq!(count_digits_of_base(0x800, 16), 3); + assert_eq!(count_digits_of_base(0x888888888888888888, 16), 18); } #[test] #[available_gas(2000000)] fn shl_should_not_overflow() { - assert_eq!(BitShift::shl(pow::(2, 7), 1), 0, "invalid result"); - assert_eq!(BitShift::shl(pow::(2, 15), 1), 0, "invalid result"); - assert_eq!(BitShift::shl(pow::(2, 31), 1), 0, "invalid result"); - assert_eq!(BitShift::shl(pow::(2, 63), 1), 0, "invalid result"); - assert_eq!(BitShift::shl(pow::(2, 127), 1), 0, "invalid result"); - assert_eq!(BitShift::shl(pow::(2, 255), 1), 0, "invalid result"); + assert_eq!(BitShift::shl(pow::(2, 7), 1), 0); + assert_eq!(BitShift::shl(pow::(2, 15), 1), 0); + assert_eq!(BitShift::shl(pow::(2, 31), 1), 0); + assert_eq!(BitShift::shl(pow::(2, 63), 1), 0); + assert_eq!(BitShift::shl(pow::(2, 127), 1), 0); + assert_eq!(BitShift::shl(pow::(2, 255), 1), 0); } #[test] #[available_gas(3000000)] fn test_rotl_min() { - assert_eq!(BitRotate::rotate_left(pow::(2, 7) + 1, 1), 3, "invalid result"); - assert_eq!(BitRotate::rotate_left(pow::(2, 15) + 1, 1), 3, "invalid result"); - assert_eq!(BitRotate::rotate_left(pow::(2, 31) + 1, 1), 3, "invalid result"); - assert_eq!(BitRotate::rotate_left(pow::(2, 63) + 1, 1), 3, "invalid result"); - assert_eq!(BitRotate::rotate_left(pow::(2, 127) + 1, 1), 3, "invalid result"); - assert_eq!(BitRotate::rotate_left(pow::(2, 255) + 1, 1), 3, "invalid result"); + assert_eq!(BitRotate::rotate_left(pow::(2, 7) + 1, 1), 3); + assert_eq!(BitRotate::rotate_left(pow::(2, 15) + 1, 1), 3); + assert_eq!(BitRotate::rotate_left(pow::(2, 31) + 1, 1), 3); + assert_eq!(BitRotate::rotate_left(pow::(2, 63) + 1, 1), 3); + assert_eq!(BitRotate::rotate_left(pow::(2, 127) + 1, 1), 3); + assert_eq!(BitRotate::rotate_left(pow::(2, 255) + 1, 1), 3); } #[test] #[available_gas(3000000)] fn test_rotl_max() { - assert_eq!(BitRotate::rotate_left(0b101, 7), pow::(2, 7) + 0b10, "invalid result"); - assert_eq!(BitRotate::rotate_left(0b101, 15), pow::(2, 15) + 0b10, "invalid result"); - assert_eq!(BitRotate::rotate_left(0b101, 31), pow::(2, 31) + 0b10, "invalid result"); - assert_eq!(BitRotate::rotate_left(0b101, 63), pow::(2, 63) + 0b10, "invalid result"); - assert_eq!(BitRotate::rotate_left(0b101, 127), pow::(2, 127) + 0b10, "invalid result"); - assert_eq!(BitRotate::rotate_left(0b101, 255), pow::(2, 255) + 0b10, "invalid result"); + assert_eq!(BitRotate::rotate_left(0b101, 7), pow::(2, 7) + 0b10); + assert_eq!(BitRotate::rotate_left(0b101, 15), pow::(2, 15) + 0b10); + assert_eq!(BitRotate::rotate_left(0b101, 31), pow::(2, 31) + 0b10); + assert_eq!(BitRotate::rotate_left(0b101, 63), pow::(2, 63) + 0b10); + assert_eq!(BitRotate::rotate_left(0b101, 127), pow::(2, 127) + 0b10); + assert_eq!(BitRotate::rotate_left(0b101, 255), pow::(2, 255) + 0b10); } #[test] #[available_gas(4000000)] fn test_rotr_min() { - assert_eq!(BitRotate::rotate_right(pow::(2, 7) + 1, 1), 0b11 * pow(2, 6), "invalid result"); + assert_eq!(BitRotate::rotate_right(pow::(2, 7) + 1, 1), 0b11 * pow(2, 6)); assert_eq!(BitRotate::rotate_right(pow::(2, 15) + 1, 1), 0b11 * pow(2, 14)); assert_eq!(BitRotate::rotate_right(pow::(2, 31) + 1, 1), 0b11 * pow(2, 30)); assert_eq!(BitRotate::rotate_right(pow::(2, 63) + 1, 1), 0b11 * pow(2, 62)); @@ -207,12 +207,12 @@ fn test_rotr_min() { #[test] #[available_gas(2000000)] fn test_rotr_max() { - assert_eq!(BitRotate::rotate_right(0b101_u8, 7), 0b1010, "invalid result"); - assert_eq!(BitRotate::rotate_right(0b101_u16, 15), 0b1010, "invalid result"); - assert_eq!(BitRotate::rotate_right(0b101_u32, 31), 0b1010, "invalid result"); - assert_eq!(BitRotate::rotate_right(0b101_u64, 63), 0b1010, "invalid result"); - assert_eq!(BitRotate::rotate_right(0b101_u128, 127), 0b1010, "invalid result"); - assert_eq!(BitRotate::rotate_right(0b101_u256, 255), 0b1010, "invalid result"); + assert_eq!(BitRotate::rotate_right(0b101_u8, 7), 0b1010); + assert_eq!(BitRotate::rotate_right(0b101_u16, 15), 0b1010); + assert_eq!(BitRotate::rotate_right(0b101_u32, 31), 0b1010); + assert_eq!(BitRotate::rotate_right(0b101_u64, 63), 0b1010); + assert_eq!(BitRotate::rotate_right(0b101_u128, 127), 0b1010); + assert_eq!(BitRotate::rotate_right(0b101_u256, 255), 0b1010); } #[test] diff --git a/packages/math/src/tests/mod_arithmetics_test.cairo b/packages/math/src/tests/mod_arithmetics_test.cairo index 2a71111c..e71176fd 100644 --- a/packages/math/src/tests/mod_arithmetics_test.cairo +++ b/packages/math/src/tests/mod_arithmetics_test.cairo @@ -12,113 +12,113 @@ const pow_256_minus_1: u256 = fn add_mod_p_test() { let prime_non_zero = p.try_into().unwrap(); - assert_eq!(add_mod(p, p, prime_non_zero), 0, "Incorrect result"); - assert_eq!(add_mod(p, 1, prime_non_zero), 1, "Incorrect result"); - assert_eq!(add_mod(1, p, prime_non_zero), 1, "Incorrect result"); - assert_eq!(add_mod(10, 30, prime_non_zero), 40, "Incorrect result"); - assert_eq!(add_mod(0, 0, prime_non_zero), 0, "Incorrect result"); - assert_eq!(add_mod(0, 1, prime_non_zero), 1, "Incorrect result"); - assert_eq!(add_mod(1, 0, prime_non_zero), 1, "Incorrect result"); + assert_eq!(add_mod(p, p, prime_non_zero), 0); + assert_eq!(add_mod(p, 1, prime_non_zero), 1); + assert_eq!(add_mod(1, p, prime_non_zero), 1); + assert_eq!(add_mod(10, 30, prime_non_zero), 40); + assert_eq!(add_mod(0, 0, prime_non_zero), 0); + assert_eq!(add_mod(0, 1, prime_non_zero), 1); + assert_eq!(add_mod(1, 0, prime_non_zero), 1); } #[test] #[available_gas(500000000)] fn add_mod_2_test() { - assert_eq!(add_mod(p, 2, 2), 1, "Incorrect result"); - assert_eq!(add_mod(p, 1, 2), 0, "Incorrect result"); + assert_eq!(add_mod(p, 2, 2), 1); + assert_eq!(add_mod(p, 1, 2), 0); } #[test] #[available_gas(500000000)] fn add_mod_1_test() { - assert_eq!(add_mod(p, 2, 1), 0, "Incorrect result"); - assert_eq!(add_mod(p, p, 1), 0, "Incorrect result"); - assert_eq!(add_mod(0, 0, 1), 0, "Incorrect result"); + assert_eq!(add_mod(p, 2, 1), 0); + assert_eq!(add_mod(p, p, 1), 0); + assert_eq!(add_mod(0, 0, 1), 0); } #[test] #[available_gas(500000000)] fn sub_mod_test() { - assert_eq!(sub_mod(p, p, p), 0, "Incorrect result"); - assert_eq!(sub_mod(p, 1, p), (p - 1), "Incorrect result"); - assert_eq!(sub_mod(1, p, p), 1, "Incorrect result"); - assert_eq!(sub_mod(10, 30, p), (p - 30 + 10), "Incorrect result"); - assert_eq!(sub_mod(0, 0, p), 0, "Incorrect result"); - assert_eq!(sub_mod(0, 1, p), (p - 1), "Incorrect result"); - assert_eq!(sub_mod(1, 0, p), 1, "Incorrect result"); - assert_eq!(sub_mod(pow_256_minus_1, 1, p), 36, "Incorrect result"); + assert_eq!(sub_mod(p, p, p), 0); + assert_eq!(sub_mod(p, 1, p), (p - 1)); + assert_eq!(sub_mod(1, p, p), 1); + assert_eq!(sub_mod(10, 30, p), (p - 30 + 10)); + assert_eq!(sub_mod(0, 0, p), 0); + assert_eq!(sub_mod(0, 1, p), (p - 1)); + assert_eq!(sub_mod(1, 0, p), 1); + assert_eq!(sub_mod(pow_256_minus_1, 1, p), 36); } #[test] #[available_gas(500000000)] fn sub_mod_1_test() { - assert_eq!(sub_mod(p, p, 1), 0, "Incorrect result"); - assert_eq!(sub_mod(p, 1, 1), 0, "Incorrect result"); - assert_eq!(sub_mod(1, p, 1), 0, "Incorrect result"); - assert_eq!(sub_mod(10, 30, 1), 0, "Incorrect result"); - assert_eq!(sub_mod(0, 0, 1), 0, "Incorrect result"); - assert_eq!(sub_mod(0, 1, 1), 0, "Incorrect result"); - assert_eq!(sub_mod(1, 0, 1), 0, "Incorrect result"); - assert_eq!(sub_mod(pow_256_minus_1, 1, 1), 0, "Incorrect result"); + assert_eq!(sub_mod(p, p, 1), 0); + assert_eq!(sub_mod(p, 1, 1), 0); + assert_eq!(sub_mod(1, p, 1), 0); + assert_eq!(sub_mod(10, 30, 1), 0); + assert_eq!(sub_mod(0, 0, 1), 0); + assert_eq!(sub_mod(0, 1, 1), 0); + assert_eq!(sub_mod(1, 0, 1), 0); + assert_eq!(sub_mod(pow_256_minus_1, 1, 1), 0); } #[test] #[available_gas(500000000)] fn sub_mod_2_test() { - assert_eq!(sub_mod(p, p, 2), 0, "Incorrect result"); - assert_eq!(sub_mod(p, 1, 2), 0, "Incorrect result"); - assert_eq!(sub_mod(1, p, 2), 0, "Incorrect result"); - assert_eq!(sub_mod(10, 30, 2), 0, "Incorrect result"); - assert_eq!(sub_mod(0, 0, 2), 0, "Incorrect result"); - assert_eq!(sub_mod(0, 1, 2), 1, "Incorrect result"); - assert_eq!(sub_mod(1, 0, 2), 1, "Incorrect result"); - assert_eq!(sub_mod(pow_256_minus_1, 1, 2), 0, "Incorrect result"); + assert_eq!(sub_mod(p, p, 2), 0); + assert_eq!(sub_mod(p, 1, 2), 0); + assert_eq!(sub_mod(1, p, 2), 0); + assert_eq!(sub_mod(10, 30, 2), 0); + assert_eq!(sub_mod(0, 0, 2), 0); + assert_eq!(sub_mod(0, 1, 2), 1); + assert_eq!(sub_mod(1, 0, 2), 1); + assert_eq!(sub_mod(pow_256_minus_1, 1, 2), 0); } #[test] #[available_gas(500000000)] fn mult_mod_test() { let prime_non_zero = p.try_into().unwrap(); - assert_eq!(mult_mod(p, p, prime_non_zero), 0, "Incorrect result"); - assert_eq!(mult_mod(p, 1, prime_non_zero), 0, "Incorrect result"); - assert_eq!(mult_mod(1, p, prime_non_zero), 0, "Incorrect result"); - assert_eq!(mult_mod(10, 30, prime_non_zero), 300, "Incorrect result"); - assert_eq!(mult_mod(0, 0, prime_non_zero), 0, "Incorrect result"); - assert_eq!(mult_mod(0, 1, prime_non_zero), 0, "Incorrect result"); - assert_eq!(mult_mod(1, 0, prime_non_zero), 0, "Incorrect result"); - assert_eq!(mult_mod(pow_256_minus_1, 1, prime_non_zero), 37, "Incorrect result"); + assert_eq!(mult_mod(p, p, prime_non_zero), 0); + assert_eq!(mult_mod(p, 1, prime_non_zero), 0); + assert_eq!(mult_mod(1, p, prime_non_zero), 0); + assert_eq!(mult_mod(10, 30, prime_non_zero), 300); + assert_eq!(mult_mod(0, 0, prime_non_zero), 0); + assert_eq!(mult_mod(0, 1, prime_non_zero), 0); + assert_eq!(mult_mod(1, 0, prime_non_zero), 0); + assert_eq!(mult_mod(pow_256_minus_1, 1, prime_non_zero), 37); } #[test] #[available_gas(500000000)] fn mult_mod_1_test() { - assert_eq!(mult_mod(p, p, 1), 0, "Incorrect result"); - assert_eq!(mult_mod(p, 1, 1), 0, "Incorrect result"); - assert_eq!(mult_mod(1, p, 1), 0, "Incorrect result"); - assert_eq!(mult_mod(10, 30, 1), 0, "Incorrect result"); - assert_eq!(mult_mod(0, 0, 1), 0, "Incorrect result"); - assert_eq!(mult_mod(0, 1, 1), 0, "Incorrect result"); - assert_eq!(mult_mod(1, 0, 1), 0, "Incorrect result"); - assert_eq!(mult_mod(pow_256_minus_1, 1, 1), 0, "Incorrect result"); + assert_eq!(mult_mod(p, p, 1), 0); + assert_eq!(mult_mod(p, 1, 1), 0); + assert_eq!(mult_mod(1, p, 1), 0); + assert_eq!(mult_mod(10, 30, 1), 0); + assert_eq!(mult_mod(0, 0, 1), 0); + assert_eq!(mult_mod(0, 1, 1), 0); + assert_eq!(mult_mod(1, 0, 1), 0); + assert_eq!(mult_mod(pow_256_minus_1, 1, 1), 0); } #[test] #[available_gas(500000000)] fn mult_mod_2_test() { - assert_eq!(mult_mod(p, p, 2), 1, "Incorrect result"); - assert_eq!(mult_mod(p, 1, 2), 1, "Incorrect result"); - assert_eq!(mult_mod(1, p, 2), 1, "Incorrect result"); - assert_eq!(mult_mod(10, 30, 2), 0, "Incorrect result"); - assert_eq!(mult_mod(0, 0, 2), 0, "Incorrect result"); - assert_eq!(mult_mod(0, 1, 2), 0, "Incorrect result"); - assert_eq!(mult_mod(1, 0, 2), 0, "Incorrect result"); - assert_eq!(mult_mod(pow_256_minus_1, 1, 2), 1, "Incorrect result"); + assert_eq!(mult_mod(p, p, 2), 1); + assert_eq!(mult_mod(p, 1, 2), 1); + assert_eq!(mult_mod(1, p, 2), 1); + assert_eq!(mult_mod(10, 30, 2), 0); + assert_eq!(mult_mod(0, 0, 2), 0); + assert_eq!(mult_mod(0, 1, 2), 0); + assert_eq!(mult_mod(1, 0, 2), 0); + assert_eq!(mult_mod(pow_256_minus_1, 1, 2), 1); } #[test] #[available_gas(500000000)] fn sqr_mod_test() { - assert_eq!(sqr_mod(p, 2), 1, "Incorrect result"); + assert_eq!(sqr_mod(p, 2), 1); assert_eq!( sqr_mod(p, pow_256_minus_1.try_into().unwrap()), mult_mod(p, p, pow_256_minus_1.try_into().unwrap()), @@ -137,44 +137,44 @@ fn div_mod_test() { let prime_non_zero = p.try_into().unwrap(); let div_10_30_mod_p = 38597363079105398474523661669562635951089994888546854679819194669304376546633; - assert_eq!(div_mod(p, 1, prime_non_zero), 0, "Incorrect result"); - assert_eq!(div_mod(30, 10, prime_non_zero), 3, "Incorrect result"); - assert_eq!(div_mod(10, 30, prime_non_zero), div_10_30_mod_p, "Incorrect result"); + assert_eq!(div_mod(p, 1, prime_non_zero), 0); + assert_eq!(div_mod(30, 10, prime_non_zero), 3); + assert_eq!(div_mod(10, 30, prime_non_zero), div_10_30_mod_p); } #[test] #[available_gas(500000000)] fn pow_mod_test() { let prime_non_zero = p.try_into().unwrap(); - assert_eq!(pow_mod(2, 4, prime_non_zero), 16, "Incorrect result"); - assert_eq!(pow_mod(2, 256, prime_non_zero), 38, "Incorrect result"); - assert_eq!(pow_mod(2, 260, prime_non_zero), 608, "Incorrect result"); + assert_eq!(pow_mod(2, 4, prime_non_zero), 16); + assert_eq!(pow_mod(2, 256, prime_non_zero), 38); + assert_eq!(pow_mod(2, 260, prime_non_zero), 608); assert_eq!( pow_mod(10, 260, prime_non_zero), 17820046977743035104984469918379927979184337110507416960697246160624073120874 ); - assert_eq!(pow_mod(4, 174, prime_non_zero), 188166885971377801784666882048, "Incorrect result"); - assert_eq!(pow_mod(100, p, prime_non_zero), 100, "Incorrect result"); + assert_eq!(pow_mod(4, 174, prime_non_zero), 188166885971377801784666882048); + assert_eq!(pow_mod(100, p, prime_non_zero), 100); } #[test] #[available_gas(500000000)] fn pow_mod_1_test() { - assert_eq!(pow_mod(2, 4, 1), 0, "Incorrect result"); - assert_eq!(pow_mod(2, 256, 1), 0, "Incorrect result"); - assert_eq!(pow_mod(2, 260, 1), 0, "Incorrect result"); - assert_eq!(pow_mod(10, 260, 1), 0, "Incorrect result"); - assert_eq!(pow_mod(4, 174, 1), 0, "Incorrect result"); - assert_eq!(pow_mod(100, p, 1), 0, "Incorrect result"); + assert_eq!(pow_mod(2, 4, 1), 0); + assert_eq!(pow_mod(2, 256, 1), 0); + assert_eq!(pow_mod(2, 260, 1), 0); + assert_eq!(pow_mod(10, 260, 1), 0); + assert_eq!(pow_mod(4, 174, 1), 0); + assert_eq!(pow_mod(100, p, 1), 0); } #[test] #[available_gas(500000000)] fn pow_mod_2_test() { - assert_eq!(pow_mod(2, 4, 2), 0, "Incorrect result"); - assert_eq!(pow_mod(2, 256, 2), 0, "Incorrect result"); - assert_eq!(pow_mod(2, 260, 2), 0, "Incorrect result"); - assert_eq!(pow_mod(10, 260, 2), 0, "Incorrect result"); - assert_eq!(pow_mod(4, 174, 2), 0, "Incorrect result"); - assert_eq!(pow_mod(100, p, 2), 0, "Incorrect result"); + assert_eq!(pow_mod(2, 4, 2), 0); + assert_eq!(pow_mod(2, 256, 2), 0); + assert_eq!(pow_mod(2, 260, 2), 0); + assert_eq!(pow_mod(10, 260, 2), 0); + assert_eq!(pow_mod(4, 174, 2), 0); + assert_eq!(pow_mod(100, p, 2), 0); } diff --git a/packages/math/src/tests/perfect_number_test.cairo b/packages/math/src/tests/perfect_number_test.cairo index 10f2dd71..c38d6c72 100644 --- a/packages/math/src/tests/perfect_number_test.cairo +++ b/packages/math/src/tests/perfect_number_test.cairo @@ -32,5 +32,5 @@ fn not_perfect_big_number_test() { #[available_gas(2000000)] fn perfect_numbers_test() { let mut res = perfect_numbers(10); - assert_eq!(res.len(), 1, "invalid result"); + assert_eq!(res.len(), 1); } diff --git a/packages/math/src/tests/sha256_test.cairo b/packages/math/src/tests/sha256_test.cairo index 765ba7c7..b3a1f04c 100644 --- a/packages/math/src/tests/sha256_test.cairo +++ b/packages/math/src/tests/sha256_test.cairo @@ -7,39 +7,39 @@ fn sha256_empty_test() { let result = sha256::sha256(input); // result should be 0xE3B0C44298FC1C149AFBF4C8996FB92427AE41E4649B934CA495991B7852B855 - assert_eq!(result.len(), 32, "invalid result length"); - assert_eq!(*result[0], 0xE3, "invalid result"); - assert_eq!(*result[1], 0xB0, "invalid result"); - assert_eq!(*result[2], 0xC4, "invalid result"); - assert_eq!(*result[3], 0x42, "invalid result"); - assert_eq!(*result[4], 0x98, "invalid result"); - assert_eq!(*result[5], 0xFC, "invalid result"); - assert_eq!(*result[6], 0x1C, "invalid result"); - assert_eq!(*result[7], 0x14, "invalid result"); - assert_eq!(*result[8], 0x9A, "invalid result"); - assert_eq!(*result[9], 0xFB, "invalid result"); - assert_eq!(*result[10], 0xF4, "invalid result"); - assert_eq!(*result[11], 0xC8, "invalid result"); - assert_eq!(*result[12], 0x99, "invalid result"); - assert_eq!(*result[13], 0x6F, "invalid result"); - assert_eq!(*result[14], 0xB9, "invalid result"); - assert_eq!(*result[15], 0x24, "invalid result"); - assert_eq!(*result[16], 0x27, "invalid result"); - assert_eq!(*result[17], 0xAE, "invalid result"); - assert_eq!(*result[18], 0x41, "invalid result"); - assert_eq!(*result[19], 0xE4, "invalid result"); - assert_eq!(*result[20], 0x64, "invalid result"); - assert_eq!(*result[21], 0x9B, "invalid result"); - assert_eq!(*result[22], 0x93, "invalid result"); - assert_eq!(*result[23], 0x4C, "invalid result"); - assert_eq!(*result[24], 0xA4, "invalid result"); - assert_eq!(*result[25], 0x95, "invalid result"); - assert_eq!(*result[26], 0x99, "invalid result"); - assert_eq!(*result[27], 0x1B, "invalid result"); - assert_eq!(*result[28], 0x78, "invalid result"); - assert_eq!(*result[29], 0x52, "invalid result"); - assert_eq!(*result[30], 0xB8, "invalid result"); - assert_eq!(*result[31], 0x55, "invalid result"); + assert_eq!(result.len(), 32); + assert_eq!(*result[0], 0xE3); + assert_eq!(*result[1], 0xB0); + assert_eq!(*result[2], 0xC4); + assert_eq!(*result[3], 0x42); + assert_eq!(*result[4], 0x98); + assert_eq!(*result[5], 0xFC); + assert_eq!(*result[6], 0x1C); + assert_eq!(*result[7], 0x14); + assert_eq!(*result[8], 0x9A); + assert_eq!(*result[9], 0xFB); + assert_eq!(*result[10], 0xF4); + assert_eq!(*result[11], 0xC8); + assert_eq!(*result[12], 0x99); + assert_eq!(*result[13], 0x6F); + assert_eq!(*result[14], 0xB9); + assert_eq!(*result[15], 0x24); + assert_eq!(*result[16], 0x27); + assert_eq!(*result[17], 0xAE); + assert_eq!(*result[18], 0x41); + assert_eq!(*result[19], 0xE4); + assert_eq!(*result[20], 0x64); + assert_eq!(*result[21], 0x9B); + assert_eq!(*result[22], 0x93); + assert_eq!(*result[23], 0x4C); + assert_eq!(*result[24], 0xA4); + assert_eq!(*result[25], 0x95); + assert_eq!(*result[26], 0x99); + assert_eq!(*result[27], 0x1B); + assert_eq!(*result[28], 0x78); + assert_eq!(*result[29], 0x52); + assert_eq!(*result[30], 0xB8); + assert_eq!(*result[31], 0x55); } #[test] @@ -49,38 +49,38 @@ fn sha256_random_data_test() { 0x57, 0x77, 0x71, 0x71, 0x66, 0x50, 0x45, 0x51, 0x51, 0x43, 0x39, 0x48, 0x38 ]; let result = sha256::sha256(input); - assert_eq!(*result[0], 61, "invalid result"); - assert_eq!(*result[1], 226, "invalid result"); - assert_eq!(*result[2], 188, "invalid result"); - assert_eq!(*result[3], 242, "invalid result"); - assert_eq!(*result[4], 118, "invalid result"); - assert_eq!(*result[5], 121, "invalid result"); - assert_eq!(*result[6], 7, "invalid result"); - assert_eq!(*result[7], 225, "invalid result"); - assert_eq!(*result[8], 150, "invalid result"); - assert_eq!(*result[9], 220, "invalid result"); - assert_eq!(*result[10], 105, "invalid result"); - assert_eq!(*result[11], 158, "invalid result"); - assert_eq!(*result[12], 185, "invalid result"); - assert_eq!(*result[13], 180, "invalid result"); - assert_eq!(*result[14], 139, "invalid result"); - assert_eq!(*result[15], 103, "invalid result"); - assert_eq!(*result[16], 221, "invalid result"); - assert_eq!(*result[17], 95, "invalid result"); - assert_eq!(*result[18], 56, "invalid result"); - assert_eq!(*result[19], 88, "invalid result"); - assert_eq!(*result[20], 209, "invalid result"); - assert_eq!(*result[21], 159, "invalid result"); - assert_eq!(*result[22], 255, "invalid result"); - assert_eq!(*result[23], 247, "invalid result"); - assert_eq!(*result[24], 145, "invalid result"); - assert_eq!(*result[25], 146, "invalid result"); - assert_eq!(*result[26], 83, "invalid result"); - assert_eq!(*result[27], 110, "invalid result"); - assert_eq!(*result[28], 185, "invalid result"); - assert_eq!(*result[29], 5, "invalid result"); - assert_eq!(*result[30], 248, "invalid result"); - assert_eq!(*result[31], 15, "invalid result"); + assert_eq!(*result[0], 61); + assert_eq!(*result[1], 226); + assert_eq!(*result[2], 188); + assert_eq!(*result[3], 242); + assert_eq!(*result[4], 118); + assert_eq!(*result[5], 121); + assert_eq!(*result[6], 7); + assert_eq!(*result[7], 225); + assert_eq!(*result[8], 150); + assert_eq!(*result[9], 220); + assert_eq!(*result[10], 105); + assert_eq!(*result[11], 158); + assert_eq!(*result[12], 185); + assert_eq!(*result[13], 180); + assert_eq!(*result[14], 139); + assert_eq!(*result[15], 103); + assert_eq!(*result[16], 221); + assert_eq!(*result[17], 95); + assert_eq!(*result[18], 56); + assert_eq!(*result[19], 88); + assert_eq!(*result[20], 209); + assert_eq!(*result[21], 159); + assert_eq!(*result[22], 255); + assert_eq!(*result[23], 247); + assert_eq!(*result[24], 145); + assert_eq!(*result[25], 146); + assert_eq!(*result[26], 83); + assert_eq!(*result[27], 110); + assert_eq!(*result[28], 185); + assert_eq!(*result[29], 5); + assert_eq!(*result[30], 248); + assert_eq!(*result[31], 15); } #[test] @@ -417,39 +417,39 @@ fn sha256_lorem_ipsum_test() { let result = sha256::sha256(input); // result should be 0xD35BF81DDF990122F8B96C7BF88C0737D5080E0C9BC3F7ABF68E6FF0D5F9EA44 - assert_eq!(result.len(), 32, "invalid result length"); - assert_eq!(*result[0], 0xD3, "invalid result"); - assert_eq!(*result[1], 0x5B, "invalid result"); - assert_eq!(*result[2], 0xF8, "invalid result"); - assert_eq!(*result[3], 0x1D, "invalid result"); - assert_eq!(*result[4], 0xDF, "invalid result"); - assert_eq!(*result[5], 0x99, "invalid result"); - assert_eq!(*result[6], 0x01, "invalid result"); - assert_eq!(*result[7], 0x22, "invalid result"); - assert_eq!(*result[8], 0xF8, "invalid result"); - assert_eq!(*result[9], 0xB9, "invalid result"); - assert_eq!(*result[10], 0x6C, "invalid result"); - assert_eq!(*result[11], 0x7B, "invalid result"); - assert_eq!(*result[12], 0xF8, "invalid result"); - assert_eq!(*result[13], 0x8C, "invalid result"); - assert_eq!(*result[14], 0x07, "invalid result"); - assert_eq!(*result[15], 0x37, "invalid result"); - assert_eq!(*result[16], 0xD5, "invalid result"); - assert_eq!(*result[17], 0x08, "invalid result"); - assert_eq!(*result[18], 0x0E, "invalid result"); - assert_eq!(*result[19], 0x0C, "invalid result"); - assert_eq!(*result[20], 0x9B, "invalid result"); - assert_eq!(*result[21], 0xC3, "invalid result"); - assert_eq!(*result[22], 0xF7, "invalid result"); - assert_eq!(*result[23], 0xAB, "invalid result"); - assert_eq!(*result[24], 0xF6, "invalid result"); - assert_eq!(*result[25], 0x8E, "invalid result"); - assert_eq!(*result[26], 0x6F, "invalid result"); - assert_eq!(*result[27], 0xF0, "invalid result"); - assert_eq!(*result[28], 0xD5, "invalid result"); - assert_eq!(*result[29], 0xF9, "invalid result"); - assert_eq!(*result[30], 0xEA, "invalid result"); - assert_eq!(*result[31], 0x44, "invalid result"); + assert_eq!(result.len(), 32); + assert_eq!(*result[0], 0xD3); + assert_eq!(*result[1], 0x5B); + assert_eq!(*result[2], 0xF8); + assert_eq!(*result[3], 0x1D); + assert_eq!(*result[4], 0xDF); + assert_eq!(*result[5], 0x99); + assert_eq!(*result[6], 0x01); + assert_eq!(*result[7], 0x22); + assert_eq!(*result[8], 0xF8); + assert_eq!(*result[9], 0xB9); + assert_eq!(*result[10], 0x6C); + assert_eq!(*result[11], 0x7B); + assert_eq!(*result[12], 0xF8); + assert_eq!(*result[13], 0x8C); + assert_eq!(*result[14], 0x07); + assert_eq!(*result[15], 0x37); + assert_eq!(*result[16], 0xD5); + assert_eq!(*result[17], 0x08); + assert_eq!(*result[18], 0x0E); + assert_eq!(*result[19], 0x0C); + assert_eq!(*result[20], 0x9B); + assert_eq!(*result[21], 0xC3); + assert_eq!(*result[22], 0xF7); + assert_eq!(*result[23], 0xAB); + assert_eq!(*result[24], 0xF6); + assert_eq!(*result[25], 0x8E); + assert_eq!(*result[26], 0x6F); + assert_eq!(*result[27], 0xF0); + assert_eq!(*result[28], 0xD5); + assert_eq!(*result[29], 0xF9); + assert_eq!(*result[30], 0xEA); + assert_eq!(*result[31], 0x44); } #[test] #[available_gas(10_000_000_000)] @@ -667,37 +667,37 @@ fn sha256_url() { let result = sha256::sha256(data); // result should be 0xe5ddd0d703d54d024a1e49cdb614d1f4e9dfa81fff119ca01554ec22d1a45f59 - assert_eq!(result.len(), 32, "invalid result length"); - assert_eq!(*result[0], 0xE5, "invalid result"); - assert_eq!(*result[1], 0xDD, "invalid result"); - assert_eq!(*result[2], 0xD0, "invalid result"); - assert_eq!(*result[3], 0xD7, "invalid result"); - assert_eq!(*result[4], 0x03, "invalid result"); - assert_eq!(*result[5], 0xD5, "invalid result"); - assert_eq!(*result[6], 0x4D, "invalid result"); - assert_eq!(*result[7], 0x02, "invalid result"); - assert_eq!(*result[8], 0x4A, "invalid result"); - assert_eq!(*result[9], 0x1E, "invalid result"); - assert_eq!(*result[10], 0x49, "invalid result"); - assert_eq!(*result[11], 0xCD, "invalid result"); - assert_eq!(*result[12], 0xB6, "invalid result"); - assert_eq!(*result[13], 0x14, "invalid result"); - assert_eq!(*result[14], 0xD1, "invalid result"); - assert_eq!(*result[15], 0xF4, "invalid result"); - assert_eq!(*result[16], 0xE9, "invalid result"); - assert_eq!(*result[17], 0xDF, "invalid result"); - assert_eq!(*result[18], 0xA8, "invalid result"); - assert_eq!(*result[19], 0x1F, "invalid result"); - assert_eq!(*result[20], 0xFF, "invalid result"); - assert_eq!(*result[21], 0x11, "invalid result"); - assert_eq!(*result[22], 0x9C, "invalid result"); - assert_eq!(*result[23], 0xA0, "invalid result"); - assert_eq!(*result[24], 0x15, "invalid result"); - assert_eq!(*result[25], 0x54, "invalid result"); - assert_eq!(*result[26], 0xEC, "invalid result"); - assert_eq!(*result[27], 0x22, "invalid result"); - assert_eq!(*result[28], 0xD1, "invalid result"); - assert_eq!(*result[29], 0xA4, "invalid result"); - assert_eq!(*result[30], 0x5F, "invalid result"); - assert_eq!(*result[31], 0x59, "invalid result"); + assert_eq!(result.len(), 32); + assert_eq!(*result[0], 0xE5); + assert_eq!(*result[1], 0xDD); + assert_eq!(*result[2], 0xD0); + assert_eq!(*result[3], 0xD7); + assert_eq!(*result[4], 0x03); + assert_eq!(*result[5], 0xD5); + assert_eq!(*result[6], 0x4D); + assert_eq!(*result[7], 0x02); + assert_eq!(*result[8], 0x4A); + assert_eq!(*result[9], 0x1E); + assert_eq!(*result[10], 0x49); + assert_eq!(*result[11], 0xCD); + assert_eq!(*result[12], 0xB6); + assert_eq!(*result[13], 0x14); + assert_eq!(*result[14], 0xD1); + assert_eq!(*result[15], 0xF4); + assert_eq!(*result[16], 0xE9); + assert_eq!(*result[17], 0xDF); + assert_eq!(*result[18], 0xA8); + assert_eq!(*result[19], 0x1F); + assert_eq!(*result[20], 0xFF); + assert_eq!(*result[21], 0x11); + assert_eq!(*result[22], 0x9C); + assert_eq!(*result[23], 0xA0); + assert_eq!(*result[24], 0x15); + assert_eq!(*result[25], 0x54); + assert_eq!(*result[26], 0xEC); + assert_eq!(*result[27], 0x22); + assert_eq!(*result[28], 0xD1); + assert_eq!(*result[29], 0xA4); + assert_eq!(*result[30], 0x5F); + assert_eq!(*result[31], 0x59); } diff --git a/packages/math/src/tests/sha512_test.cairo b/packages/math/src/tests/sha512_test.cairo index 0c11c5ee..0cb2142b 100644 --- a/packages/math/src/tests/sha512_test.cairo +++ b/packages/math/src/tests/sha512_test.cairo @@ -333,72 +333,72 @@ fn test_sha512_lorem_ipsum() { let msg = get_lorem_ipsum(); let res = sha512(msg); - assert_eq!(res.len(), 64, "Incorrect hash length"); + assert_eq!(res.len(), 64); - assert_eq!(*res[0], 0xd5, "Incorrect hash value"); - assert_eq!(*res[1], 0xa2, "Incorrect hash value"); - assert_eq!(*res[2], 0xe1, "Incorrect hash value"); - assert_eq!(*res[3], 0x4e, "Incorrect hash value"); - assert_eq!(*res[4], 0xf4, "Incorrect hash value"); - assert_eq!(*res[5], 0x20, "Incorrect hash value"); - assert_eq!(*res[6], 0xf8, "Incorrect hash value"); - assert_eq!(*res[7], 0x2d, "Incorrect hash value"); - assert_eq!(*res[8], 0x68, "Incorrect hash value"); - assert_eq!(*res[9], 0x2b, "Incorrect hash value"); - assert_eq!(*res[10], 0x19, "Incorrect hash value"); - assert_eq!(*res[11], 0xc3, "Incorrect hash value"); - assert_eq!(*res[12], 0xd0, "Incorrect hash value"); - assert_eq!(*res[13], 0x70, "Incorrect hash value"); - assert_eq!(*res[14], 0xf4, "Incorrect hash value"); - assert_eq!(*res[15], 0x81, "Incorrect hash value"); - assert_eq!(*res[16], 0x14, "Incorrect hash value"); - assert_eq!(*res[17], 0xcb, "Incorrect hash value"); - assert_eq!(*res[18], 0xb9, "Incorrect hash value"); - assert_eq!(*res[19], 0x74, "Incorrect hash value"); - assert_eq!(*res[20], 0x7c, "Incorrect hash value"); - assert_eq!(*res[21], 0x7d, "Incorrect hash value"); - assert_eq!(*res[22], 0xb1, "Incorrect hash value"); - assert_eq!(*res[23], 0x15, "Incorrect hash value"); - assert_eq!(*res[24], 0xce, "Incorrect hash value"); - assert_eq!(*res[25], 0xa5, "Incorrect hash value"); - assert_eq!(*res[26], 0x41, "Incorrect hash value"); - assert_eq!(*res[27], 0x3e, "Incorrect hash value"); - assert_eq!(*res[28], 0xf8, "Incorrect hash value"); - assert_eq!(*res[29], 0xcb, "Incorrect hash value"); - assert_eq!(*res[30], 0x8f, "Incorrect hash value"); - assert_eq!(*res[31], 0xba, "Incorrect hash value"); - assert_eq!(*res[32], 0xc6, "Incorrect hash value"); - assert_eq!(*res[33], 0x90, "Incorrect hash value"); - assert_eq!(*res[34], 0x17, "Incorrect hash value"); - assert_eq!(*res[35], 0xc5, "Incorrect hash value"); - assert_eq!(*res[36], 0x17, "Incorrect hash value"); - assert_eq!(*res[37], 0x0f, "Incorrect hash value"); - assert_eq!(*res[38], 0x01, "Incorrect hash value"); - assert_eq!(*res[39], 0xc4, "Incorrect hash value"); - assert_eq!(*res[40], 0x77, "Incorrect hash value"); - assert_eq!(*res[41], 0xb3, "Incorrect hash value"); - assert_eq!(*res[42], 0xdf, "Incorrect hash value"); - assert_eq!(*res[43], 0x3d, "Incorrect hash value"); - assert_eq!(*res[44], 0xfb, "Incorrect hash value"); - assert_eq!(*res[45], 0x34, "Incorrect hash value"); - assert_eq!(*res[46], 0xd3, "Incorrect hash value"); - assert_eq!(*res[47], 0x50, "Incorrect hash value"); - assert_eq!(*res[48], 0x8f, "Incorrect hash value"); - assert_eq!(*res[49], 0xa0, "Incorrect hash value"); - assert_eq!(*res[50], 0xb2, "Incorrect hash value"); - assert_eq!(*res[51], 0xb1, "Incorrect hash value"); - assert_eq!(*res[52], 0x37, "Incorrect hash value"); - assert_eq!(*res[53], 0xd4, "Incorrect hash value"); - assert_eq!(*res[54], 0xcb, "Incorrect hash value"); - assert_eq!(*res[55], 0x54, "Incorrect hash value"); - assert_eq!(*res[56], 0x60, "Incorrect hash value"); - assert_eq!(*res[57], 0x9e, "Incorrect hash value"); - assert_eq!(*res[58], 0x63, "Incorrect hash value"); - assert_eq!(*res[59], 0x3d, "Incorrect hash value"); - assert_eq!(*res[60], 0x14, "Incorrect hash value"); - assert_eq!(*res[61], 0x45, "Incorrect hash value"); - assert_eq!(*res[62], 0x82, "Incorrect hash value"); - assert_eq!(*res[63], 0xc9, "Incorrect hash value"); + assert_eq!(*res[0], 0xd5); + assert_eq!(*res[1], 0xa2); + assert_eq!(*res[2], 0xe1); + assert_eq!(*res[3], 0x4e); + assert_eq!(*res[4], 0xf4); + assert_eq!(*res[5], 0x20); + assert_eq!(*res[6], 0xf8); + assert_eq!(*res[7], 0x2d); + assert_eq!(*res[8], 0x68); + assert_eq!(*res[9], 0x2b); + assert_eq!(*res[10], 0x19); + assert_eq!(*res[11], 0xc3); + assert_eq!(*res[12], 0xd0); + assert_eq!(*res[13], 0x70); + assert_eq!(*res[14], 0xf4); + assert_eq!(*res[15], 0x81); + assert_eq!(*res[16], 0x14); + assert_eq!(*res[17], 0xcb); + assert_eq!(*res[18], 0xb9); + assert_eq!(*res[19], 0x74); + assert_eq!(*res[20], 0x7c); + assert_eq!(*res[21], 0x7d); + assert_eq!(*res[22], 0xb1); + assert_eq!(*res[23], 0x15); + assert_eq!(*res[24], 0xce); + assert_eq!(*res[25], 0xa5); + assert_eq!(*res[26], 0x41); + assert_eq!(*res[27], 0x3e); + assert_eq!(*res[28], 0xf8); + assert_eq!(*res[29], 0xcb); + assert_eq!(*res[30], 0x8f); + assert_eq!(*res[31], 0xba); + assert_eq!(*res[32], 0xc6); + assert_eq!(*res[33], 0x90); + assert_eq!(*res[34], 0x17); + assert_eq!(*res[35], 0xc5); + assert_eq!(*res[36], 0x17); + assert_eq!(*res[37], 0x0f); + assert_eq!(*res[38], 0x01); + assert_eq!(*res[39], 0xc4); + assert_eq!(*res[40], 0x77); + assert_eq!(*res[41], 0xb3); + assert_eq!(*res[42], 0xdf); + assert_eq!(*res[43], 0x3d); + assert_eq!(*res[44], 0xfb); + assert_eq!(*res[45], 0x34); + assert_eq!(*res[46], 0xd3); + assert_eq!(*res[47], 0x50); + assert_eq!(*res[48], 0x8f); + assert_eq!(*res[49], 0xa0); + assert_eq!(*res[50], 0xb2); + assert_eq!(*res[51], 0xb1); + assert_eq!(*res[52], 0x37); + assert_eq!(*res[53], 0xd4); + assert_eq!(*res[54], 0xcb); + assert_eq!(*res[55], 0x54); + assert_eq!(*res[56], 0x60); + assert_eq!(*res[57], 0x9e); + assert_eq!(*res[58], 0x63); + assert_eq!(*res[59], 0x3d); + assert_eq!(*res[60], 0x14); + assert_eq!(*res[61], 0x45); + assert_eq!(*res[62], 0x82); + assert_eq!(*res[63], 0xc9); } #[test] @@ -407,72 +407,72 @@ fn test_sha512_size_one() { let mut arr: Array = array![49]; let mut res = sha512(arr); - assert_eq!(res.len(), 64, "Len should be 64"); + assert_eq!(res.len(), 64); - assert_eq!(*res[0], 0x4d, "invalid value for hash"); - assert_eq!(*res[1], 0xff, "invalid value for hash"); - assert_eq!(*res[2], 0x4e, "invalid value for hash"); - assert_eq!(*res[3], 0xa3, "invalid value for hash"); - assert_eq!(*res[4], 0x40, "invalid value for hash"); - assert_eq!(*res[5], 0xf0, "invalid value for hash"); - assert_eq!(*res[6], 0xa8, "invalid value for hash"); - assert_eq!(*res[7], 0x23, "invalid value for hash"); - assert_eq!(*res[8], 0xf1, "invalid value for hash"); - assert_eq!(*res[9], 0x5d, "invalid value for hash"); - assert_eq!(*res[10], 0x3f, "invalid value for hash"); - assert_eq!(*res[11], 0x4f, "invalid value for hash"); - assert_eq!(*res[12], 0x01, "invalid value for hash"); - assert_eq!(*res[13], 0xab, "invalid value for hash"); - assert_eq!(*res[14], 0x62, "invalid value for hash"); - assert_eq!(*res[15], 0xea, "invalid value for hash"); - assert_eq!(*res[16], 0xe0, "invalid value for hash"); - assert_eq!(*res[17], 0xe5, "invalid value for hash"); - assert_eq!(*res[18], 0xda, "invalid value for hash"); - assert_eq!(*res[19], 0x57, "invalid value for hash"); - assert_eq!(*res[20], 0x9c, "invalid value for hash"); - assert_eq!(*res[21], 0xcb, "invalid value for hash"); - assert_eq!(*res[22], 0x85, "invalid value for hash"); - assert_eq!(*res[23], 0x1f, "invalid value for hash"); - assert_eq!(*res[24], 0x8d, "invalid value for hash"); - assert_eq!(*res[25], 0xb9, "invalid value for hash"); - assert_eq!(*res[26], 0xdf, "invalid value for hash"); - assert_eq!(*res[27], 0xe8, "invalid value for hash"); - assert_eq!(*res[28], 0x4c, "invalid value for hash"); - assert_eq!(*res[29], 0x58, "invalid value for hash"); - assert_eq!(*res[30], 0xb2, "invalid value for hash"); - assert_eq!(*res[31], 0xb3, "invalid value for hash"); - assert_eq!(*res[32], 0x7b, "invalid value for hash"); - assert_eq!(*res[33], 0x89, "invalid value for hash"); - assert_eq!(*res[34], 0x90, "invalid value for hash"); - assert_eq!(*res[35], 0x3a, "invalid value for hash"); - assert_eq!(*res[36], 0x74, "invalid value for hash"); - assert_eq!(*res[37], 0x0e, "invalid value for hash"); - assert_eq!(*res[38], 0x1e, "invalid value for hash"); - assert_eq!(*res[39], 0xe1, "invalid value for hash"); - assert_eq!(*res[40], 0x72, "invalid value for hash"); - assert_eq!(*res[41], 0xda, "invalid value for hash"); - assert_eq!(*res[42], 0x79, "invalid value for hash"); - assert_eq!(*res[43], 0x3a, "invalid value for hash"); - assert_eq!(*res[44], 0x6e, "invalid value for hash"); - assert_eq!(*res[45], 0x79, "invalid value for hash"); - assert_eq!(*res[46], 0xd5, "invalid value for hash"); - assert_eq!(*res[47], 0x60, "invalid value for hash"); - assert_eq!(*res[48], 0xe5, "invalid value for hash"); - assert_eq!(*res[49], 0xf7, "invalid value for hash"); - assert_eq!(*res[50], 0xf9, "invalid value for hash"); - assert_eq!(*res[51], 0xbd, "invalid value for hash"); - assert_eq!(*res[52], 0x05, "invalid value for hash"); - assert_eq!(*res[53], 0x8a, "invalid value for hash"); - assert_eq!(*res[54], 0x12, "invalid value for hash"); - assert_eq!(*res[55], 0xa2, "invalid value for hash"); - assert_eq!(*res[56], 0x80, "invalid value for hash"); - assert_eq!(*res[57], 0x43, "invalid value for hash"); - assert_eq!(*res[58], 0x3e, "invalid value for hash"); - assert_eq!(*res[59], 0xd6, "invalid value for hash"); - assert_eq!(*res[60], 0xfa, "invalid value for hash"); - assert_eq!(*res[61], 0x46, "invalid value for hash"); - assert_eq!(*res[62], 0x51, "invalid value for hash"); - assert_eq!(*res[63], 0x0a, "invalid value for hash"); + assert_eq!(*res[0], 0x4d); + assert_eq!(*res[1], 0xff); + assert_eq!(*res[2], 0x4e); + assert_eq!(*res[3], 0xa3); + assert_eq!(*res[4], 0x40); + assert_eq!(*res[5], 0xf0); + assert_eq!(*res[6], 0xa8); + assert_eq!(*res[7], 0x23); + assert_eq!(*res[8], 0xf1); + assert_eq!(*res[9], 0x5d); + assert_eq!(*res[10], 0x3f); + assert_eq!(*res[11], 0x4f); + assert_eq!(*res[12], 0x01); + assert_eq!(*res[13], 0xab); + assert_eq!(*res[14], 0x62); + assert_eq!(*res[15], 0xea); + assert_eq!(*res[16], 0xe0); + assert_eq!(*res[17], 0xe5); + assert_eq!(*res[18], 0xda); + assert_eq!(*res[19], 0x57); + assert_eq!(*res[20], 0x9c); + assert_eq!(*res[21], 0xcb); + assert_eq!(*res[22], 0x85); + assert_eq!(*res[23], 0x1f); + assert_eq!(*res[24], 0x8d); + assert_eq!(*res[25], 0xb9); + assert_eq!(*res[26], 0xdf); + assert_eq!(*res[27], 0xe8); + assert_eq!(*res[28], 0x4c); + assert_eq!(*res[29], 0x58); + assert_eq!(*res[30], 0xb2); + assert_eq!(*res[31], 0xb3); + assert_eq!(*res[32], 0x7b); + assert_eq!(*res[33], 0x89); + assert_eq!(*res[34], 0x90); + assert_eq!(*res[35], 0x3a); + assert_eq!(*res[36], 0x74); + assert_eq!(*res[37], 0x0e); + assert_eq!(*res[38], 0x1e); + assert_eq!(*res[39], 0xe1); + assert_eq!(*res[40], 0x72); + assert_eq!(*res[41], 0xda); + assert_eq!(*res[42], 0x79); + assert_eq!(*res[43], 0x3a); + assert_eq!(*res[44], 0x6e); + assert_eq!(*res[45], 0x79); + assert_eq!(*res[46], 0xd5); + assert_eq!(*res[47], 0x60); + assert_eq!(*res[48], 0xe5); + assert_eq!(*res[49], 0xf7); + assert_eq!(*res[50], 0xf9); + assert_eq!(*res[51], 0xbd); + assert_eq!(*res[52], 0x05); + assert_eq!(*res[53], 0x8a); + assert_eq!(*res[54], 0x12); + assert_eq!(*res[55], 0xa2); + assert_eq!(*res[56], 0x80); + assert_eq!(*res[57], 0x43); + assert_eq!(*res[58], 0x3e); + assert_eq!(*res[59], 0xd6); + assert_eq!(*res[60], 0xfa); + assert_eq!(*res[61], 0x46); + assert_eq!(*res[62], 0x51); + assert_eq!(*res[63], 0x0a); } #[test] @@ -482,69 +482,69 @@ fn test_size_zero() { let res = sha512(msg); - assert_eq!(res.len(), 64, "Incorrect hash len"); - assert_eq!(*res[0], 0xcf, "Incorrect hash len"); - assert_eq!(*res[1], 0x83, "Incorrect hash len"); - assert_eq!(*res[2], 0xe1, "Incorrect hash len"); - assert_eq!(*res[3], 0x35, "Incorrect hash len"); - assert_eq!(*res[4], 0x7e, "Incorrect hash len"); - assert_eq!(*res[5], 0xef, "Incorrect hash len"); - assert_eq!(*res[6], 0xb8, "Incorrect hash len"); - assert_eq!(*res[7], 0xbd, "Incorrect hash len"); - assert_eq!(*res[8], 0xf1, "Incorrect hash len"); - assert_eq!(*res[9], 0x54, "Incorrect hash len"); - assert_eq!(*res[10], 0x28, "Incorrect hash len"); - assert_eq!(*res[11], 0x50, "Incorrect hash len"); - assert_eq!(*res[12], 0xd6, "Incorrect hash len"); - assert_eq!(*res[13], 0x6d, "Incorrect hash len"); - assert_eq!(*res[14], 0x80, "Incorrect hash len"); - assert_eq!(*res[15], 0x07, "Incorrect hash len"); - assert_eq!(*res[16], 0xd6, "Incorrect hash len"); - assert_eq!(*res[17], 0x20, "Incorrect hash len"); - assert_eq!(*res[18], 0xe4, "Incorrect hash len"); - assert_eq!(*res[19], 0x05, "Incorrect hash len"); - assert_eq!(*res[20], 0x0b, "Incorrect hash len"); - assert_eq!(*res[21], 0x57, "Incorrect hash len"); - assert_eq!(*res[22], 0x15, "Incorrect hash len"); - assert_eq!(*res[23], 0xdc, "Incorrect hash len"); - assert_eq!(*res[24], 0x83, "Incorrect hash len"); - assert_eq!(*res[25], 0xf4, "Incorrect hash len"); - assert_eq!(*res[26], 0xa9, "Incorrect hash len"); - assert_eq!(*res[27], 0x21, "Incorrect hash len"); - assert_eq!(*res[28], 0xd3, "Incorrect hash len"); - assert_eq!(*res[29], 0x6c, "Incorrect hash len"); - assert_eq!(*res[30], 0xe9, "Incorrect hash len"); - assert_eq!(*res[31], 0xce, "Incorrect hash len"); - assert_eq!(*res[32], 0x47, "Incorrect hash len"); - assert_eq!(*res[33], 0xd0, "Incorrect hash len"); - assert_eq!(*res[34], 0xd1, "Incorrect hash len"); - assert_eq!(*res[35], 0x3c, "Incorrect hash len"); - assert_eq!(*res[36], 0x5d, "Incorrect hash len"); - assert_eq!(*res[37], 0x85, "Incorrect hash len"); - assert_eq!(*res[38], 0xf2, "Incorrect hash len"); - assert_eq!(*res[39], 0xb0, "Incorrect hash len"); - assert_eq!(*res[40], 0xff, "Incorrect hash len"); - assert_eq!(*res[41], 0x83, "Incorrect hash len"); - assert_eq!(*res[42], 0x18, "Incorrect hash len"); - assert_eq!(*res[43], 0xd2, "Incorrect hash len"); - assert_eq!(*res[44], 0x87, "Incorrect hash len"); - assert_eq!(*res[45], 0x7e, "Incorrect hash len"); - assert_eq!(*res[46], 0xec, "Incorrect hash len"); - assert_eq!(*res[47], 0x2f, "Incorrect hash len"); - assert_eq!(*res[48], 0x63, "Incorrect hash len"); - assert_eq!(*res[49], 0xb9, "Incorrect hash len"); - assert_eq!(*res[50], 0x31, "Incorrect hash len"); - assert_eq!(*res[51], 0xbd, "Incorrect hash len"); - assert_eq!(*res[52], 0x47, "Incorrect hash len"); - assert_eq!(*res[53], 0x41, "Incorrect hash len"); - assert_eq!(*res[54], 0x7a, "Incorrect hash len"); - assert_eq!(*res[55], 0x81, "Incorrect hash len"); - assert_eq!(*res[56], 0xa5, "Incorrect hash len"); - assert_eq!(*res[57], 0x38, "Incorrect hash len"); - assert_eq!(*res[58], 0x32, "Incorrect hash len"); - assert_eq!(*res[59], 0x7a, "Incorrect hash len"); - assert_eq!(*res[60], 0xf9, "Incorrect hash len"); - assert_eq!(*res[61], 0x27, "Incorrect hash len"); - assert_eq!(*res[62], 0xda, "Incorrect hash len"); - assert_eq!(*res[63], 0x3e, "Incorrect hash len"); + assert_eq!(res.len(), 64); + assert_eq!(*res[0], 0xcf); + assert_eq!(*res[1], 0x83); + assert_eq!(*res[2], 0xe1); + assert_eq!(*res[3], 0x35); + assert_eq!(*res[4], 0x7e); + assert_eq!(*res[5], 0xef); + assert_eq!(*res[6], 0xb8); + assert_eq!(*res[7], 0xbd); + assert_eq!(*res[8], 0xf1); + assert_eq!(*res[9], 0x54); + assert_eq!(*res[10], 0x28); + assert_eq!(*res[11], 0x50); + assert_eq!(*res[12], 0xd6); + assert_eq!(*res[13], 0x6d); + assert_eq!(*res[14], 0x80); + assert_eq!(*res[15], 0x07); + assert_eq!(*res[16], 0xd6); + assert_eq!(*res[17], 0x20); + assert_eq!(*res[18], 0xe4); + assert_eq!(*res[19], 0x05); + assert_eq!(*res[20], 0x0b); + assert_eq!(*res[21], 0x57); + assert_eq!(*res[22], 0x15); + assert_eq!(*res[23], 0xdc); + assert_eq!(*res[24], 0x83); + assert_eq!(*res[25], 0xf4); + assert_eq!(*res[26], 0xa9); + assert_eq!(*res[27], 0x21); + assert_eq!(*res[28], 0xd3); + assert_eq!(*res[29], 0x6c); + assert_eq!(*res[30], 0xe9); + assert_eq!(*res[31], 0xce); + assert_eq!(*res[32], 0x47); + assert_eq!(*res[33], 0xd0); + assert_eq!(*res[34], 0xd1); + assert_eq!(*res[35], 0x3c); + assert_eq!(*res[36], 0x5d); + assert_eq!(*res[37], 0x85); + assert_eq!(*res[38], 0xf2); + assert_eq!(*res[39], 0xb0); + assert_eq!(*res[40], 0xff); + assert_eq!(*res[41], 0x83); + assert_eq!(*res[42], 0x18); + assert_eq!(*res[43], 0xd2); + assert_eq!(*res[44], 0x87); + assert_eq!(*res[45], 0x7e); + assert_eq!(*res[46], 0xec); + assert_eq!(*res[47], 0x2f); + assert_eq!(*res[48], 0x63); + assert_eq!(*res[49], 0xb9); + assert_eq!(*res[50], 0x31); + assert_eq!(*res[51], 0xbd); + assert_eq!(*res[52], 0x47); + assert_eq!(*res[53], 0x41); + assert_eq!(*res[54], 0x7a); + assert_eq!(*res[55], 0x81); + assert_eq!(*res[56], 0xa5); + assert_eq!(*res[57], 0x38); + assert_eq!(*res[58], 0x32); + assert_eq!(*res[59], 0x7a); + assert_eq!(*res[60], 0xf9); + assert_eq!(*res[61], 0x27); + assert_eq!(*res[62], 0xda); + assert_eq!(*res[63], 0x3e); } diff --git a/packages/math/src/tests/wad_ray_math_test.cairo b/packages/math/src/tests/wad_ray_math_test.cairo index 9ae466a2..d105b400 100644 --- a/packages/math/src/tests/wad_ray_math_test.cairo +++ b/packages/math/src/tests/wad_ray_math_test.cairo @@ -9,7 +9,7 @@ use alexandria_math::{pow}; fn test_wad_to_ray_conversion() { let a = 5 * pow(10, 17); // 0.5e18 let expected = 5 * pow(10, 26); // 0.5e27 - assert_eq!(wad_to_ray(a), expected, "Wrong wad_to_ray conversion"); + assert_eq!(wad_to_ray(a), expected); } #[test] @@ -17,7 +17,7 @@ fn test_wad_to_ray_conversion() { fn test_ray_to_wad_conversion() { let a = 5 * pow(10, 26); // 0.5e27 let expected = 5 * pow(10, 17); // 0.5e18 - assert_eq!(ray_to_wad(a), expected, "Wrong ray_to_wad conversion"); + assert_eq!(ray_to_wad(a), expected); } // wad @@ -31,19 +31,19 @@ fn test_revertWhen_wad_mul_overflow() { #[test] #[available_gas(2000000)] fn test_wad_mul_trivial() { - assert_eq!(wad_mul(pow(2, 128) - 1, wad()), pow(2, 128) - 1, "Wrong result: 2**128 -1 * 1e18"); - assert_eq!(wad_mul(0, 0), 0, "Wrong result: 0 * 0"); - assert_eq!(wad_mul(0, wad()), 0, "Wrong result: 0 * 1e18"); - assert_eq!(wad_mul(wad(), 0), 0, "Wrong result: 1e18 * 0"); - assert_eq!(wad_mul(wad(), wad()), wad(), "Wrong result: 1e18 * 1e18 "); + assert_eq!(wad_mul(pow(2, 128) - 1, wad()), pow(2, 128) - 1); + assert_eq!(wad_mul(0, 0), 0); + assert_eq!(wad_mul(0, wad()), 0); + assert_eq!(wad_mul(wad(), 0), 0); + assert_eq!(wad_mul(wad(), wad()), wad()); } #[test] #[available_gas(2000000)] fn test_wad_mul_fractions() { let val: u256 = 2 * pow(10, 17); // 0.2e18 - assert_eq!(wad_mul(wad(), val), val, "Wrong result: 1e18 * 0.2e18"); - assert_eq!(wad_mul(wad() * 2, val), val * 2, "Wrong result: 2e18 * 0.2e18"); + assert_eq!(wad_mul(wad(), val), val); + assert_eq!(wad_mul(wad() * 2, val), val * 2); } #[test] @@ -56,16 +56,16 @@ fn test_revertWhen_wad_div_zero() { #[test] #[available_gas(3000000)] fn test_wad_div_trivial() { - assert_eq!(wad_div(pow(2, 128) - 1, wad()), pow(2, 128) - 1, "Wrong result: 2**128 -1 / 1e18"); - assert_eq!(wad_div(0, pow(2, 128) - 1), 0, "Wrong result: 0 / 2**128 -1"); - assert_eq!(wad_div(wad(), wad()), wad(), "Wrong result: 1e18 / 1e18"); + assert_eq!(wad_div(pow(2, 128) - 1, wad()), pow(2, 128) - 1); + assert_eq!(wad_div(0, pow(2, 128) - 1), 0); + assert_eq!(wad_div(wad(), wad()), wad()); } #[test] #[available_gas(2000000)] fn test_wad_div_fractions() { - assert_eq!(wad_div(wad() * 2, wad() * 2), wad(), "Wrong result: 2e18 / 2e18"); - assert_eq!(wad_div(wad(), wad() * 2), half_wad(), "Wrong result: 1e18 / 2e18"); + assert_eq!(wad_div(wad() * 2, wad() * 2), wad()); + assert_eq!(wad_div(wad(), wad() * 2), half_wad()); } #[test] @@ -74,8 +74,8 @@ fn test_wad_mul_rounding() { let a = 950000000000005647; let b = 1000000000; let expected = 950000000; - assert_eq!(wad_mul(a, b), expected, "Wrong rounding down: a * b"); - assert_eq!(wad_mul(b, a), expected, "Wrong rounding down: b * a"); + assert_eq!(wad_mul(a, b), expected); + assert_eq!(wad_mul(b, a), expected); } #[test] @@ -84,8 +84,8 @@ fn test_wad_mul_rounding_up() { let a = pow(10, 18) - 1; let b = 2; let expected = 2; - assert_eq!(wad_mul(a, b), expected, "Wrong rounding: a * b"); - assert_eq!(wad_mul(b, a), expected, "Wrong rounding: b * a"); + assert_eq!(wad_mul(a, b), expected); + assert_eq!(wad_mul(b, a), expected); } @@ -100,19 +100,19 @@ fn test_revertWhen_ray_mul_overflow() { #[test] #[available_gas(2000000)] fn test_ray_mul_trivial() { - assert_eq!(ray_mul(pow(2, 128) - 1, ray()), pow(2, 128) - 1, "Wrong result: 2**128 -1 * 1e27"); - assert_eq!(ray_mul(0, 0), 0, "Wrong result: 0 * 0"); - assert_eq!(ray_mul(0, ray()), 0, "Wrong result: 0 * 1e27"); - assert_eq!(ray_mul(ray(), 0), 0, "Wrong result: 1e27 * 0"); - assert_eq!(ray_mul(ray(), ray()), ray(), "Wrong result: 1e27 * 1e27 "); + assert_eq!(ray_mul(pow(2, 128) - 1, ray()), pow(2, 128) - 1); + assert_eq!(ray_mul(0, 0), 0); + assert_eq!(ray_mul(0, ray()), 0); + assert_eq!(ray_mul(ray(), 0), 0); + assert_eq!(ray_mul(ray(), ray()), ray()); } #[test] #[available_gas(2000000)] fn test_ray_mul_fractions() { let val: u256 = 2 * pow(10, 26); // 0.2e27 - assert_eq!(ray_mul(ray(), val), val, "Wrong result: 1e27 * 0.2e27"); - assert_eq!(ray_mul(ray() * 2, val), val * 2, "Wrong result: 2e27 * 0.2e27"); + assert_eq!(ray_mul(ray(), val), val); + assert_eq!(ray_mul(ray() * 2, val), val * 2); } #[test] @@ -125,16 +125,16 @@ fn test_revertWhen_ray_div_zero() { #[test] #[available_gas(3000000)] fn test_ray_div_trivial() { - assert_eq!(ray_div(pow(2, 128) - 1, ray()), pow(2, 128) - 1, "Wrong result: 2**128 -1 / 1e27"); - assert_eq!(ray_div(0, pow(2, 128) - 1), 0, "Wrong result: 0 / 2**128 -1"); - assert_eq!(ray_div(ray(), ray()), ray(), "Wrong result: 1e27 / 1e27"); + assert_eq!(ray_div(pow(2, 128) - 1, ray()), pow(2, 128) - 1); + assert_eq!(ray_div(0, pow(2, 128) - 1), 0); + assert_eq!(ray_div(ray(), ray()), ray()); } #[test] #[available_gas(2000000)] fn test_ray_div_fractions() { - assert_eq!(ray_div(ray() * 2, ray() * 2), ray(), "Wrong result: 2e27 / 2e27"); - assert_eq!(ray_div(ray(), ray() * 2), half_ray(), "Wrong result: 1e27 / 2e27"); + assert_eq!(ray_div(ray() * 2, ray() * 2), ray()); + assert_eq!(ray_div(ray(), ray() * 2), half_ray()); } #[test] @@ -143,8 +143,8 @@ fn test_ray_mul_rounding() { let a = pow(10, 18); let b = 95 * pow(10, 26) + 5647; let expected = 95 * pow(10, 17); - assert_eq!(ray_mul(a, b), expected, "Wrong rounding down: a * b"); - assert_eq!(ray_mul(b, a), expected, "Wrong rounding down: b * a"); + assert_eq!(ray_mul(a, b), expected); + assert_eq!(ray_mul(b, a), expected); } @@ -154,6 +154,6 @@ fn test_ray_mul_rounding_up() { let a = pow(10, 27) - 1; let b = 2; let expected = 2; - assert_eq!(ray_mul(a, b), expected, "Wrong rounding up: a * b"); - assert_eq!(ray_mul(b, a), expected, "Wrong rounding up: b * a"); + assert_eq!(ray_mul(a, b), expected); + assert_eq!(ray_mul(b, a), expected); } diff --git a/packages/math/src/tests/zellers_congruence_test.cairo b/packages/math/src/tests/zellers_congruence_test.cairo index 77943d0c..8f1a64a1 100644 --- a/packages/math/src/tests/zellers_congruence_test.cairo +++ b/packages/math/src/tests/zellers_congruence_test.cairo @@ -9,7 +9,7 @@ fn test_case(day: u128, month: u128, year: u128, expected: u128, error_expected: } // Otherwise, unwrap the day and check it else { let day = day.unwrap(); - assert_eq!(day, expected, "day is invalid"); + assert_eq!(day, expected); } } diff --git a/packages/merkle_tree/src/tests/merkle_tree_test.cairo b/packages/merkle_tree/src/tests/merkle_tree_test.cairo index a3dfc791..464e0984 100644 --- a/packages/merkle_tree/src/tests/merkle_tree_test.cairo +++ b/packages/merkle_tree/src/tests/merkle_tree_test.cairo @@ -25,13 +25,13 @@ mod regular_call_merkle_tree_pedersen { // [Assert] Compute merkle root. let computed_root = merkle_tree.compute_root(leaf, valid_proof); - assert_eq!(computed_root, root, "compute valid root failed"); + assert_eq!(computed_root, root); // [Assert] Compute merkle proof. let mut input_leaves = leaves; let index = 0; let computed_proof = merkle_tree.compute_proof(input_leaves, index); - assert_eq!(computed_proof, valid_proof, "compute valid proof failed"); + assert_eq!(computed_proof, valid_proof); // [Assert] Verify a valid proof. let result = merkle_tree.verify(root, leaf, valid_proof); @@ -67,7 +67,7 @@ fn merkle_tree_pedersen_test() { let computed_root = MerkleTreeImpl::< _, PedersenHasherImpl >::compute_root(ref merkle_tree, leaf, valid_proof); - assert_eq!(computed_root, root, "compute valid root failed"); + assert_eq!(computed_root, root); // [Assert] Compute merkle proof. let mut input_leaves = leaves; @@ -75,7 +75,7 @@ fn merkle_tree_pedersen_test() { let computed_proof = MerkleTreeImpl::< _, PedersenHasherImpl >::compute_proof(ref merkle_tree, input_leaves, index); - assert_eq!(computed_proof, valid_proof, "compute valid proof failed"); + assert_eq!(computed_proof, valid_proof); // [Assert] Verify a valid proof. let result = MerkleTreeImpl::< @@ -116,7 +116,7 @@ fn merkle_tree_poseidon_test() { let computed_root = MerkleTreeImpl::< _, PoseidonHasherImpl >::compute_root(ref merkle_tree, leaf, valid_proof); - assert_eq!(computed_root, root, "compute valid root failed"); + assert_eq!(computed_root, root); // [Assert] Compute merkle proof. let mut input_leaves = leaves; @@ -124,7 +124,7 @@ fn merkle_tree_poseidon_test() { let computed_proof = MerkleTreeImpl::< _, PoseidonHasherImpl >::compute_proof(ref merkle_tree, input_leaves, index); - assert_eq!(computed_proof, valid_proof, "compute valid proof failed"); + assert_eq!(computed_proof, valid_proof); // [Assert] Verify a valid proof. let result = MerkleTreeImpl::< diff --git a/packages/merkle_tree/src/tests/storage_proof_test.cairo b/packages/merkle_tree/src/tests/storage_proof_test.cairo index fea8629d..3deee73f 100644 --- a/packages/merkle_tree/src/tests/storage_proof_test.cairo +++ b/packages/merkle_tree/src/tests/storage_proof_test.cairo @@ -16,7 +16,7 @@ fn balance_lsb_proof_test() { let expected_value = 8700000000000000005; let proof = balance_proof(); let value = verify(state_commitment, contract_address, storage_address, proof); - assert_eq!(expected_value, value, "wrong value"); + assert_eq!(expected_value, value); } #[test] @@ -29,7 +29,7 @@ fn balance_msb_proof_test() { let expected_value = 8700000000000000005; let proof = balance_proof(); let value = verify(state_commitment, contract_address, storage_address, proof); - assert_eq!(expected_value, value, "wrong value"); + assert_eq!(expected_value, value); } #[test] @@ -42,7 +42,7 @@ fn wrong_contract_address_proof_test() { let expected_value = 8700000000000000005; let proof = balance_proof(); let value = verify(state_commitment, contract_address, storage_address, proof); - assert_eq!(expected_value, value, "wrong value"); + assert_eq!(expected_value, value); } #[test] @@ -54,5 +54,5 @@ fn total_balance_lsb_proof_test() { let expected_value = 2970506847688829412026631; let proof = total_balance_proof(); let value = verify(state_commitment, contract_address, storage_address, proof); - assert_eq!(expected_value, value, "wrong value"); + assert_eq!(expected_value, value); } diff --git a/packages/numeric/src/tests/cumprod_test.cairo b/packages/numeric/src/tests/cumprod_test.cairo index 387c6ce3..f41dc296 100644 --- a/packages/numeric/src/tests/cumprod_test.cairo +++ b/packages/numeric/src/tests/cumprod_test.cairo @@ -5,9 +5,9 @@ use alexandria_numeric::cumprod::cumprod; fn cumprod_test() { let xs: Array = array![3, 5, 7]; let ys = cumprod(xs.span()); - assert_eq!(*ys[0], *xs[0], "wrong value at index 0"); - assert_eq!(*ys[1], *xs[0] * *xs[1], "wrong value at index 1"); - assert_eq!(*ys[2], *xs[0] * *xs[1] * *xs[2], "wrong value at index 2"); + assert_eq!(*ys[0], *xs[0]); + assert_eq!(*ys[1], *xs[0] * *xs[1]); + assert_eq!(*ys[2], *xs[0] * *xs[1] * *xs[2]); } #[test] diff --git a/packages/numeric/src/tests/cumsum_test.cairo b/packages/numeric/src/tests/cumsum_test.cairo index 93f6717b..398d5835 100644 --- a/packages/numeric/src/tests/cumsum_test.cairo +++ b/packages/numeric/src/tests/cumsum_test.cairo @@ -5,9 +5,9 @@ use alexandria_numeric::cumsum::cumsum; fn cumsum_test() { let xs: Array = array![3, 5, 7]; let ys = cumsum(xs.span()); - assert_eq!(*ys[0], *xs[0], "wrong value at index 0"); - assert_eq!(*ys[1], *xs[0] + *xs[1], "wrong value at index 1"); - assert_eq!(*ys[2], *xs[0] + *xs[1] + *xs[2], "wrong value at index 2"); + assert_eq!(*ys[0], *xs[0]); + assert_eq!(*ys[1], *xs[0] + *xs[1]); + assert_eq!(*ys[2], *xs[0] + *xs[1] + *xs[2]); } #[test] diff --git a/packages/numeric/src/tests/diff_test.cairo b/packages/numeric/src/tests/diff_test.cairo index 5b0063e0..4623458d 100644 --- a/packages/numeric/src/tests/diff_test.cairo +++ b/packages/numeric/src/tests/diff_test.cairo @@ -5,9 +5,9 @@ use alexandria_numeric::diff::diff; fn diff_test() { let xs = array![3, 5, 7]; let ys = diff(xs.span()); - assert_eq!(*ys[0], 0_u256, "wrong value at index 0"); - assert_eq!(*ys[1], *xs[1] - *xs[0], "wrong value at index 1"); - assert_eq!(*ys[2], *xs[2] - *xs[1], "wrong value at index 2"); + assert_eq!(*ys[0], 0_u256); + assert_eq!(*ys[1], *xs[1] - *xs[0]); + assert_eq!(*ys[2], *xs[2] - *xs[1]); } #[test] diff --git a/packages/numeric/src/tests/integers_test.cairo b/packages/numeric/src/tests/integers_test.cairo index 0f0914ee..0e08e59e 100644 --- a/packages/numeric/src/tests/integers_test.cairo +++ b/packages/numeric/src/tests/integers_test.cairo @@ -7,7 +7,7 @@ fn test_u32_from_bytes() { let res: Option = UIntBytes::from_bytes(input.span()); assert!(res.is_some(), "should have a value"); - assert_eq!(res.unwrap(), 0xf4321562, "wrong result value"); + assert_eq!(res.unwrap(), 0xf4321562); } #[test] @@ -26,11 +26,11 @@ fn test_u32_to_bytes_full() { let input: u32 = 0xf4321562; let res: Span = input.to_bytes(); - assert_eq!(res.len(), 4, "wrong result length"); - assert_eq!(*res[0], 0xf4, "wrong result value"); - assert_eq!(*res[1], 0x32, "wrong result value"); - assert_eq!(*res[2], 0x15, "wrong result value"); - assert_eq!(*res[3], 0x62, "wrong result value"); + assert_eq!(res.len(), 4); + assert_eq!(*res[0], 0xf4); + assert_eq!(*res[1], 0x32); + assert_eq!(*res[2], 0x15); + assert_eq!(*res[3], 0x62); } #[test] @@ -39,10 +39,10 @@ fn test_u32_to_bytes_partial() { let input: u32 = 0xf43215; let res: Span = input.to_bytes(); - assert_eq!(res.len(), 3, "wrong result length"); - assert_eq!(*res[0], 0xf4, "wrong result value"); - assert_eq!(*res[1], 0x32, "wrong result value"); - assert_eq!(*res[2], 0x15, "wrong result value"); + assert_eq!(res.len(), 3); + assert_eq!(*res[0], 0xf4); + assert_eq!(*res[1], 0x32); + assert_eq!(*res[2], 0x15); } @@ -52,7 +52,7 @@ fn test_u32_to_bytes_leading_zeros() { let input: u32 = 0x00f432; let res: Span = input.to_bytes(); - assert_eq!(res.len(), 2, "wrong result length"); - assert_eq!(*res[0], 0xf4, "wrong result value"); - assert_eq!(*res[1], 0x32, "wrong result value"); + assert_eq!(res.len(), 2); + assert_eq!(*res[0], 0xf4); + assert_eq!(*res[1], 0x32); } diff --git a/packages/numeric/src/tests/trapezoidal_rule_test.cairo b/packages/numeric/src/tests/trapezoidal_rule_test.cairo index 2722a727..526a95de 100644 --- a/packages/numeric/src/tests/trapezoidal_rule_test.cairo +++ b/packages/numeric/src/tests/trapezoidal_rule_test.cairo @@ -5,7 +5,7 @@ use alexandria_numeric::trapezoidal_rule::trapezoidal_rule; fn trapezoidal_rule_test() { let xs: Array:: = array![3, 5, 7]; let ys = array![11, 13, 17]; - assert_eq!(trapezoidal_rule(xs.span(), ys.span()), 54, "invalid integral"); + assert_eq!(trapezoidal_rule(xs.span(), ys.span()), 54); } #[test] diff --git a/packages/searching/src/tests/binary_search_test.cairo b/packages/searching/src/tests/binary_search_test.cairo index 494ff8d9..693649ab 100644 --- a/packages/searching/src/tests/binary_search_test.cairo +++ b/packages/searching/src/tests/binary_search_test.cairo @@ -8,23 +8,23 @@ fn value_found() { let mut span = arr.span(); // Test with an even length - assert_eq!(binary_search(span, 100).unwrap(), 0, "Should be index 0"); - assert_eq!(binary_search(span, 200).unwrap(), 1, "Should be index 1"); - assert_eq!(binary_search(span, 300).unwrap(), 2, "Should be index 2"); - assert_eq!(binary_search(span, 400).unwrap(), 3, "Should be index 3"); - assert_eq!(binary_search(span, 500).unwrap(), 4, "Should be index 4"); - assert_eq!(binary_search(span, 600).unwrap(), 5, "Should be index 5"); + assert_eq!(binary_search(span, 100).unwrap(), 0); + assert_eq!(binary_search(span, 200).unwrap(), 1); + assert_eq!(binary_search(span, 300).unwrap(), 2); + assert_eq!(binary_search(span, 400).unwrap(), 3); + assert_eq!(binary_search(span, 500).unwrap(), 4); + assert_eq!(binary_search(span, 600).unwrap(), 5); // Odd length arr.append(700); span = arr.span(); - assert_eq!(binary_search(span, 100).unwrap(), 0, "Should be index 0"); - assert_eq!(binary_search(span, 200).unwrap(), 1, "Should be index 1"); - assert_eq!(binary_search(span, 300).unwrap(), 2, "Should be index 2"); - assert_eq!(binary_search(span, 400).unwrap(), 3, "Should be index 3"); - assert_eq!(binary_search(span, 500).unwrap(), 4, "Should be index 4"); - assert_eq!(binary_search(span, 600).unwrap(), 5, "Should be index 5"); - assert_eq!(binary_search(span, 700).unwrap(), 6, "Should be index 6"); + assert_eq!(binary_search(span, 100).unwrap(), 0); + assert_eq!(binary_search(span, 200).unwrap(), 1); + assert_eq!(binary_search(span, 300).unwrap(), 2); + assert_eq!(binary_search(span, 400).unwrap(), 3); + assert_eq!(binary_search(span, 500).unwrap(), 4); + assert_eq!(binary_search(span, 600).unwrap(), 5); + assert_eq!(binary_search(span, 700).unwrap(), 6); } #[test] diff --git a/packages/searching/src/tests/bm_search_test.cairo b/packages/searching/src/tests/bm_search_test.cairo index 8625df7b..ee4842a1 100644 --- a/packages/searching/src/tests/bm_search_test.cairo +++ b/packages/searching/src/tests/bm_search_test.cairo @@ -41,7 +41,7 @@ fn bm_search_test_1() { let positions = bm_search(@text, @pattern); let ground_truth: Array = array![1, 11, 20]; - assert_eq!(positions.span(), ground_truth.span(), "invalid result"); + assert_eq!(positions.span(), ground_truth.span()); } #[test] @@ -83,7 +83,7 @@ fn bm_search_test_2() { let positions = bm_search(@text, @pattern); let ground_truth: Array = array![]; - assert_eq!(positions.span(), ground_truth.span(), "invalid result"); + assert_eq!(positions.span(), ground_truth.span()); } #[test] @@ -125,5 +125,5 @@ fn bm_search_test_3() { let positions = bm_search(@text, @pattern); let ground_truth: Array = array![3, 13, 22]; - assert_eq!(positions.span(), ground_truth.span(), "invalid result"); + assert_eq!(positions.span(), ground_truth.span()); } diff --git a/packages/searching/src/tests/dijkstra_test.cairo b/packages/searching/src/tests/dijkstra_test.cairo index 3c62d0ce..05e90717 100644 --- a/packages/searching/src/tests/dijkstra_test.cairo +++ b/packages/searching/src/tests/dijkstra_test.cairo @@ -16,7 +16,7 @@ fn add_edge() { GraphTrait::add_edge(ref graph, 2, 1, 2); GraphTrait::add_edge(ref graph, 2, 3, 3); - assert_eq!(graph.nodes.len(), 6, "wrong node number"); + assert_eq!(graph.nodes.len(), 6); let val = graph.adj_nodes(source.into()); let span = match match_nullable(val) { @@ -24,15 +24,15 @@ fn add_edge() { FromNullableResult::NotNull(val) => { val.unbox() }, }; - assert_eq!(span.len(), 4, "wrong nb of adj edge for node 0"); + assert_eq!(span.len(), 4); let new_node = *span.get(1).unwrap().unbox(); - assert_eq!(*new_node.dest(), dest + 1, "Wrong dest in adj edge"); - assert_eq!(*new_node.weight(), weight + 1, "Wrong weight in adj edge"); + assert_eq!(*new_node.dest(), dest + 1); + assert_eq!(*new_node.weight(), weight + 1); let new_node = *span.get(3).unwrap().unbox(); - assert_eq!(*new_node.dest(), dest + 3, "Wrong dest in adj edge"); - assert_eq!(*new_node.weight(), weight + 3, "Wrong weight in adj edge"); + assert_eq!(*new_node.dest(), dest + 3); + assert_eq!(*new_node.weight(), weight + 3); let val = graph.adj_nodes(2.into()); @@ -41,7 +41,7 @@ fn add_edge() { FromNullableResult::NotNull(val) => { val.unbox() }, }; - assert_eq!(span.len(), 2, "wrong nb of adj edge for node 2"); + assert_eq!(span.len(), 2); } @@ -59,12 +59,12 @@ fn calculate_shortest_path() { let mut results: Felt252Dict = GraphTrait::shortest_path(ref graph, 0_u32); - assert_eq!(results.get(0.into()), 0, "Wrong weight for node 0"); - assert_eq!(results.get(1.into()), 5, "Wrong weight for node 1"); - assert_eq!(results.get(2.into()), 3, "Wrong weight for node 2"); - assert_eq!(results.get(3.into()), 2, "Wrong weight for node 3"); - assert_eq!(results.get(4.into()), 3, "Wrong weight for node 4"); - assert_eq!(results.get(5.into()), 3, "Wrong weight for node 5"); + assert_eq!(results.get(0.into()), 0); + assert_eq!(results.get(1.into()), 5); + assert_eq!(results.get(2.into()), 3); + assert_eq!(results.get(3.into()), 2); + assert_eq!(results.get(4.into()), 3); + assert_eq!(results.get(5.into()), 3); } #[test] @@ -80,11 +80,11 @@ fn calculate_shortest_path_random() { let mut results: Felt252Dict = GraphTrait::shortest_path(ref graph, 0_u32); - assert_eq!(results.get(0.into()), 0, "Wrong weight for node 0"); - assert_eq!(results.get(2.into()), 4, "Wrong weight for node 2"); - assert_eq!(results.get(3.into()), 5, "Wrong weight for node 3"); - assert_eq!(results.get(1.into()), 8, "Wrong weight for node 1"); - assert_eq!(results.get(4.into()), 7, "Wrong weight for node 4"); + assert_eq!(results.get(0.into()), 0); + assert_eq!(results.get(2.into()), 4); + assert_eq!(results.get(3.into()), 5); + assert_eq!(results.get(1.into()), 8); + assert_eq!(results.get(4.into()), 7); } @@ -101,11 +101,11 @@ fn calculate_shortest_path_node_visited() { let mut results: Felt252Dict = GraphTrait::shortest_path(ref graph, 0_u32); - assert_eq!(results.get(0.into()), 0, "Wrong weight for node 0"); - assert_eq!(results.get(1.into()), 5, "Wrong weight for node 1"); - assert_eq!(results.get(2.into()), 3, "Wrong weight for node 2"); - assert_eq!(results.get(3.into()), 2, "Wrong weight for node 3"); - assert_eq!(results.get(4.into()), 3, "Wrong weight for node 4"); - assert_eq!(results.get(5.into()), 3, "Wrong weight for node 5"); + assert_eq!(results.get(0.into()), 0); + assert_eq!(results.get(1.into()), 5); + assert_eq!(results.get(2.into()), 3); + assert_eq!(results.get(3.into()), 2); + assert_eq!(results.get(4.into()), 3); + assert_eq!(results.get(5.into()), 3); } diff --git a/packages/searching/src/tests/levenshtein_distance_test.cairo b/packages/searching/src/tests/levenshtein_distance_test.cairo index 9a40b8bc..6bed89c3 100644 --- a/packages/searching/src/tests/levenshtein_distance_test.cairo +++ b/packages/searching/src/tests/levenshtein_distance_test.cairo @@ -17,7 +17,7 @@ fn bm_search_test_1() { arr2.append_byte(0x47_u8); let dist = levenshtein_distance(@arr1, @arr2); - assert_eq!(dist, 2, "invalid result"); + assert_eq!(dist, 2); } #[test] @@ -27,7 +27,7 @@ fn bm_search_test_2() { let mut arr2: ByteArray = Default::default(); let dist = levenshtein_distance(@arr1, @arr2); - assert_eq!(dist, 0, "invalid result"); + assert_eq!(dist, 0); } #[test] @@ -38,7 +38,7 @@ fn bm_search_test_3() { arr2.append_byte(0x61_u8); let dist = levenshtein_distance(@arr1, @arr2); - assert_eq!(dist, 1, "invalid result"); + assert_eq!(dist, 1); } #[test] @@ -49,7 +49,7 @@ fn bm_search_test_4() { let mut arr2: ByteArray = Default::default(); let dist = levenshtein_distance(@arr1, @arr2); - assert_eq!(dist, 1, "invalid result"); + assert_eq!(dist, 1); } #[test] @@ -62,7 +62,7 @@ fn bm_search_test_5() { arr2.append_byte(0x61_u8); let dist = levenshtein_distance(@arr1, @arr2); - assert_eq!(dist, 1, "invalid result"); + assert_eq!(dist, 1); } #[test] @@ -86,7 +86,7 @@ fn bm_search_test_6() { arr2.append_byte(0x72_u8); let dist = levenshtein_distance(@arr1, @arr2); - assert_eq!(dist, 0, "invalid result"); + assert_eq!(dist, 0); } #[test] @@ -110,5 +110,5 @@ fn bm_search_test_7() { arr2.append_byte(0x6f_u8); let dist = levenshtein_distance(@arr1, @arr2); - assert_eq!(dist, 6, "invalid result"); + assert_eq!(dist, 6); } diff --git a/packages/sorting/src/tests/bubble_sort_test.cairo b/packages/sorting/src/tests/bubble_sort_test.cairo index 14ce6c27..88798b90 100644 --- a/packages/sorting/src/tests/bubble_sort_test.cairo +++ b/packages/sorting/src/tests/bubble_sort_test.cairo @@ -8,7 +8,7 @@ fn bubble_sort_test() { let sorted = BubbleSort::sort(data); - assert_eq!(sorted.span(), correct.span(), "invalid result"); + assert_eq!(sorted.span(), correct.span()); } @@ -20,7 +20,7 @@ fn bubble_sort_test_empty() { let sorted = BubbleSort::sort(data); - assert_eq!(sorted.span(), correct.span(), "invalid result"); + assert_eq!(sorted.span(), correct.span()); } #[test] @@ -31,7 +31,7 @@ fn bubble_sort_test_one_element() { let sorted = BubbleSort::sort(data); - assert_eq!(sorted.span(), correct.span(), "invalid result"); + assert_eq!(sorted.span(), correct.span()); } #[test] @@ -42,7 +42,7 @@ fn bubble_sort_test_pre_sorted() { let sorted = BubbleSort::sort(data); - assert_eq!(sorted.span(), correct.span(), "invalid result"); + assert_eq!(sorted.span(), correct.span()); } #[test] @@ -53,7 +53,7 @@ fn bubble_sort_test_pre_sorted_decreasing() { let sorted = BubbleSort::sort(data); - assert_eq!(sorted.span(), correct.span(), "invalid result"); + assert_eq!(sorted.span(), correct.span()); } #[test] @@ -64,7 +64,7 @@ fn bubble_sort_test_pre_sorted_2_same_values() { let sorted = BubbleSort::sort(data); - assert_eq!(sorted.span(), correct.span(), "invalid result"); + assert_eq!(sorted.span(), correct.span()); } #[test] @@ -75,5 +75,5 @@ fn bubble_sort_test_2_same_values() { let sorted = BubbleSort::sort(data); - assert_eq!(sorted.span(), correct.span(), "invalid result"); + assert_eq!(sorted.span(), correct.span()); } diff --git a/packages/sorting/src/tests/merge_sort_test.cairo b/packages/sorting/src/tests/merge_sort_test.cairo index 250eae95..f8fcb242 100644 --- a/packages/sorting/src/tests/merge_sort_test.cairo +++ b/packages/sorting/src/tests/merge_sort_test.cairo @@ -8,7 +8,7 @@ fn merge_sort_test() { let sorted = MergeSort::sort(data); - assert_eq!(sorted, correct, "invalid result"); + assert_eq!(sorted, correct); } #[test] @@ -19,7 +19,7 @@ fn merge_sort_test_2_pre_sorted_decreasing() { let sorted = MergeSort::sort(data); - assert_eq!(sorted, correct, "invalid result"); + assert_eq!(sorted, correct); } #[test] @@ -31,7 +31,7 @@ fn merge_sort_test_empty() { let sorted = MergeSort::sort(data); - assert_eq!(sorted, correct, "invalid result"); + assert_eq!(sorted, correct); } #[test] @@ -42,7 +42,7 @@ fn merge_sort_test_one_element() { let sorted = MergeSort::sort(data); - assert_eq!(sorted, correct, "invalid result"); + assert_eq!(sorted, correct); } #[test] @@ -53,7 +53,7 @@ fn merge_sort_test_pre_sorted() { let sorted = MergeSort::sort(data); - assert_eq!(sorted, correct, "invalid result"); + assert_eq!(sorted, correct); } #[test] @@ -64,7 +64,7 @@ fn merge_sort_test_2_same_values() { let sorted = MergeSort::sort(data); - assert_eq!(sorted, correct, "invalid result"); + assert_eq!(sorted, correct); } #[test] @@ -75,5 +75,5 @@ fn merge_sort_test_2_same_values_pre_sorted() { let sorted = MergeSort::sort(data); - assert_eq!(sorted, correct, "invalid result"); + assert_eq!(sorted, correct); } diff --git a/packages/storage/src/tests/list_test.cairo b/packages/storage/src/tests/list_test.cairo index aa03325b..a0ea8ea7 100644 --- a/packages/storage/src/tests/list_test.cairo +++ b/packages/storage/src/tests/list_test.cairo @@ -144,7 +144,7 @@ fn mock_addr() -> ContractAddress { #[available_gas(100000000)] fn test_deploy() { let contract = deploy_mock(); - assert_eq!(contract.do_get_len(), (0, 0), "do_get_len"); + assert_eq!(contract.do_get_len(), (0, 0)); } #[test] @@ -154,21 +154,21 @@ fn test_new_initializes_empty_list() { let addresses_address = contract_state.addresses.as_ptr().__storage_pointer_address__; let addresses_list = ListTrait::::new(0, addresses_address); - assert_eq!(addresses_list.address_domain, 0, "Address domain should be 0"); - assert_eq!(addresses_list.len(), 0, "Initial length should be 0"); - assert_eq!(addresses_list.base.into(), addresses_address, "Base address mismatch"); - assert_eq!(addresses_list.storage_size(), 1, "Storage size should be 1"); + assert_eq!(addresses_list.address_domain, 0); + assert_eq!(addresses_list.len(), 0); + assert_eq!(addresses_list.base.into(), addresses_address); + assert_eq!(addresses_list.storage_size(), 1); let numbers_address = contract_state.numbers.as_ptr().__storage_pointer_address__; let numbers_list = ListTrait::::new(0, numbers_address); - assert_eq!(numbers_list.address_domain, 0, "Address domain should be 0"); - assert_eq!(numbers_list.len(), 0, "Initial length should be 0"); - assert_eq!(numbers_list.base.into(), numbers_address, "Base address mismatch"); - assert_eq!(numbers_list.storage_size(), 2, "Storage size should be 2"); + assert_eq!(numbers_list.address_domain, 0); + assert_eq!(numbers_list.len(), 0); + assert_eq!(numbers_list.base.into(), numbers_address); + assert_eq!(numbers_list.storage_size(), 2); // Check if both addresses and numbers lists are initialized to be empty - assert_eq!(contract_state.do_get_len(), (0, 0), "Initial lengths should be 0"); - assert_eq!(contract_state.do_is_empty(), (true, true), "Lists should be empty"); + assert_eq!(contract_state.do_get_len(), (0, 0)); + assert_eq!(contract_state.do_is_empty(), (true, true)); } #[test] @@ -186,11 +186,11 @@ fn test_new_then_fill_list() { let _ = numbers_list.append(1); let _ = numbers_list.append(2); - assert_eq!(addresses_list.len(), 1, "Addresses length should be 1"); - assert_eq!(numbers_list.len(), 2, "Numbers length should be 2"); + assert_eq!(addresses_list.len(), 1); + assert_eq!(numbers_list.len(), 2); - assert_eq!(contract_state.do_get_len(), (1, 2), "Lengths should be (1,2)"); - assert_eq!(contract_state.do_is_empty(), (false, false), "Lists should not be empty"); + assert_eq!(contract_state.do_get_len(), (1, 2)); + assert_eq!(contract_state.do_is_empty(), (false, false)); } #[test] @@ -200,10 +200,10 @@ fn test_fetch_empty_list() { let empty_list = ListTrait::::fetch(0, storage_address).expect('List fetch failed'); - assert_eq!(empty_list.address_domain, 0, "Address domain should be 0"); - assert_eq!(empty_list.len(), 0, "Length should be 0"); - assert_eq!(empty_list.base.into(), storage_address, "Base address mismatch"); - assert_eq!(empty_list.storage_size(), 1, "Storage size should be 1"); + assert_eq!(empty_list.address_domain, 0); + assert_eq!(empty_list.len(), 0); + assert_eq!(empty_list.base.into(), storage_address); + assert_eq!(empty_list.storage_size(), 1); } #[test] @@ -212,22 +212,22 @@ fn test_fetch_existing_list() { let mut contract_state = AListHolder::contract_state_for_testing(); let mock_addr = mock_addr(); - assert_eq!(contract_state.do_append(mock_addr, 10), (0, 0), "1st append idx"); - assert_eq!(contract_state.do_append(mock_addr, 20), (1, 1), "2nd append idx"); + assert_eq!(contract_state.do_append(mock_addr, 10), (0, 0)); + assert_eq!(contract_state.do_append(mock_addr, 20), (1, 1)); let addresses_address = contract_state.addresses.as_ptr().__storage_pointer_address__; let addresses_list = ListTrait::::fetch(0, addresses_address) .expect('List fetch failed'); - assert_eq!(addresses_list.address_domain, 0, "Address domain should be 0"); - assert_eq!(addresses_list.len(), 2, "Length should be 2"); - assert_eq!(addresses_list.base.into(), addresses_address, "Base address mismatch"); - assert_eq!(addresses_list.storage_size(), 1, "Storage size should be 1"); + assert_eq!(addresses_list.address_domain, 0); + assert_eq!(addresses_list.len(), 2); + assert_eq!(addresses_list.base.into(), addresses_address); + assert_eq!(addresses_list.storage_size(), 1); let numbers_address = contract_state.numbers.as_ptr().__storage_pointer_address__; let numbers_list = ListTrait::::fetch(0, numbers_address).expect('List fetch failed'); - assert_eq!(numbers_list.address_domain, 0, "Address domain should be 0"); - assert_eq!(numbers_list.len(), 2, "Length should be 2"); - assert_eq!(numbers_list.base.into(), numbers_address, "Base address mismatch"); + assert_eq!(numbers_list.address_domain, 0); + assert_eq!(numbers_list.len(), 2); + assert_eq!(numbers_list.base.into(), numbers_address); } #[test] @@ -235,9 +235,9 @@ fn test_fetch_existing_list() { fn test_is_empty() { let contract = deploy_mock(); - assert_eq!(contract.do_is_empty(), (true, true), "is empty"); + assert_eq!(contract.do_is_empty(), (true, true)); contract.do_append(mock_addr(), 1337); - assert_eq!(contract.do_is_empty(), (false, false), "is not empty"); + assert_eq!(contract.do_is_empty(), (false, false)); } #[test] @@ -245,9 +245,9 @@ fn test_is_empty() { fn test_append_few() { let contract = deploy_mock(); - assert_eq!(contract.do_append(mock_addr(), 10), (0, 0), "1st append idx"); - assert_eq!(contract.do_append(mock_addr(), 20), (1, 1), "2nd append idx"); - assert_eq!(contract.do_get_len(), (2, 2), "len"); + assert_eq!(contract.do_append(mock_addr(), 10), (0, 0)); + assert_eq!(contract.do_append(mock_addr(), 20), (1, 1)); + assert_eq!(contract.do_get_len(), (2, 2)); } #[test] @@ -266,16 +266,16 @@ fn test_append_get_many() { index += 1; }; - assert_eq!(contract.do_get_len(), (max, max), "len"); + assert_eq!(contract.do_get_len(), (max, max)); // test getting many index = 0; while (index != max) { let (some_addr, some_number) = contract.do_get(index); assert!(some_addr.is_some(), "addr is some"); - assert_eq!(some_addr.unwrap(), mock_addr, "addr"); + assert_eq!(some_addr.unwrap(), mock_addr); assert!(some_number.is_some(), "number is some"); - assert_eq!(some_number.unwrap(), index.into(), "number"); + assert_eq!(some_number.unwrap(), index.into()); index += 1; } @@ -293,21 +293,21 @@ fn test_get_pass() { let (some_addr0, some_number0) = contract.do_get(0); assert!(some_addr0.is_some(), "addr0 is some"); - assert_eq!(some_addr0.unwrap(), mock_addr, "addr0"); + assert_eq!(some_addr0.unwrap(), mock_addr); assert!(some_number0.is_some(), "number0 is some"); - assert_eq!(some_number0.unwrap(), 100, "number0"); + assert_eq!(some_number0.unwrap(), 100); let (some_addr1, some_number1) = contract.do_get(1); assert!(some_addr1.is_some(), "addr1 is some"); - assert_eq!(some_addr1.unwrap(), mock_addr, "addr1"); + assert_eq!(some_addr1.unwrap(), mock_addr); assert!(some_number1.is_some(), "number1 is some"); - assert_eq!(some_number1.unwrap(), 200, "number1"); + assert_eq!(some_number1.unwrap(), 200); let (some_addr2, some_number2) = contract.do_get(2); assert!(some_addr2.is_some(), "addr2 is some"); - assert_eq!(some_addr2.unwrap(), mock_addr, "addr2"); + assert_eq!(some_addr2.unwrap(), mock_addr); assert!(some_number2.is_some(), "number2 is some"); - assert_eq!(some_number2.unwrap(), 300, "number2"); + assert_eq!(some_number2.unwrap(), 300); } #[test] @@ -339,9 +339,9 @@ fn test_get_index_pass() { contract.do_append(mock_addr, 200); // idx 1 contract.do_append(mock_addr, 300); // idx 2 - assert_eq!(contract.do_get_index(0), (mock_addr, 100), "idx 0"); - assert_eq!(contract.do_get_index(1), (mock_addr, 200), "idx 1"); - assert_eq!(contract.do_get_index(2), (mock_addr, 300), "idx 2"); + assert_eq!(contract.do_get_index(0), (mock_addr, 100)); + assert_eq!(contract.do_get_index(1), (mock_addr, 200)); + assert_eq!(contract.do_get_index(2), (mock_addr, 300)); } #[test] @@ -367,10 +367,10 @@ fn test_set_pass() { contract.do_set(0, diff_addr, 100); contract.do_set(2, diff_addr, 300); - assert_eq!(contract.do_get_index(0), (diff_addr, 100), "new at 0"); - assert_eq!(contract.do_get_index(1), (mock_addr, 20), "old at 1"); - assert_eq!(contract.do_get_index(2), (diff_addr, 300), "new at 2"); - assert_eq!(contract.do_get_len(), (3, 3), "len"); + assert_eq!(contract.do_get_index(0), (diff_addr, 100)); + assert_eq!(contract.do_get_index(1), (mock_addr, 20)); + assert_eq!(contract.do_get_index(2), (diff_addr, 300)); + assert_eq!(contract.do_get_len(), (3, 3)); } #[test] @@ -391,28 +391,28 @@ fn test_pop_front_pass() { contract.do_append(mock_addr, 200); // idx 1 contract.do_append(mock_addr, 300); // idx 2 - assert_eq!(contract.do_get_len(), (3, 3), "len"); + assert_eq!(contract.do_get_len(), (3, 3)); let (pop_addr, pop_number) = contract.do_pop_front(); assert!(pop_addr.is_some(), "pop addr 2 is some"); - assert_eq!(pop_addr.unwrap(), mock_addr, "addr 2"); + assert_eq!(pop_addr.unwrap(), mock_addr); assert!(pop_number.is_some(), "pop number 2 is some"); - assert_eq!(pop_number.unwrap(), 300, "number 2"); - assert_eq!(contract.do_get_len(), (2, 2), "len"); + assert_eq!(pop_number.unwrap(), 300); + assert_eq!(contract.do_get_len(), (2, 2)); let (pop_addr, pop_number) = contract.do_pop_front(); assert!(pop_addr.is_some(), "pop addr 1 is some"); - assert_eq!(pop_addr.unwrap(), mock_addr, "addr 1"); + assert_eq!(pop_addr.unwrap(), mock_addr); assert!(pop_number.is_some(), "pop number 1 is some"); - assert_eq!(pop_number.unwrap(), 200, "number 1"); - assert_eq!(contract.do_get_len(), (1, 1), "len"); + assert_eq!(pop_number.unwrap(), 200); + assert_eq!(contract.do_get_len(), (1, 1)); let (pop_addr, pop_number) = contract.do_pop_front(); assert!(pop_addr.is_some(), "pop addr 0 is some"); - assert_eq!(pop_addr.unwrap(), mock_addr, "addr 0"); + assert_eq!(pop_addr.unwrap(), mock_addr); assert!(pop_number.is_some(), "pop number 0 is some"); - assert_eq!(pop_number.unwrap(), 100, "number 0"); - assert_eq!(contract.do_get_len(), (0, 0), "len"); + assert_eq!(pop_number.unwrap(), 100); + assert_eq!(contract.do_get_len(), (0, 0)); } #[test] @@ -431,19 +431,19 @@ fn test_pop_append() { let contract = deploy_mock(); // write something contract.do_append(mock_addr(), 10); - assert_eq!(contract.do_get_len(), (1, 1), "len 1"); + assert_eq!(contract.do_get_len(), (1, 1)); // pop it contract.do_pop_front(); - assert_eq!(contract.do_get_len(), (0, 0), "len 2"); + assert_eq!(contract.do_get_len(), (0, 0)); let diff_addr = starknet::contract_address_const::<'bye'>(); // append again and check if it overwrites contract.do_append(diff_addr, 9000); - assert_eq!(contract.do_get_len(), (1, 1), "len 3"); + assert_eq!(contract.do_get_len(), (1, 1)); let (addr, number) = contract.do_get_index(0); - assert_eq!(addr, diff_addr, "addr"); - assert_eq!(number, 9000, "number"); + assert_eq!(addr, diff_addr); + assert_eq!(number, 9000); } #[test] @@ -458,10 +458,10 @@ fn test_array_pass() { let (array_addr, array_number) = contract.do_array(); - assert_eq!((array_addr.len(), array_number.len()), contract.do_get_len(), "lens mismatch"); - assert_eq!((*array_addr[0], *array_number[0]), contract.do_get_index(0), "idx 0"); - assert_eq!((*array_addr[1], *array_number[1]), contract.do_get_index(1), "idx 1"); - assert_eq!((*array_addr[2], *array_number[2]), contract.do_get_index(2), "idx 2"); + assert_eq!((array_addr.len(), array_number.len()), contract.do_get_len()); + assert_eq!((*array_addr[0], *array_number[0]), contract.do_get_index(0)); + assert_eq!((*array_addr[1], *array_number[1]), contract.do_get_index(1)); + assert_eq!((*array_addr[2], *array_number[2]), contract.do_get_index(2)); } #[test] @@ -470,7 +470,7 @@ fn test_array_empty() { let contract = deploy_mock(); let (array_addr, array_number) = contract.do_array(); - assert_eq!((array_addr.len(), array_number.len()), (0, 0), "lens must be null"); + assert_eq!((array_addr.len(), array_number.len()), (0, 0)); } #[test] @@ -483,7 +483,7 @@ fn test_array_clean() { contract.do_append(mock_addr, 200); // idx 1 contract.do_append(mock_addr, 300); // idx 2 contract.do_clean(); - assert_eq!(contract.do_get_len(), (0, 0), "is empty"); + assert_eq!(contract.do_get_len(), (0, 0)); } #[test] @@ -491,11 +491,11 @@ fn test_array_clean() { fn test_array_clean_with_empty_array() { let contract = deploy_mock(); - assert_eq!(contract.do_get_len(), (0, 0), "is empty"); + assert_eq!(contract.do_get_len(), (0, 0)); contract.do_clean(); - assert_eq!(contract.do_get_len(), (0, 0), "is still empty"); + assert_eq!(contract.do_get_len(), (0, 0)); } #[test] @@ -507,13 +507,13 @@ fn test_array_get_value_after_clean() { contract.do_append(mock_addr, 100); // idx 0 let (addr, number) = contract.do_get(0); assert!(addr.is_some(), "addr is some"); - assert_eq!(addr.unwrap(), mock_addr, "should be mock_addr"); + assert_eq!(addr.unwrap(), mock_addr); assert!(number.is_some(), "number is some"); - assert_eq!(number.unwrap(), 100, "should be 100"); + assert_eq!(number.unwrap(), 100); contract.do_clean(); - assert_eq!(contract.do_get_len(), (0, 0), "len"); + assert_eq!(contract.do_get_len(), (0, 0)); let (addr, number) = contract.do_get(0); assert!(addr.is_none(), "addr is none"); @@ -526,7 +526,7 @@ fn test_append_array_empty() { let contract = deploy_mock(); contract.do_append_span(array![], array![]); - assert_eq!(contract.do_is_empty(), (true, true), "should be empty"); + assert_eq!(contract.do_is_empty(), (true, true)); } #[test] @@ -535,17 +535,17 @@ fn test_append_span_existing_list() { let contract = deploy_mock(); let mock_addr = mock_addr(); - assert_eq!(contract.do_append(mock_addr, 10), (0, 0), "1st append idx"); - assert_eq!(contract.do_append(mock_addr, 20), (1, 1), "2nd append idx"); - assert_eq!(contract.do_get_len(), (2, 2), "len"); - assert_eq!(contract.do_get_index(0), (mock_addr, 10), "idx 0"); - assert_eq!(contract.do_get_index(1), (mock_addr, 20), "idx 1"); + assert_eq!(contract.do_append(mock_addr, 10), (0, 0)); + assert_eq!(contract.do_append(mock_addr, 20), (1, 1)); + assert_eq!(contract.do_get_len(), (2, 2)); + assert_eq!(contract.do_get_index(0), (mock_addr, 10)); + assert_eq!(contract.do_get_index(1), (mock_addr, 20)); contract.do_append_span(array![mock_addr], array![30]); let (a, b) = contract.do_get_len(); - assert_eq!((a, b), (3, 3), "len"); + assert_eq!((a, b), (3, 3)); - assert_eq!(contract.do_get_index(0), (mock_addr, 10), "idx 0"); - assert_eq!(contract.do_get_index(1), (mock_addr, 20), "idx 1"); - assert_eq!(contract.do_get_index(2), (mock_addr, 30), "idx 2"); + assert_eq!(contract.do_get_index(0), (mock_addr, 10)); + assert_eq!(contract.do_get_index(1), (mock_addr, 20)); + assert_eq!(contract.do_get_index(2), (mock_addr, 30)); }