mirror of
https://github.com/GyulyVGC/sniffnet.git
synced 2025-12-23 22:29:01 -05:00
rerun buil.rs when windows icon changes; added tests about IpVersion and Protocol
This commit is contained in:
4
build.rs
4
build.rs
@@ -12,9 +12,11 @@
|
||||
include!("./src/networking/types/service_query.rs");
|
||||
include!("./src/networking/types/protocol.rs");
|
||||
|
||||
const WINDOWS_ICON_PATH: &str = "./resources/packaging/windows/graphics/sniffnet.ico";
|
||||
const SERVICES_LIST_PATH: &str = "./services.txt";
|
||||
|
||||
fn main() {
|
||||
println!("cargo:rerun-if-changed={WINDOWS_ICON_PATH}");
|
||||
println!("cargo:rerun-if-changed={SERVICES_LIST_PATH}");
|
||||
|
||||
set_icon();
|
||||
@@ -25,7 +27,7 @@ fn set_icon() {
|
||||
#[cfg(windows)]
|
||||
{
|
||||
let mut res = winres::WindowsResource::new();
|
||||
res.set_icon("resources/packaging/windows/graphics/sniffnet.ico");
|
||||
res.set_icon(WINDOWS_ICON_PATH);
|
||||
res.compile().unwrap();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,3 +18,25 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
impl IpVersion {
|
||||
pub(crate) const ALL: [IpVersion; 2] = [IpVersion::IPv4, IpVersion::IPv6];
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn test_ip_version_display() {
|
||||
for version in IpVersion::ALL {
|
||||
match version {
|
||||
IpVersion::IPv4 => assert_eq!(version.to_string(), "IPv4"),
|
||||
IpVersion::IPv6 => assert_eq!(version.to_string(), "IPv6"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_all_ip_versions_collection() {
|
||||
assert_eq!(IpVersion::ALL.len(), 2);
|
||||
assert_eq!(IpVersion::ALL.get(0).unwrap(), &IpVersion::IPv4);
|
||||
assert_eq!(IpVersion::ALL.get(1).unwrap(), &IpVersion::IPv6);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,3 +21,27 @@ fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
||||
impl Protocol {
|
||||
pub const ALL: [Protocol; 3] = [Protocol::TCP, Protocol::UDP, Protocol::ICMP];
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn test_protocol_display() {
|
||||
for protocol in Protocol::ALL {
|
||||
match protocol {
|
||||
Protocol::TCP => assert_eq!(protocol.to_string(), "TCP"),
|
||||
Protocol::UDP => assert_eq!(protocol.to_string(), "UDP"),
|
||||
Protocol::ICMP => assert_eq!(protocol.to_string(), "ICMP"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_all_protocols_collection() {
|
||||
assert_eq!(Protocol::ALL.len(), 3);
|
||||
assert_eq!(Protocol::ALL.get(0).unwrap(), &Protocol::TCP);
|
||||
assert_eq!(Protocol::ALL.get(1).unwrap(), &Protocol::UDP);
|
||||
assert_eq!(Protocol::ALL.get(2).unwrap(), &Protocol::ICMP);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user