File: word_list_test.rb

package info (click to toggle)
ruby-classifier-reborn 2.2.0-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 1,420 kB
  • sloc: ruby: 2,021; makefile: 5
file content (33 lines) | stat: -rw-r--r-- 839 bytes parent folder | download | duplicates (6)
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
require_relative '../test_helper'

class WordListTest < Minitest::Test
  def test_size_does_not_count_words_twice
    list = ClassifierReborn::WordList.new
    assert list.size == 0

    list.add_word('hello')
    assert list.size == 1

    list.add_word('hello')
    assert list.size == 1

    list.add_word('world')
    assert list.size == 2
  end

  def test_brackets_return_correct_position_based_on_add_order
    list = ClassifierReborn::WordList.new
    list.add_word('hello')
    list.add_word('world')
    assert list['hello'] == 0
    assert list['world'] == 1
  end

  def test_word_for_index_returns_correct_word_based_on_add_order
    list = ClassifierReborn::WordList.new
    list.add_word('hello')
    list.add_word('world')
    assert list.word_for_index(0) == 'hello'
    assert list.word_for_index(1) == 'world'
  end
end