Skip to content

Commit 87a7935

Browse files
committed
Added test for the storage_size() method of BitStorage.
1 parent b2769a8 commit 87a7935

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

src/bit_storage.rs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ pub trait BitStorage: Sized +
1616
ShrAssign<Self> +
1717
Eq + Zero + One + Unsigned + NumCast + Bounded + Copy {
1818
fn storage_size() -> usize;
19-
}
19+
}
2020

2121
impl<S> BitStorage for S where S: Sized +
2222
BitAnd<S, Output = S> +
@@ -35,4 +35,14 @@ impl<S> BitStorage for S where S: Sized +
3535
fn storage_size() -> usize {
3636
mem::size_of::<S>() * 8
3737
}
38-
}
38+
}
39+
40+
#[cfg(test)]
41+
mod tests {
42+
use super::BitStorage;
43+
44+
#[test]
45+
fn test_storage_size() {
46+
assert_eq!(u8::storage_size(), 8);
47+
}
48+
}

0 commit comments

Comments
 (0)