Sha256: 0eaf8a781ded9209bbe4219ca71f0e3dcdd0d9fe1ab0938f758206b4cab6aafc

Contents?: true

Size: 759 Bytes

Versions: 2

Compression:

Stored size: 759 Bytes

Contents

require "minitest/autorun"

require "text_generator"

class MarkovTest < Minitest::Unit::TestCase

  def setup
    @text = "Le chat aime les souris vertes et grasses"
    @text_array = @text.split(" ")
    @n = rand(1..5)
    @genmax = rand(1..50)
    @generator = MarkovGenerator.new(@n, @genmax)
    @generator.feed(@text)
  end

  def test_tokenize_is_correct
    assert_equal @generator.tokenize(@text), @text_array
  end

  def test_feed_line
    assert_equal @generator.beginnings, [@text_array.first(@n)]
  end

  def test_ngram_length
    @generator.ngrams.each_key do |k|
      assert_equal k.length, @n
    end
  end

  def test_genmax
    sentence = @generator.generate.split(" ")
    assert_operator sentence.length, :<=, @genmax
  end
end


  
  

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
text_generator-0.0.2 test/mg_test.rb
text_generator-0.0.1 test/mg_test.rb