Sha256: 5c90c497819dc4ee802999b1adbc79f011c6f188e5524c6f0e3a098412ca3930
Contents?: true
Size: 1.34 KB
Versions: 2
Compression:
Stored size: 1.34 KB
Contents
# encoding: utf-8 require "test_helper" require "sup/util/query" require "xapian" describe Redwood::Util::Query do describe ".describe" do it "returns a UTF-8 description of query" do query = Xapian::Query.new "テスト" life = "生活: " assert_raises Encoding::CompatibilityError do _ = life + query.description end desc = Redwood::Util::Query.describe(query) _ = (life + desc) # No exception thrown end it "returns a valid UTF-8 description of bad input" do msg = "asdfa \xc3\x28 åasdf" query = Xapian::Query.new msg life = 'hæi' if query.description.force_encoding("UTF-8").valid_encoding? # xapian 1.4 internally handles this bad input assert true else # xapian 1.2 doesn't handle this bad input, so we do assert_raises Redwood::Util::Query::QueryDescriptionError do _desc = Redwood::Util::Query.describe (query) end end assert_raises Encoding::CompatibilityError do _ = life + query.description end end it "returns a valid UTF-8 fallback description of bad input" do msg = "asdfa \xc3\x28 åasdf" query = Xapian::Query.new msg desc = Redwood::Util::Query.describe(query, "invalid query") assert desc.force_encoding("UTF-8").valid_encoding? end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
sup-1.2 | test/unit/util/test_query.rb |
sup-1.1 | test/unit/util/test_query.rb |