mirror of
https://github.com/Biarity/Sieve.git
synced 2025-07-26 12:13:28 +02:00
Fixed null-ref for case-(in)sensitive null-search (#165)
* Fixed null-ref for case-insensitive null-search Added null-escaping sequence (to distinguish between prop==null (as null) and prop==\null (as string)) * Added null-search case-insensitive test * Code style * Added escape-sequences description to README.md Co-authored-by: Nikita Prokhorov <nikita.prokhorov@grse.de>
This commit is contained in:
@@ -38,7 +38,7 @@ namespace SieveUnitTests
|
||||
{
|
||||
Id = 2,
|
||||
DateCreated = DateTimeOffset.UtcNow,
|
||||
Text = "Regular comment without n*ll.",
|
||||
Text = "Regular comment without n*ll",
|
||||
Author = "Mouse",
|
||||
},
|
||||
new Comment
|
||||
@@ -47,24 +47,28 @@ namespace SieveUnitTests
|
||||
DateCreated = DateTimeOffset.UtcNow,
|
||||
Text = null,
|
||||
Author = "null",
|
||||
},
|
||||
}
|
||||
}.AsQueryable();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Filter_Equals_Null()
|
||||
[Theory]
|
||||
[InlineData("Text==null")]
|
||||
[InlineData("Text==*null")]
|
||||
public void Filter_Equals_Null(string filter)
|
||||
{
|
||||
var model = new SieveModel {Filters = "Text==null"};
|
||||
var model = new SieveModel {Filters = filter};
|
||||
|
||||
var result = _processor.Apply(model, _comments);
|
||||
|
||||
Assert.Equal(100, result.Single().Id);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Filter_NotEquals_Null()
|
||||
[Theory]
|
||||
[InlineData("Text!=null")]
|
||||
[InlineData("Text!=*null")]
|
||||
public void Filter_NotEquals_Null(string filter)
|
||||
{
|
||||
var model = new SieveModel {Filters = "Text!=null"};
|
||||
var model = new SieveModel {Filters = filter};
|
||||
|
||||
var result = _processor.Apply(model, _comments);
|
||||
|
||||
@@ -101,6 +105,22 @@ namespace SieveUnitTests
|
||||
Assert.Equal(expectedIds, result.Select(p => p.Id));
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(@"Author==\null", 100)]
|
||||
[InlineData(@"Author==*\null", 100)]
|
||||
[InlineData(@"Author==*\NuLl", 100)]
|
||||
[InlineData(@"Author!=*\null", 0, 1, 2)]
|
||||
[InlineData(@"Author!=*\NulL", 0, 1, 2)]
|
||||
[InlineData(@"Author!=\null", 0, 1, 2)]
|
||||
public void SingleFilter_Equals_NullStringEscaped(string filter, params int[] expectedIds)
|
||||
{
|
||||
var model = new SieveModel {Filters = filter};
|
||||
|
||||
var result = _processor.Apply(model, _comments);
|
||||
|
||||
Assert.Equal(expectedIds, result.Select(p => p.Id));
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("Text_=null")]
|
||||
[InlineData("Text_=*null")]
|
||||
|
Reference in New Issue
Block a user