-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
39 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
require 'test/unit' | ||
require 'orientdb4r' | ||
|
||
### | ||
# This class tests Utils methods. | ||
class TestDmo < Test::Unit::TestCase | ||
include Orientdb4r::Utils | ||
|
||
def test_verify_options | ||
opt_pattern = {:a => :mandatory, :b => :optional, :c => 'predefined', :d => [1, 2]} | ||
assert_nothing_thrown do verify_options({:a => 'A', :b => 'B', :c => 'C', :d => 1}, opt_pattern); end | ||
|
||
# missing mandatory | ||
assert_raise ArgumentError do verify_options({}, opt_pattern); end | ||
# unknown key | ||
assert_raise ArgumentError do verify_options({:a => 1, :z => 2}, opt_pattern); end | ||
# value not in predefined set | ||
assert_raise ArgumentError do verify_options({:a => 1, :d => 3}, opt_pattern); end | ||
end | ||
|
||
def test_verify_and_sanitize_options | ||
opt_pattern = {:a => 'A', :b => 'B'} | ||
options = {:a => 'X'} | ||
verify_and_sanitize_options(options, opt_pattern) | ||
assert_equal 2, options.size | ||
assert_equal 'X', options[:a] | ||
assert_equal 'B', options[:b] | ||
end | ||
|
||
end |