Skip to content

Commit

Permalink
test(core): add test for Mfr item new()
Browse files Browse the repository at this point in the history
  • Loading branch information
ziteh committed Aug 4, 2024
1 parent 323cb81 commit 836b9ae
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions elebox-core/src/manufacturer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -538,4 +538,36 @@ mod tests {
assert_eq!(item.alias, None);
assert_eq!(item.url, None);
}

#[test]
fn test_new_item_some() {
// Arrange
const NAME: &str = "TestName";
const ALIAS: Option<&str> = Some("TestAlias");
const URL: Option<&str> = Some("https://test.com");

// Act
let item = Manufacturer::new(NAME, ALIAS, URL);

// Assert
assert_eq!(item.name, NAME);
assert_eq!(item.alias.as_deref(), ALIAS);
assert_eq!(item.url.as_deref(), URL);
}

#[test]
fn test_new_item_none() {
// Arrange
const NAME: &str = "TestName";
const ALIAS: Option<&str> = None;
const URL: Option<&str> = None;

// Act
let item = Manufacturer::new(NAME, ALIAS, URL);

// Assert
assert_eq!(item.name, NAME);
assert_eq!(item.alias.as_deref(), ALIAS);
assert_eq!(item.url.as_deref(), URL);
}
}

0 comments on commit 836b9ae

Please sign in to comment.