filetest

Crates.iofiletest
lib.rsfiletest
version0.1.2
sourcesrc
created_at2023-09-26 20:30:35.313681
updated_at2023-10-18 10:19:55.484447
descriptionMacro that creates test cases for each file in a directory
homepage
repositoryhttps://github.com/Kyuuhachi/filetest
max_upload_size
id984018
size9,950
(Kyuuhachi)

documentation

README

A proc macro for making test cases from a corpus of files, intended for parsing-related tests.

#[filetest::filetest("examples/files/*")]
fn test_file(path: &std::path::Path, bytes: &[u8], text: &str) {
    assert_eq!(std::fs::read(path).unwrap(), bytes);
    assert_eq!(bytes, text.as_bytes());
}

This crate requires the proc_macro_span unstable feature, in order to support relative paths.

Arguments

Arguments passed to the function are identified by name, not by type. All references are 'static. Currently, the following three arguments are supported:

Name Type Content
path str: AsRef<T>1 Absolute path to the file
bytes &[u8] File contents, as seen by include_bytes!()
text &str File contents, as seen by include_str!()

Footnotes

  1. This includes str, std::path::Path, and camino::Utf8Path.

Commit count: 6

cargo fmt