File: node_test.rb

package info (click to toggle)
ruby-linked-list 0.0.14-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, trixie
  • size: 156 kB
  • sloc: ruby: 957; sh: 4; makefile: 4
file content (42 lines) | stat: -rw-r--r-- 741 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
33
34
35
36
37
38
39
40
41
42
require 'test_helper'

describe LinkedList::Node do
  let(:node) { create_node('foo') }

  describe 'instantiation' do
    it 'assigns data' do
      assert_equal 'foo', node.data
    end

    it 'assigns nil to next' do
      assert_nil node.next
    end

    it 'assigns nil to prev' do
      assert_nil node.prev
    end
  end

  describe 'accessors' do
    it '#data' do
      node.data = 'bar'
      assert_equal 'bar', node.data
    end

    it '#next' do
      node.next = 'bar'
      assert_equal 'bar', node.next
    end

    it '#prev' do
      node.prev = 'xyz'
      assert_equal 'xyz', node.prev
    end
  end

  describe 'conversion' do
    it '#to_node returns self' do
      assert_equal node, node.to_node
    end
  end
end