From f30dc86d30ecf9a8bd19654aa3bb1f536ca398eb Mon Sep 17 00:00:00 2001 From: Romain Beauxis Date: Sat, 28 Dec 2024 13:57:20 +0100 Subject: [PATCH] Add more strings to test for parsing. --- tests/core/dune | 13 +++++++++++++ tests/core/dune.inc | 2 +- tests/core/gen_dune.ml | 5 ++++- tests/core/json_test.ml | 10 ++++++++++ 4 files changed, 28 insertions(+), 2 deletions(-) diff --git a/tests/core/dune b/tests/core/dune index d13f9d243d..68b4f229be 100644 --- a/tests/core/dune +++ b/tests/core/dune @@ -63,3 +63,16 @@ (system "cd json5 && find . -type f | egrep '\\.json|\\.js|\\.txt' | xargs -I % mv % .") (system "cd json5 && find . -type d | grep -v '^\\.$' | xargs rm -rf")))) + +(rule + (alias citest) + (target big-list-of-naughty-strings) + (action + (progn + (run rm -rf big-list-of-naughty-strings) + (run + git + clone + --depth + 1 + https://github.com/minimaxir/big-list-of-naughty-strings.git)))) diff --git a/tests/core/dune.inc b/tests/core/dune.inc index d1ac0fc5e3..9035190dc3 100644 --- a/tests/core/dune.inc +++ b/tests/core/dune.inc @@ -120,7 +120,7 @@ (alias citest) (package liquidsoap) (deps - (:json ./json) (:json5 ./json5) + (:json ./json) (:json5 ./json5) (:big-list-of-naughty-strings ./big-list-of-naughty-strings) (:json_test json_test.exe)) (action (run %{json_test} ))) diff --git a/tests/core/gen_dune.ml b/tests/core/gen_dune.ml index 2ff7d1c1c6..f9e303d3f5 100644 --- a/tests/core/gen_dune.ml +++ b/tests/core/gen_dune.ml @@ -1,7 +1,10 @@ (* test name, (deps, args) *) let test_params = [ - ("json_test", ("(:json ./json) (:json5 ./json5)", [""])); + ( "json_test", + ( "(:json ./json) (:json5 ./json5) (:big-list-of-naughty-strings \ + ./big-list-of-naughty-strings)", + [""] ) ); ( "stream_decoder_test", ( "(:test_wav ./test.wav) (:test_mp3 ./test.mp3)", ["%{test_wav} bla.wav"; "%{test_mp3} bla.wav"] ) ); diff --git a/tests/core/json_test.ml b/tests/core/json_test.ml index 91472d746d..b2edbb700e 100644 --- a/tests/core/json_test.ml +++ b/tests/core/json_test.ml @@ -127,3 +127,13 @@ let () = | _ when expectation = `Failure -> Printf.printf "OK!\n%!" in List.iter run_test tests + +let () = + let pwd = Filename.dirname Sys.argv.(0) in + let basedir = Filename.concat pwd "big-list-of-naughty-strings" in + let strings_file = Filename.concat basedir "blns.json" in + Printf.printf "Testing big-list-of-naughty-strings...\n%!"; + let s = read_file strings_file in + let v = Json.from_string s in + ignore (Json.to_string ~compact:true v); + ignore (Json.to_string ~compact:false v)