Sha256: 87e0b83ee0e27c54594ff6c6cd9a81db69011fca0e4587be68a0ef08d98cc32a

Contents?: true

Size: 1.79 KB

Versions: 13

Compression:

Stored size: 1.79 KB

Contents

#!/usr/bin/env ruby

require 'TestSetup'
require 'test/unit'
require 'rubygems'
require 'fireruby'

include FireRuby

class CharacterSetTest < Test::Unit::TestCase
   CURDIR   = "#{Dir.getwd}"
   DB_FILE  = "#{CURDIR}#{File::SEPARATOR}cxnarset_unit_test.fdb"
   CHAR_SET = 'WIN1251'
   
   def setup
      puts "#{self.class.name} started." if TEST_LOGGING
      if File::exist?(DB_FILE)
         Database.new(DB_FILE).drop(DB_USER_NAME, DB_PASSWORD)
      end

      @database = Database.create(DB_FILE, DB_USER_NAME, DB_PASSWORD, 1024,
                                  CHAR_SET)
   end
   
   def teardown
      if File::exist?(DB_FILE)
         Database.new(DB_FILE).drop(DB_USER_NAME, DB_PASSWORD)
      end
      puts "#{self.class.name} finished." if TEST_LOGGING
   end

   def test01
      db = Database.new(DB_FILE, CHAR_SET)

      assert(db.character_set = CHAR_SET)

      db.character_set = 'ASCII'
      assert(db.character_set == 'ASCII')
   end

   def test02
      text = "?"
      db   = Database.new(DB_FILE, CHAR_SET)

      begin
         db.connect("SYSDBA", "masterkey") do |cxn|
            cxn.start_transaction do |tr|
               cxn.execute("CREATE TABLE SAMPLE_TABLE(SAMPLE_FIELD VARCHAR(100))",tr)
            end  
            cxn.start_transaction do |tr|
               cxn.execute("INSERT INTO SAMPLE_TABLE VALUES ('#{win1251_str}')",tr)
               cxn.execute("SELECT * FROM SAMPLE_TABLE WHERE SAMPLE_FIELD = "\
                           "'#{win1251_str}'",tr) do |row|
                  # here we have an exception:
                  some_var = row['SAMPLE_FIELD']
               end
            end
         end
      rescue => error
         assert("Character set unit test failure.", false)
      end
   end
end

Version data entries

13 entries across 13 versions & 2 rubygems

Version Path
rubyfb-0.5.4-x86-mswin32-60 test/CharacterSetTest.rb
rubyfb-0.5.4-x86-linux test/CharacterSetTest.rb
rubyfb-0.5.4 test/CharacterSetTest.rb
rubyfb-0.5.3-x86-mswin32-60 test/CharacterSetTest.rb
rubyfb-0.5.3-x86-linux test/CharacterSetTest.rb
rubyfb-0.5.3 test/CharacterSetTest.rb
rubyfb-0.5.2-x86-mswin32-60 test/CharacterSetTest.rb
rubyfb-0.5.2-x86-linux test/CharacterSetTest.rb
rubyfb-0.5.2 test/CharacterSetTest.rb
fireruby-0.4.3-mswin32 test/CharacterSetTest.rb
fireruby-0.4.3-i586-linux test/CharacterSetTest.rb
fireruby-0.4.2-mswin32 test/CharacterSetTest.rb
fireruby-0.4.2-i586-linux test/CharacterSetTest.rb