]> git.notmuchmail.org Git - notmuch/blobdiff - test/test-lib.sh
test-lib.sh: add test_valid_json
[notmuch] / test / test-lib.sh
index cb5bb8941b52cd230e80f43a533b07bdf2ee4fec..43fffa09c639a91b9461c0faea0a6bc9bcfd1d01 100644 (file)
@@ -524,6 +524,12 @@ test_expect_equal_json () {
     test_expect_equal "$output" "$expected" "$@"
 }
 
+# Ensure that the argument is valid JSON data.
+test_valid_json () {
+    PYTHONIOENCODING=utf-8 $NOTMUCH_PYTHON -c "import sys, json; json.load(sys.stdin)" <<<"$1"
+    test_expect_equal "$?" 0
+}
+
 # Sort the top-level list of JSON data from stdin.
 test_sort_json () {
     PYTHONIOENCODING=utf-8 $NOTMUCH_PYTHON -c \