Skip to content

Commit

Permalink
chore: UserAddress zeroable tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Orlando committed Aug 18, 2023
1 parent ec78c93 commit 869f831
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions starknet/src/types/user_address.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -74,3 +74,24 @@ impl UserAddressZeroable of Zeroable<UserAddress> {
!self.is_zero()
}
}

#[cfg(test)]
mod tests {
use zeroable::Zeroable;
use super::{UserAddress, UserAddressZeroable};
use starknet::{EthAddress, contract_address_const};

#[test]
fn test_is_zero() {
assert(UserAddress::Starknet(contract_address_const::<0>()).is_zero(), 'is not zero');
assert(UserAddress::Ethereum(EthAddress { address: 0 }).is_zero(), 'is not zero');
assert(UserAddress::Custom(0_u256).is_zero(), 'is not zero');
}

#[test]
fn test_is_non_zero() {
assert(UserAddress::Starknet(contract_address_const::<1>()).is_non_zero(), 'is zero');
assert(UserAddress::Ethereum(EthAddress { address: 1 }).is_non_zero(), 'is zero');
assert(UserAddress::Custom(1_u256).is_non_zero(), 'is zero');
}
}

0 comments on commit 869f831

Please sign in to comment.