Skip to content

Commit 213c278

Browse files
nobumatzbot
authored andcommitted
[ruby/optparse] Add test for enum arguments
ruby/optparse@0a0e977b7c
1 parent 0c73328 commit 213c278

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

test/optparse/test_placearg.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ def setup
77
@opt.def_option("-x [VAL]") {|x| @flag = x}
88
@opt.def_option("--option [VAL]") {|x| @flag = x}
99
@opt.def_option("-T [level]", /^[0-4]$/, Integer) {|x| @topt = x}
10+
@opt.def_option("--enum [VAL]", [:Alpha, :Bravo, :Charlie]) {|x| @enum = x}
1011
@topt = nil
1112
@opt.def_option("-n") {}
1213
@opt.def_option("--regexp [REGEXP]", Regexp) {|x| @reopt = x}
@@ -93,4 +94,9 @@ def test_lambda
9394
assert_equal(%w"", no_error {@opt.parse!(%w"--lambda")})
9495
assert_equal(nil, @flag)
9596
end
97+
98+
def test_enum
99+
assert_equal([], no_error {@opt.parse!(%w"--enum=A")})
100+
assert_equal(:Alpha, @enum)
101+
end
96102
end

0 commit comments

Comments
 (0)