Skip to content

Commit d438a77

Browse files
committed
Streamline more tests.
Several of them sort or inspect their vectors unnecessarily. We can just do `Vec` literal equality tests.
1 parent fc54a45 commit d438a77

File tree

1 file changed

+15
-25
lines changed

1 file changed

+15
-25
lines changed

crates/nvvm/src/lib.rs

Lines changed: 15 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1199,47 +1199,37 @@ mod tests {
11991199
);
12001200

12011201
// Architecture with all three variants
1202-
let mut compute120_variants = NvvmArch::Compute120.get_variants();
1203-
compute120_variants.sort_by_key(|v| format!("{:?}", v));
1204-
assert_eq!(
1205-
compute120_variants,
1206-
vec![
1207-
NvvmArch::Compute120,
1208-
NvvmArch::Compute120a,
1209-
NvvmArch::Compute120f
1210-
]
1211-
);
1212-
1213-
// Getting variants from a variant returns all variants
1214-
let compute120f_variants = NvvmArch::Compute120f.get_variants();
1215-
assert_eq!(compute120f_variants.len(), 3);
1216-
assert!(compute120f_variants.contains(&NvvmArch::Compute120));
1217-
assert!(compute120f_variants.contains(&NvvmArch::Compute120f));
1218-
assert!(compute120f_variants.contains(&NvvmArch::Compute120a));
1202+
let expected120 = vec![
1203+
NvvmArch::Compute120,
1204+
NvvmArch::Compute120f,
1205+
NvvmArch::Compute120a,
1206+
];
1207+
assert_eq!(NvvmArch::Compute120.get_variants(), expected120);
1208+
assert_eq!(NvvmArch::Compute120f.get_variants(), expected120);
1209+
assert_eq!(NvvmArch::Compute120a.get_variants(), expected120);
12191210
}
12201211

12211212
#[test]
12221213
fn nvvm_arch_variants_for_capability() {
12231214
use crate::NvvmArch;
12241215

12251216
// Capability with single variant
1226-
let compute75_variants = NvvmArch::variants_for_capability(75);
1227-
assert_eq!(compute75_variants, vec![NvvmArch::Compute75]);
1217+
assert_eq!(
1218+
NvvmArch::variants_for_capability(75),
1219+
vec![NvvmArch::Compute75]
1220+
);
12281221

12291222
// Capability with multiple variants
1230-
let mut compute101_variants = NvvmArch::variants_for_capability(101);
1231-
compute101_variants.sort_by_key(|v| format!("{:?}", v));
12321223
assert_eq!(
1233-
compute101_variants,
1224+
NvvmArch::variants_for_capability(101),
12341225
vec![
12351226
NvvmArch::Compute101,
1227+
NvvmArch::Compute101f,
12361228
NvvmArch::Compute101a,
1237-
NvvmArch::Compute101f
12381229
]
12391230
);
12401231

12411232
// Non-existent capability
1242-
let compute999_variants = NvvmArch::variants_for_capability(999);
1243-
assert!(compute999_variants.is_empty());
1233+
assert!(NvvmArch::variants_for_capability(999).is_empty());
12441234
}
12451235
}

0 commit comments

Comments
 (0)