Skip to content

Commit 6d28b86

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 5512f02 commit 6d28b86

File tree

1 file changed

+16
-28
lines changed

1 file changed

+16
-28
lines changed

crates/nvvm/src/lib.rs

Lines changed: 16 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1193,55 +1193,43 @@ mod tests {
11931193
assert_eq!(compute80_variants, vec![NvvmArch::Compute80]);
11941194

11951195
// Architecture with architecture and base variants
1196-
let mut compute90_variants = NvvmArch::Compute90.get_variants();
1197-
compute90_variants.sort_by_key(|v| format!("{:?}", v));
11981196
assert_eq!(
1199-
compute90_variants,
1197+
NvvmArch::Compute90.get_variants(),
12001198
vec![NvvmArch::Compute90, NvvmArch::Compute90a]
12011199
);
12021200

12031201
// Architecture with all three variants
1204-
let mut compute120_variants = NvvmArch::Compute120.get_variants();
1205-
compute120_variants.sort_by_key(|v| format!("{:?}", v));
1206-
assert_eq!(
1207-
compute120_variants,
1208-
vec![
1209-
NvvmArch::Compute120,
1210-
NvvmArch::Compute120a,
1211-
NvvmArch::Compute120f
1212-
]
1213-
);
1214-
1215-
// Getting variants from a variant returns all variants
1216-
let compute120f_variants = NvvmArch::Compute120f.get_variants();
1217-
assert_eq!(compute120f_variants.len(), 3);
1218-
assert!(compute120f_variants.contains(&NvvmArch::Compute120));
1219-
assert!(compute120f_variants.contains(&NvvmArch::Compute120f));
1220-
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);
12211210
}
12221211

12231212
#[test]
12241213
fn nvvm_arch_variants_for_capability() {
12251214
use crate::NvvmArch;
12261215

12271216
// Capability with single variant
1228-
let compute75_variants = NvvmArch::variants_for_capability(75);
1229-
assert_eq!(compute75_variants, vec![NvvmArch::Compute75]);
1217+
assert_eq!(
1218+
NvvmArch::variants_for_capability(75),
1219+
vec![NvvmArch::Compute75]
1220+
);
12301221

12311222
// Capability with multiple variants
1232-
let mut compute101_variants = NvvmArch::variants_for_capability(101);
1233-
compute101_variants.sort_by_key(|v| format!("{:?}", v));
12341223
assert_eq!(
1235-
compute101_variants,
1224+
NvvmArch::variants_for_capability(101),
12361225
vec![
12371226
NvvmArch::Compute101,
1227+
NvvmArch::Compute101f,
12381228
NvvmArch::Compute101a,
1239-
NvvmArch::Compute101f
12401229
]
12411230
);
12421231

12431232
// Non-existent capability
1244-
let compute999_variants = NvvmArch::variants_for_capability(999);
1245-
assert!(compute999_variants.is_empty());
1233+
assert!(NvvmArch::variants_for_capability(999).is_empty());
12461234
}
12471235
}

0 commit comments

Comments
 (0)