File: GH-2856_bad_character_transcode_should_not_hang_spec.rb

package info (click to toggle)
jruby 1.7.26-1%2Bdeb9u1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 84,572 kB
  • sloc: ruby: 669,910; java: 253,056; xml: 35,152; ansic: 9,187; yacc: 7,267; cpp: 5,244; sh: 1,036; makefile: 345; jsp: 48; tcl: 40
file content (15 lines) | stat: -rw-r--r-- 518 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
require 'base64'

describe "A badly-encoded UTF-8 String reencoded with replacements as UTF-16 " do
  it "completes for all inputs" do
    random = Random.new
    # We obviously can't test all valid inputs, but we use the script from #2856 to try
    10_000.times do
      data = random.bytes(1000)
      data.force_encoding("UTF-8")
      data = data.encode("UTF-16", :undef => :replace, :invalid => :replace, :replace => '')

      expect(data).to_not eq(nil)
    end
  end
end unless RUBY_VERSION.index('1.8') == 0