| 1 | require File.expand_path(File.join(File.dirname(__FILE__), "..", "helper"))
|
|---|
| 2 | require "smtools/options"
|
|---|
| 3 |
|
|---|
| 4 | class TestOptions < Test::Unit::TestCase
|
|---|
| 5 | def test_options_create_bpms
|
|---|
| 6 | command, data = SMTools::Options.create("#BPMS:0.000=60.000;")
|
|---|
| 7 | assert_equal "BPMS", command
|
|---|
| 8 | assert_kind_of SMTools::Options::BPMS, data
|
|---|
| 9 |
|
|---|
| 10 | # option = SMTools::Options.create("#BPMS:0.000=60.000,\n16.000=120.000;")
|
|---|
| 11 | # assert_kind_of SMTools::Options::BPMS, option
|
|---|
| 12 | end
|
|---|
| 13 |
|
|---|
| 14 | def test_options_create_numerics
|
|---|
| 15 | [
|
|---|
| 16 | ["OFFSET", "#OFFSET:0.123;"],
|
|---|
| 17 | ["SAMPLESTART", "#SAMPLESTART:0.123;"],
|
|---|
| 18 | ["SAMPLELENGTH", "#SAMPLELENGTH:0.123;"],
|
|---|
| 19 | ].each do |source|
|
|---|
| 20 | command, data = SMTools::Options.create(source[1])
|
|---|
| 21 | assert_equal source[0], command
|
|---|
| 22 | assert_kind_of Float, data
|
|---|
| 23 | assert_equal 0.123, data
|
|---|
| 24 | end
|
|---|
| 25 | end
|
|---|
| 26 |
|
|---|
| 27 | def test_options_create_strings
|
|---|
| 28 | [
|
|---|
| 29 | ["TITLE", "#TITLE:data;"],
|
|---|
| 30 | ["SUBTITLE", "#SUBTITLE:data;"],
|
|---|
| 31 | ["ARTIST", "#ARTIST:data;"],
|
|---|
| 32 | ["TITLETRANSLIT", "#TITLETRANSLIT:data;"],
|
|---|
| 33 | ["SUBTITLETRANSLIT", "#SUBTITLETRANSLIT:data;"],
|
|---|
| 34 | ["ARTISTTRANSLIT", "#ARTISTTRANSLIT:data;"],
|
|---|
| 35 | ["CREDIT", "#CREDIT:data;"],
|
|---|
| 36 | ["BANNER", "#BANNER:data;"],
|
|---|
| 37 | ["BACKGROUND", "#BACKGROUND:data;"],
|
|---|
| 38 | ["LYRICSPATH", "#LYRICSPATH:data;"],
|
|---|
| 39 | ["CDTITLE", "#CDTITLE:data;"],
|
|---|
| 40 | ["MUSIC", "#MUSIC:data;"],
|
|---|
| 41 | ].each do |source|
|
|---|
| 42 | command, data = SMTools::Options.create(source[1])
|
|---|
| 43 | assert_equal source[0], command
|
|---|
| 44 | assert_kind_of String, data
|
|---|
| 45 | assert_equal "data", data
|
|---|
| 46 | end
|
|---|
| 47 | end
|
|---|
| 48 |
|
|---|
| 49 | def test_options_create_unknown_option
|
|---|
| 50 | command, data = SMTools::Options.create("#COMMAND:DATA;")
|
|---|
| 51 | assert_equal "COMMAND", command
|
|---|
| 52 | assert_kind_of String, data
|
|---|
| 53 | assert_equal "DATA", data
|
|---|
| 54 | end
|
|---|
| 55 |
|
|---|
| 56 | def test_options_create_error_invalid_data
|
|---|
| 57 | assert_raise(TypeError){ SMTools::Options.create("#INVALID;") }
|
|---|
| 58 | assert_raise(TypeError){ SMTools::Options.create("INVALID") }
|
|---|
| 59 | end
|
|---|
| 60 | end
|
|---|