Sha256: 49cc51ff9100a9173e2ecd4eb3d0b7049f841e9a3caa3ae873b5774e1ad61a9e

Contents?: true

Size: 1.05 KB

Versions: 3

Compression:

Stored size: 1.05 KB

Contents

require 'test_helper'

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,Gbarcode::BARCODE_OUT_EPS)
    w.close()
    b = r.read
    r.close()
    f = File.open(File.dirname(__FILE__) + "/assets/gb-code128b.eps").read
    assert_equal(b,f)
  end
  
end

Version data entries

3 entries across 3 versions & 2 rubygems

Version Path
gbarcode-linux-0.98.20 test/gbarcode_test.rb
gbarcode-98-20-0.98.21 test/gbarcode_test.rb
gbarcode-98-20-0.98.20 test/gbarcode_test.rb