From c7133826408d8ba359f2a92ac53e95787392f0ac Mon Sep 17 00:00:00 2001 From: jotape24 Date: Tue, 7 Jan 2025 10:08:36 -0300 Subject: [PATCH] test getters and setters for OptOption added --- src/edns/opt_option.rs | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/src/edns/opt_option.rs b/src/edns/opt_option.rs index 9b5e9c57..3dbef2b5 100644 --- a/src/edns/opt_option.rs +++ b/src/edns/opt_option.rs @@ -223,6 +223,7 @@ mod option_data_tests { use crate::edns::options::ede::ede_optdata::EdeOptData; use crate::edns::options::ede::ede_code::EdeCode; use crate::edns::opt_option::option_code::OptionCode; + use crate::edns::opt_option::OptOption; use crate::message::resource_record::ToBytes; #[test] fn test_option_data_nsid() { @@ -271,4 +272,31 @@ mod option_data_tests { assert_eq!(option_data, rebuilt); assert_eq!(serialized.len(), 4); } + + #[test] + fn test_set_get_option_code() { + let mut opt = OptOption::new(OptionCode::NSID); + assert_eq!(opt.get_option_code(), OptionCode::NSID); + + opt.set_option_code(OptionCode::EDE); + assert_eq!(opt.get_option_code(), OptionCode::EDE); + } + + #[test] + fn test_set_get_option_len() { + let mut opt = OptOption::new(OptionCode::NSID); + assert_eq!(opt.get_option_len(), 0); + + opt.set_option_len(8); + assert_eq!(opt.get_option_len(), 8); + } + + #[test] + fn test_set_get_opt_data() { + let mut opt = OptOption::new(OptionCode::NSID); + assert_eq!(opt.get_opt_data(), OptionData::NSID(String::new())); + + opt.set_opt_data(OptionData::NSID("example".to_string())); + assert_eq!(opt.get_opt_data(), OptionData::NSID("example".to_string())); + } } \ No newline at end of file