nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: jonasbb/serde_with
Pull request #6 (2018-05-28 22:25:14)

Add string collection tests
Alter behaviour of empty string to allow for empty collections.

bors r+

bors[bot]: # Build failed
  * [continuous-integration/travis-ci/push](https://travis-ci.org/jonasbb/serde_with/builds/384937337?utm_source=github_status&utm_medium=notification)

Patch:
diff --git a/src/rust.rs b/src/rust.rs
index 1f58ea4..9089869 100644
--- a/src/rust.rs
+++ b/src/rust.rs
@@ -95,6 +95,8 @@ pub mod display_fromstr {
 /// You can define an arbitrary seperator, by specifying a type which implements [Separator].
 /// Some common ones, like space and comma are already predefined and you can find them [here][Separator].
 ///
+/// An empty string deserializes as an empty collection.
+///
 /// # Examples
 ///
 /// ```
@@ -163,9 +165,13 @@ where
         V::Err: Display,
     {
         let s = String::deserialize(deserializer)?;
-        s.split(Sep::separator())
-            .map(FromStr::from_str)
-            .collect::<Result<_, _>>()
-            .map_err(de::Error::custom)
+        if s.is_empty() {
+            Ok(None.into_iter().collect())
+        } else {
+            s.split(Sep::separator())
+                .map(FromStr::from_str)
+                .collect::<Result<_, _>>()
+                .map_err(de::Error::custom)
+        }
     }
 }


Test patch:
diff --git a/tests/rust.rs b/tests/rust.rs
new file mode 100644
index 0000000..f84b196
--- /dev/null
+++ b/tests/rust.rs
@@ -0,0 +1,56 @@
+extern crate serde;
+#[macro_use]
+extern crate serde_derive;
+extern crate serde_json;
+extern crate serde_with;
+#[macro_use]
+extern crate pretty_assertions;
+
+use serde_with::CommaSeparator;
+
+#[test]
+fn string_collection() {
+    #[derive(Debug, Deserialize)]
+    struct S {
+        #[serde(with = "serde_with::rust::StringWithSeparator::<CommaSeparator>")]
+        s: Vec<String>,
+    }
+    let from = r#"[
+        { "s": "A,B,C,D" },
+        { "s": ",," },
+        { "s": "AVeryLongString" }
+    ]"#;
+
+    let res: Vec<S> = serde_json::from_str(from).unwrap();
+    assert_eq!(
+        vec![
+            "A".to_string(),
+            "B".to_string(),
+            "C".to_string(),
+            "D".to_string(),
+        ],
+        res[0].s
+    );
+    assert_eq!(
+        vec!["".to_string(), "".to_string(), "".to_string()],
+        res[1].s
+    );
+    assert_eq!(vec!["AVeryLongString".to_string()], res[2].s);
+}
+
+#[test]
+fn string_collection_non_existing() {
+    #[derive(Debug, Deserialize, Serialize)]
+    struct S {
+        #[serde(with = "serde_with::rust::StringWithSeparator::<CommaSeparator>")]
+        s: Vec<String>,
+    }
+    let from = r#"[
+        { "s": "" }
+    ]"#;
+
+    let res: Vec<S> = serde_json::from_str(from).unwrap();
+    assert_eq!(Vec::<String>::new(), res[0].s);
+
+    assert_eq!(r#"{"s":""}"#, serde_json::to_string(&res[0]).unwrap());
+}
Repository: jonasbb/serde_with
Pull request #777 (2024-09-05 08:13:36)

Add newline separators


Patch:
diff --git a/serde_with/src/formats.rs b/serde_with/src/formats.rs
index 2722832..3171a2b 100644
--- a/serde_with/src/formats.rs
+++ b/serde_with/src/formats.rs
@@ -138,3 +138,23 @@ impl Separator for ColonSeparator {
         ":"
     }
 }
+
+/// Predefined separator using a single linefeed.
+pub struct UnixLineSeparator;
+
+impl Separator for UnixLineSeparator {
+    #[inline]
+    fn separator() -> &'static str {
+        "\n"
+    }
+}
+
+/// Predefined separator using a DOS/Windows line ending.
+pub struct DosLineSeparator;
+
+impl Separator for DosLineSeparator {
+    #[inline]
+    fn separator() -> &'static str {
+        "\r\n"
+    }
+}


Test patch:
diff --git a/serde_with/tests/serde_as/lib.rs b/serde_with/tests/serde_as/lib.rs
index 74cf32b..566f168 100644
--- a/serde_with/tests/serde_as/lib.rs
+++ b/serde_with/tests/serde_as/lib.rs
@@ -519,7 +519,7 @@ fn test_bytes_or_string() {
 #[test]
 fn string_with_separator() {
     use serde_with::{
-        formats::{CommaSeparator, SpaceSeparator},
+        formats::{CommaSeparator, DosLineSeparator, SpaceSeparator, UnixLineSeparator},
         StringWithSeparator,
     };
 
@@ -529,26 +529,44 @@ fn string_with_separator() {
         #[serde_as(as = "StringWithSeparator::<SpaceSeparator, String>")]
         tags: Vec<String>,
         #[serde_as(as = "StringWithSeparator::<CommaSeparator, String>")]
-        // more_tags: Vec<String>,
         more_tags: BTreeSet<String>,
+        #[serde_as(as = "StringWithSeparator::<UnixLineSeparator, String>")]
+        lf_tags: BTreeSet<String>,
+        #[serde_as(as = "StringWithSeparator::<DosLineSeparator, String>")]
+        crlf_tags: BTreeSet<String>,
     }
 
     let v: A = serde_json::from_str(
         r##"{
     "tags": "#hello #world",
-    "more_tags": "foo,bar,bar"
+    "more_tags": "foo,bar,bar",
+    "lf_tags": "foo\nbar\nbar",
+    "crlf_tags": "foo\r\nbar\r\nbar"
 }"##,
     )
     .unwrap();
     assert_eq!(vec!["#hello", "#world"], v.tags);
-    assert_eq!(2, v.more_tags.len());
+    assert_eq!(
+        BTreeSet::from(["foo".to_string(), "bar".to_string()]),
+        v.more_tags
+    );
+    assert_eq!(
+        BTreeSet::from(["foo".to_string(), "bar".to_string()]),
+        v.lf_tags
+    );
+    assert_eq!(
+        BTreeSet::from(["foo".to_string(), "bar".to_string()]),
+        v.crlf_tags
+    );
 
     let x = A {
         tags: vec!["1".to_string(), "2".to_string(), "3".to_string()],
         more_tags: BTreeSet::default(),
+        lf_tags: BTreeSet::default(),
+        crlf_tags: BTreeSet::default(),
     };
     assert_eq!(
-        r#"{"tags":"1 2 3","more_tags":""}"#,
+        r#"{"tags":"1 2 3","more_tags":"","lf_tags":"","crlf_tags":""}"#,
         serde_json::to_string(&x).unwrap()
     );
 }
Repository: deepjavalibrary/djl
Pull request #1863 (2022-08-03 17:20:31)

Add ARM support for ONNXRuntime update integration test
## Description ##

Brief description of what this PR is about

Add ARM support for ONNXRuntime update integration test

- If this change is a backward incompatible change, why must this change be made?
- Interesting edge cases to note here



Patch:
diff --git a/.github/workflows/continuous.yml b/.github/workflows/continuous.yml
index bce696a0d..5aca115af 100644
--- a/.github/workflows/continuous.yml
+++ b/.github/workflows/continuous.yml
@@ -44,6 +44,10 @@ jobs:
         run: ./gradlew :engines:pytorch:pytorch-native:compileJNI
       - name: Compile PaddlePaddle JNI
         run: ./gradlew :engines:paddlepaddle:paddlepaddle-native:compileJNI
+      - name: Test ONNX Runtime
+        run: |
+          ./gradlew -Dai.djl.default_engine=OnnxRuntime :integration:test
+          ./gradlew :integration:clean
       - name: Build with Gradle
         run: ./gradlew build jRR jRV
       - name: Upload test results
@@ -89,3 +93,4 @@ jobs:
         run: |
           ./gradlew -Pjni "-Dai.djl.default_engine=PyTorch" test -x examples:test
           ./gradlew -Pjni --rerun-tasks "-Dai.djl.default_engine=TensorFlow" test -x examples:test
+          ./gradlew --rerun-tasks "-Dai.djl.default_engine=OnnxRuntime" :integration:test
diff --git a/integration/build.gradle b/integration/build.gradle
index f4dbdaa3a..14e99f12b 100644
--- a/integration/build.gradle
+++ b/integration/build.gradle
@@ -103,10 +103,8 @@ jacocoTestCoverageVerification {
     violationRules {
         rule {
             limit {
-                if (System.getProperty("ai.djl.default_engine") == "PyTorch") {
-                    minimum = 0.4
-                } else if (System.getProperty("ai.djl.default_engine") == "TensorFlow") {
-                    minimum = 0.29
+                if (System.getProperty("ai.djl.default_engine") != null) {
+                    minimum = 0.2
                 } else {
                     // TODO: improve coverage by running integration tests with 3 engines
                     minimum = 0.4


Test patch:
diff --git a/integration/src/main/java/ai/djl/integration/tests/ndarray/NDArrayOtherOpTest.java b/integration/src/main/java/ai/djl/integration/tests/ndarray/NDArrayOtherOpTest.java
index 4d576127d..35606c848 100644
--- a/integration/src/main/java/ai/djl/integration/tests/ndarray/NDArrayOtherOpTest.java
+++ b/integration/src/main/java/ai/djl/integration/tests/ndarray/NDArrayOtherOpTest.java
@@ -269,7 +269,7 @@ public class NDArrayOtherOpTest {
             float[] data = {-1};
             array.set(FloatBuffer.wrap(data));
             NDArray expected = manager.create(-1f);
-            Assert.assertEquals(array, expected);
+            Assertions.assertAlmostEquals(array, expected);
             array = manager.zeros(new Shape(2, 3));
             data = new float[] {0, 1, 2, 3, 4, 5};
             array.set(FloatBuffer.wrap(data));