diff options
author | Bryant Mairs <bryantmairs@google.com> | 2017-12-15 14:58:02 -0800 |
---|---|---|
committer | Bryant Mairs <bryantmairs@google.com> | 2017-12-20 07:05:04 -0800 |
commit | d8c538525807253aea6c64fc4bdcdb8a6e24f78d (patch) | |
tree | e7f489787ca2b3b08208bdbdd9720dde7c3df63a /test | |
parent | 4bad9bf9b9bb08d29511f060a3adae7453573a72 (diff) | |
download | nix-d8c538525807253aea6c64fc4bdcdb8a6e24f78d.zip |
Make numeric literals easier to read
Diffstat (limited to 'test')
-rw-r--r-- | test/sys/test_ioctl.rs | 60 | ||||
-rw-r--r-- | test/sys/test_socket.rs | 2 | ||||
-rw-r--r-- | test/sys/test_sockopt.rs | 2 |
3 files changed, 32 insertions, 32 deletions
diff --git a/test/sys/test_ioctl.rs b/test/sys/test_ioctl.rs index 1ed4a4b4..26ff42f8 100644 --- a/test/sys/test_ioctl.rs +++ b/test/sys/test_ioctl.rs @@ -87,22 +87,22 @@ mod linux { #[test] fn test_op_none() { if cfg!(any(target_arch = "mips", target_arch = "mips64", target_arch="powerpc", target_arch="powerpc64")){ - assert_eq!(io!(b'q', 10), 0x2000710A); - assert_eq!(io!(b'a', 255), 0x200061FF); + assert_eq!(io!(b'q', 10), 0x2000_710A); + assert_eq!(io!(b'a', 255), 0x2000_61FF); } else { - assert_eq!(io!(b'q', 10), 0x0000710A); - assert_eq!(io!(b'a', 255), 0x000061FF); + assert_eq!(io!(b'q', 10), 0x0000_710A); + assert_eq!(io!(b'a', 255), 0x0000_61FF); } } #[test] fn test_op_write() { if cfg!(any(target_arch = "mips", target_arch = "mips64", target_arch="powerpc", target_arch="powerpc64")){ - assert_eq!(iow!(b'z', 10, 1), 0x80017A0A); - assert_eq!(iow!(b'z', 10, 512), 0x82007A0A); + assert_eq!(iow!(b'z', 10, 1), 0x8001_7A0A); + assert_eq!(iow!(b'z', 10, 512), 0x8200_7A0A); } else { - assert_eq!(iow!(b'z', 10, 1), 0x40017A0A); - assert_eq!(iow!(b'z', 10, 512), 0x42007A0A); + assert_eq!(iow!(b'z', 10, 1), 0x4001_7A0A); + assert_eq!(iow!(b'z', 10, 512), 0x4200_7A0A); } } @@ -110,9 +110,9 @@ mod linux { #[test] fn test_op_write_64() { if cfg!(any(target_arch = "mips64", target_arch="powerpc64")){ - assert_eq!(iow!(b'z', 10, (1 as u64) << 32), 0x80007A0A); + assert_eq!(iow!(b'z', 10, (1 as u64) << 32), 0x8000_7A0A); } else { - assert_eq!(iow!(b'z', 10, (1 as u64) << 32), 0x40007A0A); + assert_eq!(iow!(b'z', 10, (1 as u64) << 32), 0x4000_7A0A); } } @@ -120,11 +120,11 @@ mod linux { #[test] fn test_op_read() { if cfg!(any(target_arch = "mips", target_arch = "mips64", target_arch="powerpc", target_arch="powerpc64")){ - assert_eq!(ior!(b'z', 10, 1), 0x40017A0A); - assert_eq!(ior!(b'z', 10, 512), 0x42007A0A); + assert_eq!(ior!(b'z', 10, 1), 0x4001_7A0A); + assert_eq!(ior!(b'z', 10, 512), 0x4200_7A0A); } else { - assert_eq!(ior!(b'z', 10, 1), 0x80017A0A); - assert_eq!(ior!(b'z', 10, 512), 0x82007A0A); + assert_eq!(ior!(b'z', 10, 1), 0x8001_7A0A); + assert_eq!(ior!(b'z', 10, 512), 0x8200_7A0A); } } @@ -132,22 +132,22 @@ mod linux { #[test] fn test_op_read_64() { if cfg!(any(target_arch = "mips64", target_arch="powerpc64")){ - assert_eq!(ior!(b'z', 10, (1 as u64) << 32), 0x40007A0A); + assert_eq!(ior!(b'z', 10, (1 as u64) << 32), 0x4000_7A0A); } else { - assert_eq!(ior!(b'z', 10, (1 as u64) << 32), 0x80007A0A); + assert_eq!(ior!(b'z', 10, (1 as u64) << 32), 0x8000_7A0A); } } #[test] fn test_op_read_write() { - assert_eq!(iorw!(b'z', 10, 1), 0xC0017A0A); - assert_eq!(iorw!(b'z', 10, 512), 0xC2007A0A); + assert_eq!(iorw!(b'z', 10, 1), 0xC001_7A0A); + assert_eq!(iorw!(b'z', 10, 512), 0xC200_7A0A); } #[cfg(target_pointer_width = "64")] #[test] fn test_op_read_write_64() { - assert_eq!(iorw!(b'z', 10, (1 as u64) << 32), 0xC0007A0A); + assert_eq!(iorw!(b'z', 10, (1 as u64) << 32), 0xC000_7A0A); } } @@ -160,44 +160,44 @@ mod linux { mod bsd { #[test] fn test_op_none() { - assert_eq!(io!(b'q', 10), 0x2000710A); - assert_eq!(io!(b'a', 255), 0x200061FF); + assert_eq!(io!(b'q', 10), 0x2000_710A); + assert_eq!(io!(b'a', 255), 0x2000_61FF); } #[test] fn test_op_write() { - assert_eq!(iow!(b'z', 10, 1), 0x80017A0A); - assert_eq!(iow!(b'z', 10, 512), 0x82007A0A); + assert_eq!(iow!(b'z', 10, 1), 0x8001_7A0A); + assert_eq!(iow!(b'z', 10, 512), 0x8200_7A0A); } #[cfg(target_pointer_width = "64")] #[test] fn test_op_write_64() { - assert_eq!(iow!(b'z', 10, (1 as u64) << 32), 0x80007A0A); + assert_eq!(iow!(b'z', 10, (1 as u64) << 32), 0x8000_7A0A); } #[test] fn test_op_read() { - assert_eq!(ior!(b'z', 10, 1), 0x40017A0A); - assert_eq!(ior!(b'z', 10, 512), 0x42007A0A); + assert_eq!(ior!(b'z', 10, 1), 0x4001_7A0A); + assert_eq!(ior!(b'z', 10, 512), 0x4200_7A0A); } #[cfg(target_pointer_width = "64")] #[test] fn test_op_read_64() { - assert_eq!(ior!(b'z', 10, (1 as u64) << 32), 0x40007A0A); + assert_eq!(ior!(b'z', 10, (1 as u64) << 32), 0x4000_7A0A); } #[test] fn test_op_read_write() { - assert_eq!(iorw!(b'z', 10, 1), 0xC0017A0A); - assert_eq!(iorw!(b'z', 10, 512), 0xC2007A0A); + assert_eq!(iorw!(b'z', 10, 1), 0xC001_7A0A); + assert_eq!(iorw!(b'z', 10, 512), 0xC200_7A0A); } #[cfg(target_pointer_width = "64")] #[test] fn test_op_read_write_64() { - assert_eq!(iorw!(b'z', 10, (1 as u64) << 32), 0xC0007A0A); + assert_eq!(iorw!(b'z', 10, (1 as u64) << 32), 0xC000_7A0A); } } diff --git a/test/sys/test_socket.rs b/test/sys/test_socket.rs index d29b2ecb..a997fbca 100644 --- a/test/sys/test_socket.rs +++ b/test/sys/test_socket.rs @@ -13,7 +13,7 @@ pub fn test_inetv4_addr_to_sock_addr() { match addr { InetAddr::V4(addr) => { - let ip: u32 = 0x7f000001; + let ip: u32 = 0x7f00_0001; let port: u16 = 3000; assert_eq!(addr.sin_addr.s_addr, ip.to_be()); diff --git a/test/sys/test_sockopt.rs b/test/sys/test_sockopt.rs index 81db8248..a38657c1 100644 --- a/test/sys/test_sockopt.rs +++ b/test/sys/test_sockopt.rs @@ -5,7 +5,7 @@ use nix::sys::socket::{socket, sockopt, getsockopt, setsockopt, AddressFamily, S fn test_so_buf() { let fd = socket(AddressFamily::Inet, SockType::Datagram, SockFlag::empty(), SockProtocol::Udp) .unwrap(); - let bufsize: usize = thread_rng().gen_range(4096, 131072); + let bufsize: usize = thread_rng().gen_range(4096, 131_072); setsockopt(fd, sockopt::SndBuf, &bufsize).unwrap(); let actual = getsockopt(fd, sockopt::SndBuf).unwrap(); assert!(actual >= bufsize); |