Sha256: 70869ceac6d5eb3e95d3831f562a195ec77683ed14273ddd4419d24f2776a344
Contents?: true
Size: 995 Bytes
Versions: 2
Compression:
Stored size: 995 Bytes
Contents
# -*- coding: utf-8 -*- require_relative 'helper' class TestText < Test::Unit::TestCase LINES = %w[123 456] def buffer (str = nil) str = LINES.join("\n") unless str str = str.dup if String === str Spacy::TextBuffer.new str end def text () Spacy::Text.new buffer end def test_pos () lineend = LINES[0].size assert_equal [0, 0], text.cursor assert_equal [0, 1], text.tap{|t| t.pos += 1}.cursor assert_equal [0, lineend], text.tap{|t| t.pos = lineend}.cursor assert_equal [1, 0], text.tap{|t| t.pos = lineend + 1}.cursor end def test_cursor () lineend = LINES[0].size size = LINES.inject(0) {|n, s| n + s.size + 1} - 1 assert_equal lineend, text.tap{|t| t.cursor = 0, lineend}.pos assert_equal size, text.tap{|t| t.cursor = 1, 4}.pos end def test_row () assert_equal [1, 0], text.tap{|t| t.row += 1}.cursor assert_equal [0, 1], text.tap{|t| t.column += 1}.cursor end end# TestText
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
spacy-0.1.6 | test/test_text.rb |
spacy-0.1.5 | test/test_text.rb |