Skip to content

Commit ca90794

Browse files
committed
cargo fmt
1 parent 6b6a81a commit ca90794

File tree

1 file changed

+87
-17
lines changed

1 file changed

+87
-17
lines changed

tests/mod.rs

Lines changed: 87 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -290,16 +290,66 @@ fn test_ctoption() {
290290
));
291291

292292
// Test (in)equality
293-
assert!(CtOption::new(1, Choice::from(0)).ct_eq(&CtOption::new(1, Choice::from(1))).unwrap_u8() == 0);
294-
assert!(CtOption::new(1, Choice::from(1)).ct_eq(&CtOption::new(1, Choice::from(0))).unwrap_u8() == 0);
295-
assert!(CtOption::new(1, Choice::from(0)).ct_eq(&CtOption::new(2, Choice::from(1))).unwrap_u8() == 0);
296-
assert!(CtOption::new(1, Choice::from(1)).ct_eq(&CtOption::new(2, Choice::from(0))).unwrap_u8() == 0);
297-
assert!(CtOption::new(1, Choice::from(0)).ct_eq(&CtOption::new(1, Choice::from(0))).unwrap_u8() == 1);
298-
assert!(CtOption::new(1, Choice::from(0)).ct_eq(&CtOption::new(2, Choice::from(0))).unwrap_u8() == 1);
299-
assert!(CtOption::new(1, Choice::from(1)).ct_eq(&CtOption::new(2, Choice::from(1))).unwrap_u8() == 0);
300-
assert!(CtOption::new(1, Choice::from(1)).ct_eq(&CtOption::new(2, Choice::from(1))).unwrap_u8() == 0);
301-
assert!(CtOption::new(1, Choice::from(1)).ct_eq(&CtOption::new(1, Choice::from(1))).unwrap_u8() == 1);
302-
assert!(CtOption::new(1, Choice::from(1)).ct_eq(&CtOption::new(1, Choice::from(1))).unwrap_u8() == 1);
293+
assert!(
294+
CtOption::new(1, Choice::from(0))
295+
.ct_eq(&CtOption::new(1, Choice::from(1)))
296+
.unwrap_u8()
297+
== 0
298+
);
299+
assert!(
300+
CtOption::new(1, Choice::from(1))
301+
.ct_eq(&CtOption::new(1, Choice::from(0)))
302+
.unwrap_u8()
303+
== 0
304+
);
305+
assert!(
306+
CtOption::new(1, Choice::from(0))
307+
.ct_eq(&CtOption::new(2, Choice::from(1)))
308+
.unwrap_u8()
309+
== 0
310+
);
311+
assert!(
312+
CtOption::new(1, Choice::from(1))
313+
.ct_eq(&CtOption::new(2, Choice::from(0)))
314+
.unwrap_u8()
315+
== 0
316+
);
317+
assert!(
318+
CtOption::new(1, Choice::from(0))
319+
.ct_eq(&CtOption::new(1, Choice::from(0)))
320+
.unwrap_u8()
321+
== 1
322+
);
323+
assert!(
324+
CtOption::new(1, Choice::from(0))
325+
.ct_eq(&CtOption::new(2, Choice::from(0)))
326+
.unwrap_u8()
327+
== 1
328+
);
329+
assert!(
330+
CtOption::new(1, Choice::from(1))
331+
.ct_eq(&CtOption::new(2, Choice::from(1)))
332+
.unwrap_u8()
333+
== 0
334+
);
335+
assert!(
336+
CtOption::new(1, Choice::from(1))
337+
.ct_eq(&CtOption::new(2, Choice::from(1)))
338+
.unwrap_u8()
339+
== 0
340+
);
341+
assert!(
342+
CtOption::new(1, Choice::from(1))
343+
.ct_eq(&CtOption::new(1, Choice::from(1)))
344+
.unwrap_u8()
345+
== 1
346+
);
347+
assert!(
348+
CtOption::new(1, Choice::from(1))
349+
.ct_eq(&CtOption::new(1, Choice::from(1)))
350+
.unwrap_u8()
351+
== 1
352+
);
303353
}
304354

305355
#[test]
@@ -327,7 +377,7 @@ macro_rules! generate_greater_than_test {
327377
assert!(z.unwrap_u8() == 1);
328378
}
329379
}
330-
}
380+
};
331381
}
332382

333383
#[test]
@@ -358,16 +408,26 @@ fn greater_than_u128() {
358408

359409
#[test]
360410
fn greater_than_ordering() {
361-
assert_eq!(cmp::Ordering::Less.ct_gt(&cmp::Ordering::Greater).unwrap_u8(), 0);
362-
assert_eq!(cmp::Ordering::Greater.ct_gt(&cmp::Ordering::Less).unwrap_u8(), 1);
411+
assert_eq!(
412+
cmp::Ordering::Less
413+
.ct_gt(&cmp::Ordering::Greater)
414+
.unwrap_u8(),
415+
0
416+
);
417+
assert_eq!(
418+
cmp::Ordering::Greater
419+
.ct_gt(&cmp::Ordering::Less)
420+
.unwrap_u8(),
421+
1
422+
);
363423
}
364424

365425
#[test]
366426
/// Test that the two's compliment min and max, i.e. 0000...0001 < 1111...1110,
367427
/// gives the correct result. (This fails using the bit-twiddling algorithm that
368428
/// go/crypto/subtle uses.)
369429
fn less_than_twos_compliment_minmax() {
370-
let z = 1u32.ct_lt(&(2u32.pow(31)-1));
430+
let z = 1u32.ct_lt(&(2u32.pow(31) - 1));
371431

372432
assert!(z.unwrap_u8() == 1);
373433
}
@@ -389,7 +449,7 @@ macro_rules! generate_less_than_test {
389449
assert!(z.unwrap_u8() == 1);
390450
}
391451
}
392-
}
452+
};
393453
}
394454

395455
#[test]
@@ -420,6 +480,16 @@ fn less_than_u128() {
420480

421481
#[test]
422482
fn less_than_ordering() {
423-
assert_eq!(cmp::Ordering::Greater.ct_lt(&cmp::Ordering::Less).unwrap_u8(), 0);
424-
assert_eq!(cmp::Ordering::Less.ct_lt(&cmp::Ordering::Greater).unwrap_u8(), 1);
483+
assert_eq!(
484+
cmp::Ordering::Greater
485+
.ct_lt(&cmp::Ordering::Less)
486+
.unwrap_u8(),
487+
0
488+
);
489+
assert_eq!(
490+
cmp::Ordering::Less
491+
.ct_lt(&cmp::Ordering::Greater)
492+
.unwrap_u8(),
493+
1
494+
);
425495
}

0 commit comments

Comments
 (0)