about summary refs log tree commit homepage
path: root/test/test_tracklist.rb
diff options
context:
space:
mode:
Diffstat (limited to 'test/test_tracklist.rb')
-rw-r--r--test/test_tracklist.rb11
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