diff --git a/starknet/src/types/user_address.cairo b/starknet/src/types/user_address.cairo index 7753f9e1..b584dcf3 100644 --- a/starknet/src/types/user_address.cairo +++ b/starknet/src/types/user_address.cairo @@ -74,3 +74,24 @@ impl UserAddressZeroable of Zeroable { !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'); + } +}