about summary refs log tree commit diff
path: root/tvix/nix-compat
diff options
context:
space:
mode:
authorFlorian Klink <flokli@flokli.de>2024-04-19T11·30+0300
committerclbot <clbot@tvl.fyi>2024-04-19T19·22+0000
commitcaedd6ff86bd186df76ef135d7fc959f2b1a61f4 (patch)
tree5301e245f18d433b97dc387e89448e5667487479 /tvix/nix-compat
parent2783143414ac9597f3835bb899c5acb8d6992812 (diff)
chore(nix-compat/aterm): migrate from test_case to rstest r/7971
Change-Id: If05fa3d0f41d45e3574e0c5ddff406cb33dc52f4
Reviewed-on: https://cl.tvl.fyi/c/depot/+/11470
Tested-by: BuildkiteCI
Reviewed-by: Connor Brewster <cbrewster@hey.com>
Autosubmit: flokli <flokli@flokli.de>
Diffstat (limited to 'tvix/nix-compat')
-rw-r--r--tvix/nix-compat/src/aterm/escape.rs11
-rw-r--r--tvix/nix-compat/src/aterm/parser.rs41
2 files changed, 30 insertions, 22 deletions
diff --git a/tvix/nix-compat/src/aterm/escape.rs b/tvix/nix-compat/src/aterm/escape.rs
index 06b550bbf02d..80a85d210339 100644
--- a/tvix/nix-compat/src/aterm/escape.rs
+++ b/tvix/nix-compat/src/aterm/escape.rs
@@ -16,12 +16,13 @@ pub fn escape_bytes<P: AsRef<[u8]>>(s: P) -> Vec<u8> {
 #[cfg(test)]
 mod tests {
     use super::escape_bytes;
-    use test_case::test_case;
+    use rstest::rstest;
 
-    #[test_case(b"", b""; "empty")]
-    #[test_case(b"\"", b"\\\""; "doublequote")]
-    #[test_case(b":", b":"; "colon")]
-    fn escape(input: &[u8], expected: &[u8]) {
+    #[rstest]
+    #[case::empty(b"", b"")]
+    #[case::doublequote(b"\"", b"\\\"")]
+    #[case::colon(b":", b":")]
+    fn escape(#[case] input: &[u8], #[case] expected: &[u8]) {
         assert_eq!(expected, escape_bytes(input))
     }
 }
diff --git a/tvix/nix-compat/src/aterm/parser.rs b/tvix/nix-compat/src/aterm/parser.rs
index 72648d5ef590..a30cb40ab08d 100644
--- a/tvix/nix-compat/src/aterm/parser.rs
+++ b/tvix/nix-compat/src/aterm/parser.rs
@@ -76,25 +76,31 @@ pub(crate) fn parse_str_list(i: &[u8]) -> IResult<&[u8], Vec<String>> {
 
 #[cfg(test)]
 mod tests {
-    use test_case::test_case;
+    use rstest::rstest;
 
-    #[test_case(br#""""#, b"", b""; "empty")]
-    #[test_case(br#""Hello World""#, b"Hello World", b""; "hello world")]
-    #[test_case(br#""\"""#, br#"""#, b""; "doublequote")]
-    #[test_case(br#"":""#, b":", b""; "colon")]
-    #[test_case(br#""\""Rest"#, br#"""#, b"Rest"; "doublequote rest")]
-    fn parse_bstr_field(input: &[u8], expected: &[u8], exp_rest: &[u8]) {
+    #[rstest]
+    #[case::empty(br#""""#, b"", b"")]
+    #[case::hello_world(br#""Hello World""#, b"Hello World", b"")]
+    #[case::doublequote(br#""\"""#, br#"""#, b"")]
+    #[case::colon(br#"":""#, b":", b"")]
+    #[case::doublequote_rest(br#""\""Rest"#, br#"""#, b"Rest")]
+    fn test_parse_bstr_field(
+        #[case] input: &[u8],
+        #[case] expected: &[u8],
+        #[case] exp_rest: &[u8],
+    ) {
         let (rest, parsed) = super::parse_bstr_field(input).expect("must parse");
         assert_eq!(exp_rest, rest, "expected remainder");
         assert_eq!(expected, parsed);
     }
 
-    #[test_case(br#""""#, "", b""; "empty")]
-    #[test_case(br#""Hello World""#, "Hello World", b""; "hello world")]
-    #[test_case(br#""\"""#, r#"""#, b""; "doublequote")]
-    #[test_case(br#"":""#, ":", b""; "colon")]
-    #[test_case(br#""\""Rest"#, r#"""#, b"Rest"; "doublequote rest")]
-    fn parse_string_field(input: &[u8], expected: &str, exp_rest: &[u8]) {
+    #[rstest]
+    #[case::empty(br#""""#, "", b"")]
+    #[case::hello_world(br#""Hello World""#, "Hello World", b"")]
+    #[case::doublequote(br#""\"""#, r#"""#, b"")]
+    #[case::colon(br#"":""#, ":", b"")]
+    #[case::doublequote_rest(br#""\""Rest"#, r#"""#, b"Rest")]
+    fn parse_string_field(#[case] input: &[u8], #[case] expected: &str, #[case] exp_rest: &[u8]) {
         let (rest, parsed) = super::parse_string_field(input).expect("must parse");
         assert_eq!(exp_rest, rest, "expected remainder");
         assert_eq!(expected, &parsed);
@@ -107,10 +113,11 @@ mod tests {
         super::parse_string_field(&input).expect_err("must fail");
     }
 
-    #[test_case(br#"["foo"]"#, vec!["foo".to_string()], b""; "single foo")]
-    #[test_case(b"[]", vec![], b""; "empty list")]
-    #[test_case(b"[]blub", vec![], b"blub"; "empty list with rest")]
-    fn parse_list(input: &[u8], expected: Vec<String>, exp_rest: &[u8]) {
+    #[rstest]
+    #[case::single_foo(br#"["foo"]"#, vec!["foo".to_string()], b"")]
+    #[case::empty_list(b"[]", vec![], b"")]
+    #[case::empty_list_with_rest(b"[]blub", vec![], b"blub")]
+    fn parse_list(#[case] input: &[u8], #[case] expected: Vec<String>, #[case] exp_rest: &[u8]) {
         let (rest, parsed) = super::parse_str_list(input).expect("must parse");
         assert_eq!(exp_rest, rest, "expected remainder");
         assert_eq!(expected, parsed);