/vendor/plugins/rtf-0.1.0/test/DocumentStyleTest.rb

http://rorptm.googlecode.com/ · Ruby · 85 lines · 61 code · 22 blank · 2 comment · 25 complexity · f28770be8524845f5f7f9c0e5e723e6d MD5 · raw file

  1. #!/usr/bin/env ruby
  2. require 'rubygems'
  3. require 'test/unit'
  4. require 'rtf'
  5. include RTF
  6. # Information class unit test class.
  7. class DocumentStyleTest < Test::Unit::TestCase
  8. def test_basics
  9. style = DocumentStyle.new
  10. assert(style.is_character_style? == false)
  11. assert(style.is_document_style? == true)
  12. assert(style.is_paragraph_style? == false)
  13. assert(style.is_table_style? == false)
  14. assert(style.prefix(nil, nil) == '\paperw11907\paperh16840\margl1800'\
  15. '\margr1800\margt1440\margb1440')
  16. assert(style.suffix(nil, nil) == nil)
  17. assert(style.bottom_margin == DocumentStyle::DEFAULT_BOTTOM_MARGIN)
  18. assert(style.gutter == nil)
  19. assert(style.left_margin == DocumentStyle::DEFAULT_LEFT_MARGIN)
  20. assert(style.orientation == DocumentStyle::PORTRAIT)
  21. assert(style.paper == Paper::A4)
  22. assert(style.right_margin == DocumentStyle::DEFAULT_RIGHT_MARGIN)
  23. assert(style.top_margin == DocumentStyle::DEFAULT_TOP_MARGIN)
  24. end
  25. def test_mutators
  26. style = DocumentStyle.new
  27. style.bottom_margin = 200
  28. assert(style.bottom_margin == 200)
  29. style.gutter = 1000
  30. assert(style.gutter == 1000)
  31. style.left_margin = 34
  32. assert(style.left_margin == 34)
  33. style.orientation = DocumentStyle::LANDSCAPE
  34. assert(style.orientation == DocumentStyle::LANDSCAPE)
  35. style.paper = Paper::LETTER
  36. assert(style.paper == Paper::LETTER)
  37. style.right_margin = 345
  38. assert(style.right_margin == 345)
  39. style.top_margin = 819
  40. assert(style.top_margin == 819)
  41. end
  42. def test_prefix
  43. style = DocumentStyle.new
  44. style.left_margin = style.right_margin = 200
  45. style.top_margin = style.bottom_margin = 100
  46. style.gutter = 300
  47. style.orientation = DocumentStyle::LANDSCAPE
  48. style.paper = Paper::A5
  49. assert(style.prefix(nil, nil) == '\paperw11907\paperh8392\margl200'\
  50. '\margr200\margt100\margb100\gutter300'\
  51. '\sectd\lndscpsxn')
  52. end
  53. def test_body_method
  54. style = DocumentStyle.new
  55. lr_margin = style.left_margin + style.right_margin
  56. tb_margin = style.top_margin + style.bottom_margin
  57. assert(style.body_width == Paper::A4.width - lr_margin)
  58. assert(style.body_height == Paper::A4.height - tb_margin)
  59. style.orientation = DocumentStyle::LANDSCAPE
  60. assert(style.body_width == Paper::A4.height - lr_margin)
  61. assert(style.body_height == Paper::A4.width - tb_margin)
  62. end
  63. end