Sha256: b5f8ff21e92056480c0eea7f6c1390b2d92441149589ae37e05234b5b4868d0c

Contents?: true

Size: 818 Bytes

Versions: 2

Compression:

Stored size: 818 Bytes

Contents

#! /usr/bin/env ruby
require File.dirname(__FILE__) + '/test_helper.rb'
require '_test-util'

class QueryTest < Test::Unit::TestCase
  def test_query
    config = Gonzui::Config.new
    [ 
      ['foo bar',           [["foo", nil], ["bar", nil]]],
      ['fundef:foo bar',    [["foo", :fundef], ["bar", nil]]],
      ['"foo bar" baz',     [["foo bar", nil], ["baz", nil]]]
    ].each {|query_string, parts|
      query = Gonzui::SearchQuery.new(config, query_string)
      query.each {|item| 
        assert(item.is_a?(Gonzui::QueryItem))
        part = parts.shift
        if item.phrase?
          assert_equal(part.first, item.value.join(" "))
        else
          assert_equal(part.first, item.value)
        end
        assert_equal(part.last, item.property)
      }
    }
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
gonzui-1.2-x86-mswin32-60 test/test_searchquery.rb
gonzui-1.2 test/test_searchquery.rb