Skip to content

Commit 71d02d0

Browse files
committed
test: Update doctests
1 parent 90d4355 commit 71d02d0

File tree

5 files changed

+37
-37
lines changed

5 files changed

+37
-37
lines changed

src/bit_int.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ use num_traits::{PrimInt, Signed};
2727
/// let n = Int::new(-64).unwrap();
2828
/// assert_eq!(n, Int::MIN);
2929
///
30-
/// assert!(n.checked_sub(1).is_none());
30+
/// assert_eq!(n.checked_sub(1), None);
3131
/// assert_eq!(n.get().checked_sub(1), Some(-65));
3232
/// ```
3333
///
@@ -66,7 +66,7 @@ macro_rules! impl_bit_int {
6666
/// assert_eq!(n.map(BitInt::get), Some(42));
6767
#[doc = ""]
6868
#[doc = concat!("let m = BitInt::<", stringify!($T), ", 6>::new(42);")]
69-
/// assert!(m.is_none());
69+
/// assert_eq!(m, None);
7070
/// ```
7171
#[must_use]
7272
#[inline]
@@ -88,8 +88,8 @@ macro_rules! impl_bit_int {
8888
/// ```
8989
/// # use bit_int::BitInt;
9090
/// #
91-
#[doc = concat!("assert!(!BitInt::<", stringify!($T), ", 7>::MIN.is_positive());")]
92-
#[doc = concat!("assert!(BitInt::<", stringify!($T), ", 7>::MAX.is_positive());")]
91+
#[doc = concat!("assert_eq!(BitInt::<", stringify!($T), ", 7>::MIN.is_positive(), false);")]
92+
#[doc = concat!("assert_eq!(BitInt::<", stringify!($T), ", 7>::MAX.is_positive(), true);")]
9393
/// ```
9494
#[must_use]
9595
#[inline]
@@ -105,8 +105,8 @@ macro_rules! impl_bit_int {
105105
/// ```
106106
/// # use bit_int::BitInt;
107107
/// #
108-
#[doc = concat!("assert!(BitInt::<", stringify!($T), ", 7>::MIN.is_negative());")]
109-
#[doc = concat!("assert!(!BitInt::<", stringify!($T), ", 7>::MAX.is_negative());")]
108+
#[doc = concat!("assert_eq!(BitInt::<", stringify!($T), ", 7>::MIN.is_negative(), true);")]
109+
#[doc = concat!("assert_eq!(BitInt::<", stringify!($T), ", 7>::MAX.is_negative(), false);")]
110110
/// ```
111111
#[must_use]
112112
#[inline]

src/bit_int/ops.rs

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ macro_rules! impl_ops {
2121
#[doc = concat!("let n = BitInt::<", stringify!($T), ", 7>::new(42).unwrap();")]
2222
///
2323
/// assert_eq!(n.checked_add(21).map(BitInt::get), Some(63));
24-
/// assert!(n.checked_add(22).is_none());
24+
/// assert_eq!(n.checked_add(22), None);
2525
/// ```
2626
#[must_use]
2727
#[inline]
@@ -45,7 +45,7 @@ macro_rules! impl_ops {
4545
#[doc = concat!("let n = BitInt::<", stringify!($T), ", 7>::new(-42).unwrap();")]
4646
///
4747
/// assert_eq!(n.checked_sub(22).map(BitInt::get), Some(-64));
48-
/// assert!(n.checked_sub(23).is_none());
48+
/// assert_eq!(n.checked_sub(23), None);
4949
/// ```
5050
#[must_use]
5151
#[inline]
@@ -69,7 +69,7 @@ macro_rules! impl_ops {
6969
#[doc = concat!("let n = BitInt::<", stringify!($T), ", 7>::new(21).unwrap();")]
7070
///
7171
/// assert_eq!(n.checked_mul(2).map(BitInt::get), Some(42));
72-
/// assert!(n.checked_mul(4).is_none());
72+
/// assert_eq!(n.checked_mul(4), None);
7373
/// ```
7474
#[must_use]
7575
#[inline]
@@ -93,8 +93,8 @@ macro_rules! impl_ops {
9393
#[doc = concat!("let n = BitInt::<", stringify!($T), ", 7>::new(42).unwrap();")]
9494
///
9595
/// assert_eq!(n.checked_div(2).map(BitInt::get), Some(21));
96-
/// assert!(n.checked_div(0).is_none());
97-
#[doc = concat!("assert!(BitInt::<", stringify!($T), ", 7>::MIN.checked_div(-1).is_none());")]
96+
/// assert_eq!(n.checked_div(0), None);
97+
#[doc = concat!("assert_eq!(BitInt::<", stringify!($T), ", 7>::MIN.checked_div(-1), None);")]
9898
/// ```
9999
#[must_use]
100100
#[inline]
@@ -118,8 +118,8 @@ macro_rules! impl_ops {
118118
#[doc = concat!("let n = BitInt::<", stringify!($T), ", 7>::new(42).unwrap();")]
119119
///
120120
/// assert_eq!(n.checked_div_euclid(2).map(BitInt::get), Some(21));
121-
/// assert!(n.checked_div_euclid(0).is_none());
122-
#[doc = concat!("assert!(BitInt::<", stringify!($T), ", 7>::MIN.checked_div_euclid(-1).is_none());")]
121+
/// assert_eq!(n.checked_div_euclid(0), None);
122+
#[doc = concat!("assert_eq!(BitInt::<", stringify!($T), ", 7>::MIN.checked_div_euclid(-1), None);")]
123123
/// ```
124124
#[must_use]
125125
#[inline]
@@ -143,8 +143,8 @@ macro_rules! impl_ops {
143143
#[doc = concat!("let n = BitInt::<", stringify!($T), ", 4>::new(5).unwrap();")]
144144
///
145145
/// assert_eq!(n.checked_rem(2).map(BitInt::get), Some(1));
146-
/// assert!(n.checked_rem(0).is_none());
147-
#[doc = concat!("assert!(BitInt::<", stringify!($T), ", 4>::MIN.checked_rem(-1).is_none());")]
146+
/// assert_eq!(n.checked_rem(0), None);
147+
#[doc = concat!("assert_eq!(BitInt::<", stringify!($T), ", 4>::MIN.checked_rem(-1), None);")]
148148
/// ```
149149
#[must_use]
150150
#[inline]
@@ -167,8 +167,8 @@ macro_rules! impl_ops {
167167
#[doc = concat!("let n = BitInt::<", stringify!($T), ", 4>::new(5).unwrap();")]
168168
///
169169
/// assert_eq!(n.checked_rem_euclid(2).map(BitInt::get), Some(1));
170-
/// assert!(n.checked_rem_euclid(0).is_none());
171-
#[doc = concat!("assert!(BitInt::<", stringify!($T), ", 4>::MIN.checked_rem_euclid(-1).is_none());")]
170+
/// assert_eq!(n.checked_rem_euclid(0), None);
171+
#[doc = concat!("assert_eq!(BitInt::<", stringify!($T), ", 4>::MIN.checked_rem_euclid(-1), None);")]
172172
/// ```
173173
#[must_use]
174174
#[inline]
@@ -250,7 +250,7 @@ macro_rules! impl_ops {
250250
#[doc = concat!("let n = BitInt::<", stringify!($T), ", 4>::new(5).unwrap();")]
251251
///
252252
/// assert_eq!(n.checked_neg().map(BitInt::get), Some(-5));
253-
#[doc = concat!("assert!(BitInt::<", stringify!($T), ", 4>::MIN.checked_neg().is_none());")]
253+
#[doc = concat!("assert_eq!(BitInt::<", stringify!($T), ", 4>::MIN.checked_neg(), None);")]
254254
/// ```
255255
#[must_use]
256256
#[inline]
@@ -276,7 +276,7 @@ macro_rules! impl_ops {
276276
#[doc = concat!("let m = BitInt::<", stringify!($T), ", 6>::new(0x10).unwrap();")]
277277
///
278278
/// assert_eq!(n.checked_shl(4).map(BitInt::get), Some(0x10));
279-
/// assert!(n.checked_shl(129).is_none());
279+
/// assert_eq!(n.checked_shl(129), None);
280280
#[doc = concat!("assert_eq!(m.checked_shl(", stringify!($T), "::BITS - 1).map(BitInt::get), Some(0x00));")]
281281
/// ```
282282
#[must_use]
@@ -302,7 +302,7 @@ macro_rules! impl_ops {
302302
#[doc = concat!("let n = BitInt::<", stringify!($T), ", 6>::new(0x10).unwrap();")]
303303
///
304304
/// assert_eq!(n.checked_shr(4).map(BitInt::get), Some(0x01));
305-
/// assert!(n.checked_shr(128).is_none());
305+
/// assert_eq!(n.checked_shr(128), None);
306306
/// ```
307307
#[must_use]
308308
#[inline]
@@ -326,7 +326,7 @@ macro_rules! impl_ops {
326326
#[doc = concat!("let n = BitInt::<", stringify!($T), ", 4>::new(-5).unwrap();")]
327327
///
328328
/// assert_eq!(n.checked_abs().map(BitInt::get), Some(5));
329-
#[doc = concat!("assert!(BitInt::<", stringify!($T), ", 4>::MIN.checked_abs().is_none());")]
329+
#[doc = concat!("assert_eq!(BitInt::<", stringify!($T), ", 4>::MIN.checked_abs(), None);")]
330330
/// ```
331331
#[must_use]
332332
#[inline]
@@ -350,7 +350,7 @@ macro_rules! impl_ops {
350350
#[doc = concat!("let n = BitInt::<", stringify!($T), ", 8>::new(8).unwrap();")]
351351
///
352352
/// assert_eq!(n.checked_pow(2).map(BitInt::get), Some(64));
353-
#[doc = concat!("assert!(BitInt::<", stringify!($T), ", 8>::MAX.checked_pow(2).is_none());")]
353+
#[doc = concat!("assert_eq!(BitInt::<", stringify!($T), ", 8>::MAX.checked_pow(2), None);")]
354354
/// ```
355355
#[must_use]
356356
#[inline]

src/bit_uint.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ use num_traits::{PrimInt, Unsigned};
2727
/// let n = Uint::new(127).unwrap();
2828
/// assert_eq!(n, Uint::MAX);
2929
///
30-
/// assert!(n.checked_add(1).is_none());
30+
/// assert_eq!(n.checked_add(1), None);
3131
/// assert_eq!(n.get().checked_add(1), Some(128));
3232
/// ```
3333
///
@@ -66,7 +66,7 @@ macro_rules! impl_bit_uint {
6666
/// assert_eq!(n.map(BitUint::get), Some(42));
6767
#[doc = ""]
6868
#[doc = concat!("let m = BitUint::<", stringify!($T), ", 5>::new(42);")]
69-
/// assert!(m.is_none());
69+
/// assert_eq!(m, None);
7070
/// ```
7171
#[must_use]
7272
#[inline]

src/bit_uint/ops.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ macro_rules! impl_ops {
2121
#[doc = concat!("let n = BitUint::<", stringify!($T), ", 6>::new(42).unwrap();")]
2222
///
2323
/// assert_eq!(n.checked_add(21).map(BitUint::get), Some(63));
24-
/// assert!(n.checked_add(22).is_none());
24+
/// assert_eq!(n.checked_add(22), None);
2525
/// ```
2626
#[must_use]
2727
#[inline]
@@ -45,7 +45,7 @@ macro_rules! impl_ops {
4545
#[doc = concat!("let n = BitUint::<", stringify!($T), ", 6>::new(42).unwrap();")]
4646
///
4747
/// assert_eq!(n.checked_sub(42).map(BitUint::get), Some(0));
48-
/// assert!(n.checked_sub(43).is_none());
48+
/// assert_eq!(n.checked_sub(43), None);
4949
/// ```
5050
#[must_use]
5151
#[inline]
@@ -69,7 +69,7 @@ macro_rules! impl_ops {
6969
#[doc = concat!("let n = BitUint::<", stringify!($T), ", 6>::new(21).unwrap();")]
7070
///
7171
/// assert_eq!(n.checked_mul(2).map(BitUint::get), Some(42));
72-
/// assert!(n.checked_mul(4).is_none());
72+
/// assert_eq!(n.checked_mul(4), None);
7373
/// ```
7474
#[must_use]
7575
#[inline]
@@ -93,7 +93,7 @@ macro_rules! impl_ops {
9393
#[doc = concat!("let n = BitUint::<", stringify!($T), ", 6>::new(42).unwrap();")]
9494
///
9595
/// assert_eq!(n.checked_div(2).map(BitUint::get), Some(21));
96-
/// assert!(n.checked_div(0).is_none());
96+
/// assert_eq!(n.checked_div(0), None);
9797
/// ```
9898
#[must_use]
9999
#[inline]
@@ -117,7 +117,7 @@ macro_rules! impl_ops {
117117
#[doc = concat!("let n = BitUint::<", stringify!($T), ", 6>::new(42).unwrap();")]
118118
///
119119
/// assert_eq!(n.checked_div_euclid(2).map(BitUint::get), Some(21));
120-
/// assert!(n.checked_div_euclid(0).is_none());
120+
/// assert_eq!(n.checked_div_euclid(0), None);
121121
/// ```
122122
#[must_use]
123123
#[inline]
@@ -141,7 +141,7 @@ macro_rules! impl_ops {
141141
#[doc = concat!("let n = BitUint::<", stringify!($T), ", 3>::new(5).unwrap();")]
142142
///
143143
/// assert_eq!(n.checked_rem(2).map(BitUint::get), Some(1));
144-
/// assert!(n.checked_rem(0).is_none());
144+
/// assert_eq!(n.checked_rem(0), None);
145145
/// ```
146146
#[must_use]
147147
#[inline]
@@ -165,7 +165,7 @@ macro_rules! impl_ops {
165165
#[doc = concat!("let n = BitUint::<", stringify!($T), ", 3>::new(5).unwrap();")]
166166
///
167167
/// assert_eq!(n.checked_rem_euclid(2).map(BitUint::get), Some(1));
168-
/// assert!(n.checked_rem_euclid(0).is_none());
168+
/// assert_eq!(n.checked_rem_euclid(0), None);
169169
/// ```
170170
#[must_use]
171171
#[inline]
@@ -251,7 +251,7 @@ macro_rules! impl_ops {
251251
#[doc = concat!(" BitUint::<", stringify!($T), ", 1>::MIN.checked_neg().map(BitUint::get),")]
252252
/// Some(0)
253253
/// );
254-
#[doc = concat!("assert!(BitUint::<", stringify!($T), ", 1>::MAX.checked_neg().is_none());")]
254+
#[doc = concat!("assert_eq!(BitUint::<", stringify!($T), ", 1>::MAX.checked_neg(), None);")]
255255
/// ```
256256
#[must_use]
257257
#[inline]
@@ -277,7 +277,7 @@ macro_rules! impl_ops {
277277
#[doc = concat!("let m = BitUint::<", stringify!($T), ", 5>::new(0x10).unwrap();")]
278278
///
279279
/// assert_eq!(n.checked_shl(4).map(BitUint::get), Some(0x10));
280-
/// assert!(m.checked_shl(129).is_none());
280+
/// assert_eq!(m.checked_shl(129), None);
281281
#[doc = concat!("assert_eq!(m.checked_shl(", stringify!($T), "::BITS - 1).map(BitUint::get), Some(0x00));")]
282282
/// ```
283283
#[must_use]
@@ -303,7 +303,7 @@ macro_rules! impl_ops {
303303
#[doc = concat!("let n = BitUint::<", stringify!($T), ", 5>::new(0x10).unwrap();")]
304304
///
305305
/// assert_eq!(n.checked_shr(4).map(BitUint::get), Some(0x01));
306-
/// assert!(n.checked_shr(129).is_none());
306+
/// assert_eq!(n.checked_shr(129), None);
307307
/// ```
308308
#[must_use]
309309
#[inline]
@@ -327,7 +327,7 @@ macro_rules! impl_ops {
327327
#[doc = concat!("let n = BitUint::<", stringify!($T), ", 6>::new(2).unwrap();")]
328328
///
329329
/// assert_eq!(n.checked_pow(5).map(BitUint::get), Some(32));
330-
#[doc = concat!("assert!(BitUint::<", stringify!($T), ", 6>::MAX.checked_pow(2).is_none());")]
330+
#[doc = concat!("assert_eq!(BitUint::<", stringify!($T), ", 6>::MAX.checked_pow(2), None);")]
331331
/// ```
332332
#[must_use]
333333
#[inline]

src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
//! assert_eq!(n.get(), 63);
4040
//! assert_eq!(n, Int::MAX);
4141
//!
42-
//! assert!(n.checked_add(22).is_none());
42+
//! assert_eq!(n.checked_add(22), None);
4343
//! ```
4444
//!
4545
//! ## Unsigned integer type
@@ -60,7 +60,7 @@
6060
//! assert_eq!(n.get(), 127);
6161
//! assert_eq!(n, Uint::MAX);
6262
//!
63-
//! assert!(n.checked_add(86).is_none());
63+
//! assert_eq!(n.checked_add(86), None);
6464
//! ```
6565
//!
6666
//! [C23]: https://en.cppreference.com/w/c/23

0 commit comments

Comments
 (0)