Sha256: d907454f6ae88371cbd3ebb88fac23f615d9bf5d849daa74dc84ea3458911784

Contents?: true

Size: 1.09 KB

Versions: 1

Compression:

Stored size: 1.09 KB

Contents

require File.dirname(__FILE__) + '/test_helper.rb'

class GbarcodeTest < Test::Unit::TestCase

  def setup 
    @@BC_TEXT = "Gbarcode"
    @@BC = Gbarcode.barcode_create(@@BC_TEXT)
    Gbarcode.barcode_encode(@@BC, Gbarcode::BARCODE_128B)
  end

  def teardown
    Gbarcode.barcode_delete(@@BC)
  end
  
  def test_barcode_create
    assert(@@BC != nil, "BC not created")
  end
  
  def test_barcode_delete
    r = Gbarcode.barcode_delete(Gbarcode.barcode_create(@@BC_TEXT))
    assert(r == 0, "barcode_delete failed")
  end
  
  def test_ascii
    assert_equal(@@BC.ascii, "Gbarcode")
  end
  
  def test_barcode_encode
    b = Gbarcode.barcode_create("1234")
    r = Gbarcode.barcode_encode(b, Gbarcode::BARCODE_39)
    assert(r == 0, "encoding unsuccessful")
  end
  
  def test_encoding
    assert_equal(@@BC.encoding, "code 128-B")
  end
  
  def test_barcode_print
    r,w = File.pipe
    Gbarcode.barcode_print(@@BC,w,0)
    w.close()
    b = r.readlines().join("\n")
    r.close()
    f = File.open(File.dirname(__FILE__) + "/ assets/gb-code128b.eps").readlines.join("\n")
    assert_equal(b,f)
  end
  
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
gbarcode-0.98.16-mswin32 test/gbarcode_test.rb