File: test_succ.rb

package info (click to toggle)
ruby-facets 2.9.2-1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 9,824 kB
  • sloc: ruby: 25,483; xml: 90; makefile: 20
file content (35 lines) | stat: -rw-r--r-- 772 bytes parent folder | download | duplicates (2)
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
require 'facets/succ.rb'
require 'test/unit'

class TestStringSucc < Test::Unit::TestCase

  def test_succ
    assert_equal( "b", "a".succ )
    assert_equal( "b", "a".succ(1) )
    assert_equal( "c", "a".succ(2) )
    assert_equal( "d", "a".succ(3) )
  end

end

class TestNumericSucc < Test::Unit::TestCase

  def test_pred
    assert_equal(  3,  4.pred )
    assert_equal( -3, -2.pred )
    assert_equal(  2,  4.pred(2) )
    assert_equal( -4, -2.pred(2) )
    assert_equal(  6,  4.pred(-2) )
    assert_equal(  0, -2.pred(-2) )
  end

  def test_succ
    assert_equal(  5,  4.succ )
    assert_equal( -1, -2.succ )
    assert_equal(  6,  4.succ(2) )
    assert_equal(  0, -2.succ(2) )
    assert_equal(  2,  4.succ(-2) )
    assert_equal( -4, -2.succ(-2) )
  end

end