summaryrefslogtreecommitdiffstats
path: root/third_party/rust/semver/tests/test_identifier.rs
diff options
context:
space:
mode:
Diffstat (limited to 'third_party/rust/semver/tests/test_identifier.rs')
-rw-r--r--third_party/rust/semver/tests/test_identifier.rs45
1 files changed, 45 insertions, 0 deletions
diff --git a/third_party/rust/semver/tests/test_identifier.rs b/third_party/rust/semver/tests/test_identifier.rs
new file mode 100644
index 0000000000..dc888c9c10
--- /dev/null
+++ b/third_party/rust/semver/tests/test_identifier.rs
@@ -0,0 +1,45 @@
+#![allow(
+ clippy::eq_op,
+ clippy::needless_pass_by_value,
+ clippy::toplevel_ref_arg,
+ clippy::wildcard_imports
+)]
+
+mod util;
+
+use crate::util::*;
+use semver::Prerelease;
+
+#[test]
+fn test_new() {
+ fn test(identifier: Prerelease, expected: &str) {
+ assert_eq!(identifier.is_empty(), expected.is_empty());
+ assert_eq!(identifier.len(), expected.len());
+ assert_eq!(identifier.as_str(), expected);
+ assert_eq!(identifier, identifier);
+ assert_eq!(identifier, identifier.clone());
+ }
+
+ let ref mut string = String::new();
+ let limit = if cfg!(miri) { 40 } else { 280 }; // miri is slow
+ for _ in 0..limit {
+ test(prerelease(string), string);
+ string.push('1');
+ }
+
+ if !cfg!(miri) {
+ let ref string = string.repeat(20000);
+ test(prerelease(string), string);
+ }
+}
+
+#[test]
+fn test_eq() {
+ assert_eq!(prerelease("-"), prerelease("-"));
+ assert_ne!(prerelease("a"), prerelease("aa"));
+ assert_ne!(prerelease("aa"), prerelease("a"));
+ assert_ne!(prerelease("aaaaaaaaa"), prerelease("a"));
+ assert_ne!(prerelease("a"), prerelease("aaaaaaaaa"));
+ assert_ne!(prerelease("aaaaaaaaa"), prerelease("bbbbbbbbb"));
+ assert_ne!(build_metadata("1"), build_metadata("001"));
+}