diff options
author | Eric Wong <e@80x24.org> | 2015-12-07 02:34:28 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2015-12-14 02:04:44 +0000 |
commit | 6c8504238ddbd96deea577df58c043b95cb1068d (patch) | |
tree | 3ddcebc0f388d6935b3d4df4dda23851a41aa73d /test | |
parent | 71cc32bcac667c699b89ef5f0b5147cf1b3670a5 (diff) | |
download | dtas-6c8504238ddbd96deea577df58c043b95cb1068d.tar.gz |
This (from the point of the client) will atomically swap two tracks. This should allow easily implementing of a tracklist editor.
Diffstat (limited to 'test')
-rw-r--r-- | test/test_tracklist.rb | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/test/test_tracklist.rb b/test/test_tracklist.rb index c918ff7..c05090c 100644 --- a/test/test_tracklist.rb +++ b/test/test_tracklist.rb @@ -120,4 +120,15 @@ class TestTracklist < Testcase assert_kind_of Integer, tl.add_track('y') assert_equal 2, tl.instance_variable_get(:@list).size end + + def test_swap + tl = DTAS::Tracklist.new + list_add(tl, %w(a b c d e f g)) + mapping = _build_mapping(tl) + assert tl.swap(mapping['a'], mapping['g']) + assert_equal %w(g b c d e f a), list_to_path(tl) + + assert_nil tl.swap(-2, -3), 'no swap on invalid' + assert_equal %w(g b c d e f a), list_to_path(tl) + end end |