Skip to content
Myr

utf8test

This file

Path

tests/utf8test

38 lines · 1.3 KiB

Last changed by

Improve performance of string output (#3643)Michiel van Slobbebefore adoptionb904884

History of this file

Take it

1#!/bin/sh -x23. "${0%/*}/setup" "$@"45# Reading jq file does not corrupt multi-byte characters -- #13116for l in 1 2 3 4; do7  $VALGRIND $Q $JQ -rn "[(range($l) | 48), (range(3000) | 128515)] | implode |8    \"\\(tojson) | explode | unique == [48, 128515]\"" > $d/input9  if ! $VALGRIND $Q $JQ -nef $d/input > /dev/null; then10    echo "Reading jq file corrupted multi-byte characters"11    exit 112  fi13done1415# Slurping raw input does not corrupt multi-byte characters -- #338916for l in 1 2 3 4; do17  $VALGRIND $Q $JQ -jn "[(range($l) | 48), (range(3000) | 128515)] | implode" > $d/input18  if ! $VALGRIND $Q $JQ -Rse 'explode | unique == [48, 128515]' $d/input > /dev/null; then19    echo "Slurping raw input corrupted multi-byte characters"20    exit 121  fi22done2324# --ascii-output escapes non-ASCII characters on both sides of runs of25# bytes that need no escaping26$VALGRIND $Q $JQ -cn '[range(18) as $i | ("é", "😀", "\u007f") as $c |27  "abcdefghijklmnopq"[:$i] + $c + "abcdefghijklmnopq"[$i:]]' > $d/input28$VALGRIND $Q $JQ -ac . $d/input > $d/out29if LC_ALL=C grep -q '[^ -~]' $d/out; then30  echo "--ascii-output printed a non-ASCII byte"31  exit 132fi33if ! $VALGRIND $Q $JQ -e --slurpfile a $d/input '. == $a[0]' $d/out > /dev/null; then34  echo "--ascii-output changed a string"35  exit 136fi3738exit 0