-
Notifications
You must be signed in to change notification settings - Fork 0
/
ProgramInRubyTest.rb
64 lines (49 loc) · 1.54 KB
/
ProgramInRubyTest.rb
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#
# Rubyによるプログラムのテスト
#
require "test/unit"
require "./ProgramInRuby"
class ProgramInRubyTest < Test::Unit::TestCase
def test_prime_numbersで最大値2までの素数の配列が返却される
max = 2
expected = [2]
actual = ProgramInRuby.prime_numbers(max)
assert_equal(actual, expected)
end
def test_prime_numbersで最大値1までの素数の配列が返却される
max = 1
expected = []
actual = ProgramInRuby.prime_numbers(max)
assert_equal(actual, expected)
end
def test_prime_numbersで最大値13までの素数の配列が返却される
max = 13
expected = [2, 3, 5, 7, 11, 13]
actual = ProgramInRuby.prime_numbers(max)
assert_equal(actual, expected)
end
def test_prime_numbersで最大値15までの素数の配列が返却される
max = 15
expected = [2, 3, 5, 7, 11, 13]
actual = ProgramInRuby.prime_numbers(max)
assert_equal(actual, expected)
end
def test_prime_numbersで最大値0までの素数の配列が返却される
max = 0
expected = []
actual = ProgramInRuby.prime_numbers(max)
assert_equal(actual, expected)
end
def test_prime_numbersで最大値マイナス1までの素数の配列が返却される
max = -1
expected = []
actual = ProgramInRuby.prime_numbers(max)
assert_equal(actual, expected)
end
def test_prime_numbersでmaxが整数でない場合TypeErrorが発生する
max = "2"
assert_raise(TypeError) do
ProgramInRuby.prime_numbers(max)
end
end
end