mirror of
https://chromium.googlesource.com/crosvm/crosvm
synced 2024-10-22 20:36:34 +00:00
net_util: add test for create_sockaddr()
Prepare for refactoring the create_sockaddr() function by adding a test for the existing version. BUG=b:365852007 TEST=cargo test -p net_util sockaddr Change-Id: Ibe2d910df93f46702ce96615220a7e8e60cc6dc9 Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5760285 Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org> Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
This commit is contained in:
parent
e91ab42483
commit
b222eb3351
1 changed files with 19 additions and 0 deletions
|
@ -666,3 +666,22 @@ pub mod fakes {
|
|||
impl TapT for FakeTap {}
|
||||
volatile_impl!(FakeTap);
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
pub mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn sockaddr_byte_order() {
|
||||
let sa = create_sockaddr(net::Ipv4Addr::new(1, 2, 3, 4));
|
||||
assert_eq!(sa.sa_family, 2); // AF_INET
|
||||
assert_eq!(
|
||||
sa.sa_data,
|
||||
[
|
||||
0, 0, // sin_port
|
||||
1, 2, 3, 4, // sin_addr
|
||||
0, 0, 0, 0, 0, 0, 0, 0, // sin_zero
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue