Sha256: 4f2c29350ae62c5519ab5472498c3bb5cb002788b26d066cc65f522aa8f28428

Contents?: true

Size: 1.67 KB

Versions: 17

Compression:

Stored size: 1.67 KB

Contents

# -*- coding: utf-8 -*-
##########################################################################
# test_23_note.rb
#
# Tests for some of the internal method used to write the NOTE record that
# is used in cell comments.
#
# reverse('©'), September 2005, John McNamara, jmcnamara@cpan.org
#
# original written in Perl by John McNamara
# converted to Ruby by Hideo Nakamura, cxn03651@msj.biglobe.ne.jp
#
#########################################################################
require 'helper'
require 'stringio'

class TC_note < Test::Unit::TestCase

  def setup
    @workbook   = WriteExcel.new(StringIO.new)
    @worksheet  = @workbook.add_worksheet
  end

  def test_blank_author_name
    comment = Writeexcel::Worksheet::Comment.new(@worksheet, 2, 0, 'Test')
    obj_id   = 1

    caption = sprintf(" \tnote_record")
    target  = %w(
        1C 00 0C 00 02 00 00 00 00 00 01 00 00 00 00 00
    ).join(' ')
    result = unpack_record(comment.store_note_record(obj_id))
    assert_equal(target, result, caption)
  end

  def test_defined_author_name
    comment = Writeexcel::Worksheet::Comment.new(@worksheet, 2, 0,'Test', :author => 'Username')
    obj_id   = 1

    caption = sprintf(" \tstore_note")
    target  = %w(
        1C 00 14 00 02 00 00 00 00 00 01 00 08 00 00 55
        73 65 72 6E 61 6D 65 00
    ).join(' ')
    result = unpack_record(comment.store_note_record(obj_id))
    assert_equal(target, result, caption)
  end

  ###############################################################################
  #
  # Unpack the binary data into a format suitable for printing in tests.
  #
  def unpack_record(data)
    data.unpack('C*').map! {|c| sprintf("%02X", c) }.join(' ')
  end

end

Version data entries

17 entries across 17 versions & 3 rubygems

Version Path
writeexcel-0.6.18 test/test_23_note.rb
writeexcel-0.6.17 test/test_23_note.rb
sunrise-cms-0.5.0.rc1 vendor/bundle/ruby/1.9.1/gems/writeexcel-0.6.16/test/test_23_note.rb
writeexcel-0.6.16 test/test_23_note.rb
writeexcel-0.6.15 test/test_23_note.rb
writeexcel-0.6.14 test/test_23_note.rb
sunrise-cms-0.3.3 vendor/bundle/ruby/1.9.1/gems/writeexcel-0.6.13/test/test_23_note.rb
sunrise-cms-0.3.2 vendor/bundle/ruby/1.9.1/gems/writeexcel-0.6.13/test/test_23_note.rb
sunrise-cms-0.3.1 vendor/bundle/ruby/1.9.1/gems/writeexcel-0.6.13/test/test_23_note.rb
sunrise-cms-0.3.0 vendor/bundle/ruby/1.9.1/gems/writeexcel-0.6.13/test/test_23_note.rb
sunrise-cms-0.3.0.rc vendor/bundle/ruby/1.9.1/gems/writeexcel-0.6.13/test/test_23_note.rb
writeexcel-0.6.13 test/test_23_note.rb
ricardoo27-writeexcel-0.6.12.2 test/test_23_note.rb
ricardoo27-writeexcel-0.6.12.1 test/test_23_note.rb
writeexcel-0.6.12 test/test_23_note.rb
writeexcel-0.6.11 test/test_23_note.rb
writeexcel-0.6.10 test/test_23_note.rb