File: conversions_test.rb

package info (click to toggle)
ruby-linked-list 0.0.14-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 156 kB
  • sloc: ruby: 957; sh: 4; makefile: 4
file content (32 lines) | stat: -rw-r--r-- 824 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
require 'test_helper'

describe LinkedList::Conversions do
  describe 'Node()' do
    it 'returns self if node is given' do
      node = create_node('foo')
      assert_equal LinkedList::Conversions.Node(node), node
    end

    it 'returns new node' do
      assert_instance_of LinkedList::Node,
        LinkedList::Conversions.Node('foo')
    end
  end

  describe 'List()' do
    it 'returns self if list is given' do
      list = create_list
      assert_equal LinkedList::Conversions.List(list), list
    end

    it 'returns list with nodes made from array' do
      list = LinkedList::Conversions.List([1, 2])
      assert_equal [1, 2], [list.first, list.last]
    end

    it 'returns new list with one node' do
      list = LinkedList::Conversions.List('foo')
      assert_equal 'foo', list.first
    end
  end
end