|
| 1 | +#![cfg(test)] |
| 2 | + |
| 3 | +use crate::types::*; |
| 4 | + |
| 5 | +#[test] |
| 6 | +fn test_asset_type_variants() { |
| 7 | + // Test that all AssetType variants can be created |
| 8 | + let physical = AssetType::Physical; |
| 9 | + let digital = AssetType::Digital; |
| 10 | + |
| 11 | + // Test equality |
| 12 | + assert_eq!(physical, AssetType::Physical); |
| 13 | + assert_eq!(digital, AssetType::Digital); |
| 14 | + assert_ne!(physical, digital); |
| 15 | + |
| 16 | + // Test cloning |
| 17 | + let physical_clone = physical.clone(); |
| 18 | + assert_eq!(physical, physical_clone); |
| 19 | +} |
| 20 | + |
| 21 | +#[test] |
| 22 | +fn test_asset_status_variants() { |
| 23 | + // Test that all AssetStatus variants can be created |
| 24 | + let active = AssetStatus::Active; |
| 25 | + let in_maintenance = AssetStatus::InMaintenance; |
| 26 | + let disposed = AssetStatus::Disposed; |
| 27 | + |
| 28 | + // Test equality |
| 29 | + assert_eq!(active, AssetStatus::Active); |
| 30 | + assert_eq!(in_maintenance, AssetStatus::InMaintenance); |
| 31 | + assert_eq!(disposed, AssetStatus::Disposed); |
| 32 | + |
| 33 | + // Test that they are different |
| 34 | + assert_ne!(active, in_maintenance); |
| 35 | + assert_ne!(active, disposed); |
| 36 | + assert_ne!(in_maintenance, disposed); |
| 37 | +} |
| 38 | + |
| 39 | +#[test] |
| 40 | +fn test_action_type_variants() { |
| 41 | + // Test that all ActionType variants can be created |
| 42 | + let procured = ActionType::Procured; |
| 43 | + let transferred = ActionType::Transferred; |
| 44 | + let maintained = ActionType::Maintained; |
| 45 | + let disposed = ActionType::Disposed; |
| 46 | + let checked_in = ActionType::CheckedIn; |
| 47 | + let checked_out = ActionType::CheckedOut; |
| 48 | + |
| 49 | + // Test equality |
| 50 | + assert_eq!(procured, ActionType::Procured); |
| 51 | + assert_eq!(transferred, ActionType::Transferred); |
| 52 | + assert_eq!(maintained, ActionType::Maintained); |
| 53 | + assert_eq!(disposed, ActionType::Disposed); |
| 54 | + assert_eq!(checked_in, ActionType::CheckedIn); |
| 55 | + assert_eq!(checked_out, ActionType::CheckedOut); |
| 56 | + |
| 57 | + // Test that they are different |
| 58 | + assert_ne!(procured, transferred); |
| 59 | + assert_ne!(checked_in, checked_out); |
| 60 | +} |
| 61 | + |
| 62 | +#[test] |
| 63 | +fn test_plan_type_variants() { |
| 64 | + // Test that all PlanType variants can be created |
| 65 | + let basic = PlanType::Basic; |
| 66 | + let pro = PlanType::Pro; |
| 67 | + let enterprise = PlanType::Enterprise; |
| 68 | + |
| 69 | + // Test equality |
| 70 | + assert_eq!(basic, PlanType::Basic); |
| 71 | + assert_eq!(pro, PlanType::Pro); |
| 72 | + assert_eq!(enterprise, PlanType::Enterprise); |
| 73 | + |
| 74 | + // Test that they are different |
| 75 | + assert_ne!(basic, pro); |
| 76 | + assert_ne!(pro, enterprise); |
| 77 | + assert_ne!(basic, enterprise); |
| 78 | +} |
| 79 | + |
| 80 | +#[test] |
| 81 | +fn test_subscription_status_variants() { |
| 82 | + // Test that all SubscriptionStatus variants can be created |
| 83 | + let active = SubscriptionStatus::Active; |
| 84 | + let expired = SubscriptionStatus::Expired; |
| 85 | + let cancelled = SubscriptionStatus::Cancelled; |
| 86 | + |
| 87 | + // Test equality |
| 88 | + assert_eq!(active, SubscriptionStatus::Active); |
| 89 | + assert_eq!(expired, SubscriptionStatus::Expired); |
| 90 | + assert_eq!(cancelled, SubscriptionStatus::Cancelled); |
| 91 | + |
| 92 | + // Test that they are different |
| 93 | + assert_ne!(active, expired); |
| 94 | + assert_ne!(active, cancelled); |
| 95 | + assert_ne!(expired, cancelled); |
| 96 | +} |
| 97 | + |
| 98 | +#[test] |
| 99 | +fn test_types_can_be_used_in_functions() { |
| 100 | + // Test that types can be used as function parameters and return values |
| 101 | + fn get_asset_type() -> AssetType { |
| 102 | + AssetType::Physical |
| 103 | + } |
| 104 | + |
| 105 | + fn process_action(action: ActionType) -> bool { |
| 106 | + match action { |
| 107 | + ActionType::Procured => true, |
| 108 | + ActionType::Transferred => true, |
| 109 | + ActionType::Maintained => true, |
| 110 | + ActionType::Disposed => false, |
| 111 | + ActionType::CheckedIn => true, |
| 112 | + ActionType::CheckedOut => true, |
| 113 | + } |
| 114 | + } |
| 115 | + |
| 116 | + let asset_type = get_asset_type(); |
| 117 | + assert_eq!(asset_type, AssetType::Physical); |
| 118 | + |
| 119 | + let result = process_action(ActionType::Procured); |
| 120 | + assert!(result); |
| 121 | + |
| 122 | + let result = process_action(ActionType::Disposed); |
| 123 | + assert!(!result); |
| 124 | +} |
0 commit comments