Sha256: 0dde8e500e37b51da19c1e67cd74bcf799fabc9200fa03a786d5b7e21efa3367

Contents?: true

Size: 985 Bytes

Versions: 2

Compression:

Stored size: 985 Bytes

Contents

# encoding: ASCII-8BIT
require 'test_helper'

class DerbyUnitTest < Test::Unit::TestCase

  class DerbyImpl
    include ArJdbc::Derby
    def initialize; end
  end
  derby = DerbyImpl.new
  
  test "quote (string) without column passed" do
    s = "'"; q = "''"
    assert_equal q, derby.quote_string(s)
    assert_equal "'string #{q}'", derby.quote(v = "string #{s}"), "while quoting #{v.inspect}"
    assert_equal "' #{q}'", derby.quote(v = " #{s}", nil), "while quoting #{v.inspect}"
    assert_equal "'#{q}str'", derby.quote(v = "#{s}str", nil), "while quoting #{v.inspect}"
  end

  test "quote (string) keeps original" do
    s = "kôň ůň löw9876qűáéőú.éáű-mehehehehehehe0 \x01 \x02"
    q = "'kôň ůň löw9876qűáéőú.éáű-mehehehehehehe0 \x01 \x02'"
    assert_equal q, derby.quote(s.dup)
    
    if s.respond_to?(:force_encoding)
      s.force_encoding('UTF-8')
      q.force_encoding('UTF-8')
      assert_equal q, derby.quote(s.dup)
    end
  end
  
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
activerecord-jdbc-adapter-1.3.0.beta2 test/db/derby/unit_test.rb
activerecord-jdbc-adapter-1.3.0.beta1 test/db/derby/unit_test.rb