(tests) data-driven tests with macros

This commit is contained in:
ddidderr 2022-05-08 19:09:38 +02:00
parent a72e40d9cb
commit 60316e5593
2 changed files with 11 additions and 0 deletions

View File

@ -1,3 +1,4 @@
#![feature(concat_idents)]
use std::net::UdpSocket; use std::net::UdpSocket;
use std::sync::mpsc; use std::sync::mpsc;
use std::thread::{self, JoinHandle}; use std::thread::{self, JoinHandle};

View File

@ -228,9 +228,19 @@ pub enum DNSParseError {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
macro_rules! data_driven_test {
($name:expr, $func:expr, $input:literal, $output:literal) => {
#[test]
fn concat_idents!($name, _test) {
assert_eq!($input, $output);
}
}
}
mod from_udp_datagram { mod from_udp_datagram {
data_driven_test!("my_macro_test", somefunc, 5, 5);
mod header_length { mod header_length {
use super::super::super::*; use super::super::super::*;