File: geometry.rb

package info (click to toggle)
subtle 0.11.3224-xi-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,600 kB
  • sloc: ansic: 14,699; ruby: 3,101; makefile: 17
file content (50 lines) | stat: -rw-r--r-- 1,272 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#
# @package test
#
# @file Test Subtlext::Geometry functions
# @author Christoph Kappel <unexist@subforge.org>
# @version $Id: test/contexts/geometry.rb,v 3169 2012/01/03 20:43:30 unexist $
#
# This program can be distributed under the terms of the GNU GPLv2.
# See the file COPYING for details.
#

context 'Geometry' do
  setup do # {{{
    Subtlext::Geometry.new(0, 0, 1, 1)
  end # }}}

  asserts 'Init types' do # {{{
    g1 = Subtlext::Geometry.new(topic)
    g2 = Subtlext::Geometry.new([ 0, 0, 1, 1 ])
    g3 = Subtlext::Geometry.new({ x: 0, y: 0, width: 1, height: 1 })
    g4 = Subtlext::Geometry.new("0x0+1+1")

    topic == g1 and g1 == g2 and g1 == g3 and g1 == g4
  end # }}}

  asserts 'Check attributes' do # {{{
    0 == topic.x and 0 == topic.y and 1 == topic.width and 1 == topic.height
  end # }}}

  asserts 'Type conversions' do # {{{
    hash = topic.to_hash
    ary  = topic.to_ary

    hash.values == ary
  end # }}}

  asserts 'Equal and compare' do # {{{
    topic.eql?(Subtlext::Geometry.new(0, 0, 1, 1)) and topic == topic
  end # }}}

  asserts 'Hash and unique' do # {{{
    1 == [ topic, topic ].uniq.size
  end # }}}

  asserts 'Convert to string' do # {{{
    '0x0+1+1' == topic.to_str
  end # }}}
end

# vim:ts=2:bs=2:sw=2:et:fdm=marker