aboutsummaryrefslogtreecommitdiffstats
path: root/src/descriptor.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/descriptor.rs')
-rw-r--r--src/descriptor.rs28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/descriptor.rs b/src/descriptor.rs
index 8461413..c0d3314 100644
--- a/src/descriptor.rs
+++ b/src/descriptor.rs
@@ -1,4 +1,5 @@
#[derive(Clone, Copy, Debug)]
+#[repr(u8)]
pub enum DescriptorType {
Device = 1,
Configuration = 2,
@@ -66,3 +67,30 @@ pub struct EndpointDescriptor {
pub w_max_packet_size: u16,
pub b_interval: u8,
}
+
+#[cfg(test)]
+mod test {
+ use super::*;
+
+ use core::mem;
+
+ #[test]
+ fn device_descriptor_layout() {
+ assert_eq!(mem::size_of::<DeviceDescriptor>(), 18);
+ }
+
+ #[test]
+ fn configuration_descriptor_layout() {
+ assert_eq!(mem::size_of::<ConfigurationDescriptor>(), 9);
+ }
+
+ #[test]
+ fn interface_descriptor_layout() {
+ assert_eq!(mem::size_of::<InterfaceDescriptor>(), 9);
+ }
+
+ #[test]
+ fn endpoint_descriptor_layout() {
+ assert_eq!(mem::size_of::<EndpointDescriptor>(), 7);
+ }
+}