File tree Expand file tree Collapse file tree 4 files changed +20
-2
lines changed Expand file tree Collapse file tree 4 files changed +20
-2
lines changed Original file line number Diff line number Diff line change @@ -141,7 +141,10 @@ let escape text =
141141 | '\b' -> Buffer. add_string buf " \\ b"
142142 | '\r' -> Buffer. add_string buf " \\ r"
143143 | '\t' -> Buffer. add_string buf " \\ t"
144- | c -> Buffer. add_char buf c);
144+ | c ->
145+ let code = Char. code c in
146+ if code < 0x20 then Printf. bprintf buf " \\ u%04x" code
147+ else Buffer. add_char buf c);
145148 loop (i + 1 ))
146149 in
147150 loop 0 ;
Original file line number Diff line number Diff line change 1111 (<> %{profile} browser))
1212 (flags
1313 (:standard -w +a-4-9-30-40-41-42-48-70))
14- (libraries bsb bsb_helper core ounit2))
14+ (libraries bsb bsb_helper core ounit2 analysis ))
Original file line number Diff line number Diff line change 1+ let ( > :: ), ( > ::: ) = OUnit. (( > :: ), ( > ::: ))
2+
3+ let suites =
4+ __FILE__
5+ > ::: [
6+ ( " escape 'hello'" > :: fun _ ->
7+ let escaped = Json. escape " hello" in
8+ let expected = " hello" in
9+ OUnit. assert_equal escaped expected );
10+ ( " escape \\ x17" > :: fun _ ->
11+ let escaped = Json. escape " \x17 " in
12+ let expected = " \\ u0017" in
13+ OUnit. assert_equal escaped expected );
14+ ]
Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ let suites =
22 OUnit. ( > ::: ) __FILE__
33 [
44 Ounit_vec_test. suites;
5+ Ounit_json_tests. suites;
56 Ounit_ext_json_tests. suites;
67 Ounit_path_tests. suites;
78 Ounit_array_tests. suites;
You can’t perform that action at this time.
0 commit comments