Skip to content

Commit

Permalink
Fixes LUCENENET-597
Browse files Browse the repository at this point in the history
  • Loading branch information
sisve committed Jan 19, 2019
1 parent 1fdea4e commit de4032a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
16 changes: 16 additions & 0 deletions src/Lucene.Net.Tests/Search/Spans/TestSpans.cs
Original file line number Diff line number Diff line change
Expand Up @@ -554,6 +554,22 @@ public virtual void TestSpanNots()
Assert.AreEqual(0, SpanCount("s3", "s1", 8, 8), "SpanNotS3NotS1_8_8");
}

[Test]
[Description("LUCENENET-597")]
public void TestToString_LUCENENET_597()
{
var clauses = new[]
{
new SpanTermQuery(new Term("f", "lucene")),
new SpanTermQuery(new Term("f", "net")),
new SpanTermQuery(new Term("f", "solr"))
};
var query = new SpanNearQuery(clauses, 0, true);
var queryString = query.ToString();

Assert.AreEqual("SpanNear([f:lucene, f:net, f:solr], 0, True)", queryString);
}

private int SpanCount(string include, string exclude, int pre, int post)
{
SpanTermQuery iq = new SpanTermQuery(new Term(field, include));
Expand Down
2 changes: 1 addition & 1 deletion src/Lucene.Net/Search/Spans/SpanNearQuery.cs
Original file line number Diff line number Diff line change
Expand Up @@ -134,11 +134,11 @@ public override string ToString(string field)
while (i.MoveNext())
{
SpanQuery clause = i.Current;
buffer.Append(clause.ToString(field));
if (!isFirst)
{
buffer.Append(", ");
}
buffer.Append(clause.ToString(field));
isFirst = false;
}
buffer.Append("], ");
Expand Down

0 comments on commit de4032a

Please sign in to comment.