Skip to content

Commit f38c619

Browse files
committed
Add inequality test for RandomName
1 parent e2f339a commit f38c619

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

src/random_name.rs

+10-3
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,15 @@ impl RandomName {
2323
name: format!("{}{}{:x}{:x}{:x}", prefix, pid, marker, secs, subsec_nanos),
2424
}
2525
}
26+
27+
pub fn as_str(&self) -> &str {
28+
self.name.as_str()
29+
}
2630
}
2731

2832
impl AsRef<str> for RandomName {
2933
fn as_ref(&self) -> &str {
30-
&self.name
34+
self.as_str()
3135
}
3236
}
3337

@@ -37,7 +41,10 @@ mod tests {
3741

3842
#[test]
3943
fn test_random_name() {
40-
let name = RandomName::new("test");
41-
assert!(name.as_ref().starts_with("test"))
44+
let first = RandomName::new("test");
45+
let second = RandomName::new("test");
46+
assert!(first.as_str().starts_with("test"));
47+
assert!(second.as_str().starts_with("test"));
48+
assert_ne!(first.as_str(), second.as_str());
4249
}
4350
}

0 commit comments

Comments
 (0)