-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_parser.rb
More file actions
40 lines (31 loc) · 959 Bytes
/
test_parser.rb
File metadata and controls
40 lines (31 loc) · 959 Bytes
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
require 'test/unit'
require 'parser'
class TestParser < Test::Unit::TestCase
def test_line_void
parser = Parser.new([])
expected = parser.parse("")
assert_equal expected, []
end
def test_line_spaces
parser = Parser.new([])
expected = parser.parse(" ")
assert_equal expected, []
end
def test_line_string
parser = Parser.new([:s])
assert_equal [ "4p" ], parser.parse("4p")
end
def test_line_integer
parser = Parser.new([:i])
assert_equal [ 4 ], parser.parse("4")
end
def test_line_float
parser = Parser.new([:f])
assert_equal [ 4.2 ], parser.parse("4.2")
end
def test_line_variated
parser = Parser.new([:f, :i, :s, :i, :f, :f])
assert_equal([ 4.2, 123, "Slavoj_Zi:Zek", 88, 2.78901234, 8],
parser.parse("4.2 123 Slavoj_Zi:Zek 88 2.78901234 8"))
end
end