Class: TestXmlEscaping

Inherits:
Builder::Test show all
Defined in:
lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/builder-3.2.4/test/test_xchar.rb

Constant Summary collapse

REPLACEMENT_CHAR =
Builder::XChar::REPLACEMENT_CHAR.to_xs

Constants inherited from Minitest::Test

Minitest::Test::PASSTHROUGH_EXCEPTIONS, Minitest::Test::SETUP_METHODS, Minitest::Test::TEARDOWN_METHODS

Constants included from Minitest::Assertions

Minitest::Assertions::E, Minitest::Assertions::UNDEFINED

Constants inherited from Minitest::Runnable

Minitest::Runnable::SIGNALS

Instance Attribute Summary

Attributes inherited from Minitest::Runnable

#assertions, #failures, #time

Instance Method Summary collapse

Methods inherited from Builder::Test

#assert_nothing_raised

Methods inherited from Minitest::Test

#capture_exceptions, #class_name, #clean, i_suck_and_my_tests_are_order_dependent!, make_my_diffs_pretty!, #neuter_exception, #new_exception, parallelize_me!, #run, runnable_methods, #sanitize_exception, test_order, #with_empty_backtrace_filter, #with_info_handler

Methods included from Minitest::Guard

#jruby?, #maglev?, #mri?, #osx?, #rubinius?, #windows?

Methods included from Minitest::Test::LifecycleHooks

#after_setup, #after_teardown, #before_setup, #before_teardown, #setup, #teardown

Methods included from Minitest::Reportable

#class_name, #error?, #location, #passed?, #result_code, #skipped?

Methods included from Minitest::Assertions

#_synchronize, #assert, #assert_empty, #assert_equal, #assert_in_delta, #assert_in_epsilon, #assert_includes, #assert_instance_of, #assert_kind_of, #assert_match, #assert_mock, #assert_nil, #assert_operator, #assert_output, #assert_path_exists, #assert_predicate, #assert_raises, #assert_respond_to, #assert_same, #assert_send, #assert_silent, #assert_throws, #capture_io, #capture_subprocess_io, #diff, diff, diff=, #exception_details, #fail_after, #flunk, #message, #mu_pp, #mu_pp_for_diff, #pass, #refute, #refute_empty, #refute_equal, #refute_in_delta, #refute_in_epsilon, #refute_includes, #refute_instance_of, #refute_kind_of, #refute_match, #refute_nil, #refute_operator, #refute_path_exists, #refute_predicate, #refute_respond_to, #refute_same, #skip, #skip_until, #skipped?, #things_to_diff

Methods inherited from Minitest::Runnable

#failure, inherited, #initialize, #marshal_dump, #marshal_load, methods_matching, #name, #name=, on_signal, #passed?, reset, #result_code, run, #run, run_one_method, runnable_methods, runnables, #skipped?, #time_it, #whatever, with_info_handler

Constructor Details

This class inherits a constructor from Minitest::Runnable

Instance Method Details

#test_asciiObject



42
43
44
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/builder-3.2.4/test/test_xchar.rb', line 42

def test_ascii
  assert_equal 'abc', 'abc'.to_xs
end

#test_invalidObject



52
53
54
55
56
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/builder-3.2.4/test/test_xchar.rb', line 52

def test_invalid
  assert_equal REPLACEMENT_CHAR, "\x00".to_xs               # null
  assert_equal REPLACEMENT_CHAR, "\x0C".to_xs               # form feed
  assert_equal REPLACEMENT_CHAR, "\xEF\xBF\xBF".to_xs       # U+FFFF
end

#test_iso_8859_1Object



58
59
60
61
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/builder-3.2.4/test/test_xchar.rb', line 58

def test_iso_8859_1
  assert_equal 'ç', "\xE7".to_xs          # small c cedilla
  assert_equal '©', "\xA9".to_xs          # copyright symbol
end

#test_predefinedObject



46
47
48
49
50
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/builder-3.2.4/test/test_xchar.rb', line 46

def test_predefined
  assert_equal '&', '&'.to_xs              # ampersand
  assert_equal '&lt;',  '<'.to_xs              # left angle bracket
  assert_equal '&gt;',  '>'.to_xs              # right angle bracket
end

#test_utf8Object



68
69
70
71
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/builder-3.2.4/test/test_xchar.rb', line 68

def test_utf8
  assert_equal '&#8217;', "\xE2\x80\x99".to_xs # right single quote
  assert_equal '&#169;',  "\xC2\xA9".to_xs     # copy
end

#test_utf8_verbatimObject



73
74
75
76
77
78
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/builder-3.2.4/test/test_xchar.rb', line 73

def test_utf8_verbatim
  assert_equal binary("\xE2\x80\x99"), "\xE2\x80\x99".to_xs(false)  # right single quote
  assert_equal binary("\xC2\xA9"),  "\xC2\xA9".to_xs(false)         # copy
  assert_equal binary("\xC2\xA9&amp;\xC2\xA9"),
    "\xC2\xA9&\xC2\xA9".to_xs(false)                                # copy with ampersand
end

#test_win_1252Object



63
64
65
66
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/builder-3.2.4/test/test_xchar.rb', line 63

def test_win_1252
  assert_equal '&#8217;', "\x92".to_xs         # smart quote
  assert_equal '&#8364;', "\x80".to_xs         # euro
end