Browse Source

tests: Add comment for assert_eq_fmt

Nicholas Bishop 1 month ago
parent
commit
cd773ecd84
1 changed files with 11 additions and 0 deletions
  1. 11 0
      tests/tests.rs

+ 11 - 0
tests/tests.rs

@@ -39,6 +39,17 @@ macro_rules! c_fmt {
     }};
 }
 
+/// Assert that `rust_fmt` produces the same output as C's `asprintf`,
+/// and that both match the `expected` literal.
+///
+/// This takes a format literal, followed by optional printf arguments,
+/// followed by `=>` and then the `expected` output.
+///
+/// Example usage:
+///
+/// ```
+/// assert_eq_fmt!(c"%d %d", 1, 2 => "1 2");
+/// ```
 macro_rules! assert_eq_fmt {
     ($format:literal $(, $p:expr)* => $expected:literal) => {
         let (bytes_written, s) = c_fmt!($format $(, $p)*);