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