File: json_test.rb

package info (click to toggle)
ruby-spring 4.4.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 444 kB
  • sloc: ruby: 3,584; sh: 9; makefile: 7
file content (17 lines) | stat: -rw-r--r-- 534 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
require_relative "../helper"
require 'spring/json'

class JsonTest < ActiveSupport::TestCase
  test 'can decode unicode characters' do
    assert_equal({"unicode_example"=>"©"}, Spring::JSON.load('{"unicode_example": "\u00A9"}'))
  end

  test 'can decode binary strings with valid UTF8 characters' do
    string = "{\"PS1\":\"\xEF\x90\x98 main \xEE\x9E\x91 v3.4.2\"}".b
    assert_equal({"PS1"=>" main  v3.4.2"}, Spring::JSON.load(string))
  end

  test 'can encode' do
    assert_equal('{}', Spring::JSON.dump({}))
  end
end