|
| 1 | +// Copyright 2023 Parity Technologies |
| 2 | +// |
| 3 | +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or |
| 4 | +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license |
| 5 | +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your |
| 6 | +// option. This file may not be copied, modified, or distributed |
| 7 | +// except according to those terms. |
| 8 | + |
| 9 | +//! Tests for the `bounded-collections` crate. |
| 10 | +
|
| 11 | +#![cfg(test)] |
| 12 | + |
| 13 | +use crate::*; |
| 14 | +use core::fmt::Debug; |
| 15 | + |
| 16 | +#[test] |
| 17 | +#[allow(path_statements)] |
| 18 | +fn const_impl_default_clone_debug() { |
| 19 | + struct ImplsDefault<T: Default + Clone + Debug>(T); |
| 20 | + |
| 21 | + ImplsDefault::<ConstBool<true>>; |
| 22 | + ImplsDefault::<ConstBool<false>>; |
| 23 | + ImplsDefault::<ConstU8<255>>; |
| 24 | + ImplsDefault::<ConstU16<50>>; |
| 25 | + ImplsDefault::<ConstU32<10>>; |
| 26 | + ImplsDefault::<ConstU64<99>>; |
| 27 | + ImplsDefault::<ConstU128<100>>; |
| 28 | + ImplsDefault::<ConstI8<-127>>; |
| 29 | + ImplsDefault::<ConstI16<-50>>; |
| 30 | + ImplsDefault::<ConstI32<-10>>; |
| 31 | + ImplsDefault::<ConstI64<-99>>; |
| 32 | + ImplsDefault::<ConstI128<-100>>; |
| 33 | +} |
| 34 | + |
| 35 | +#[test] |
| 36 | +#[cfg(feature = "std")] |
| 37 | +fn const_debug_fmt() { |
| 38 | + assert_eq!(format!("{:?}", ConstBool::<true> {}), "ConstBool<true>"); |
| 39 | + assert_eq!(format!("{:?}", ConstBool::<false> {}), "ConstBool<false>"); |
| 40 | + assert_eq!(format!("{:?}", ConstU8::<255> {}), "ConstU8<255>"); |
| 41 | + assert_eq!(format!("{:?}", ConstU16::<50> {}), "ConstU16<50>"); |
| 42 | + assert_eq!(format!("{:?}", ConstU32::<10> {}), "ConstU32<10>"); |
| 43 | + assert_eq!(format!("{:?}", ConstU64::<99> {}), "ConstU64<99>"); |
| 44 | + assert_eq!(format!("{:?}", ConstU128::<100> {}), "ConstU128<100>"); |
| 45 | + assert_eq!(format!("{:?}", ConstI8::<-127> {}), "ConstI8<-127>"); |
| 46 | + assert_eq!(format!("{:?}", ConstI16::<-50> {}), "ConstI16<-50>"); |
| 47 | + assert_eq!(format!("{:?}", ConstI32::<-10> {}), "ConstI32<-10>"); |
| 48 | + assert_eq!(format!("{:?}", ConstI64::<-99> {}), "ConstI64<-99>"); |
| 49 | + assert_eq!(format!("{:?}", ConstI128::<-100> {}), "ConstI128<-100>"); |
| 50 | +} |
0 commit comments