mirror of
https://github.com/Readarr/Readarr
synced 2026-02-02 12:53:25 +01:00
Fixed: Identification failing if book metadata has no authors
This commit is contained in:
parent
146fe04cce
commit
11577b6db9
2 changed files with 48 additions and 2 deletions
|
|
@ -131,6 +131,38 @@ public void test_add_string_both_none()
|
|||
dist.Penalties.Should().BeEquivalentTo(new Dictionary<string, List<double>> { { "string", new List<double> { 0.0 } } });
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void test_add_string_empty_values_valid_target()
|
||||
{
|
||||
var dist = new Distance();
|
||||
dist.AddString("string", new List<string>(), "target");
|
||||
dist.Penalties.Should().BeEquivalentTo(new Dictionary<string, List<double>> { { "string", new List<double> { 1.0 } } });
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void test_add_string_empty_values_empty_target()
|
||||
{
|
||||
var dist = new Distance();
|
||||
dist.AddString("string", new List<string>(), string.Empty);
|
||||
dist.Penalties.Should().BeEquivalentTo(new Dictionary<string, List<double>> { { "string", new List<double> { 0.0 } } });
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void test_add_string_empty_options_valid_value()
|
||||
{
|
||||
var dist = new Distance();
|
||||
dist.AddString("string", "value", new List<string>());
|
||||
dist.Penalties.Should().BeEquivalentTo(new Dictionary<string, List<double>> { { "string", new List<double> { 1.0 } } });
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void test_add_string_empty_options_empty_value()
|
||||
{
|
||||
var dist = new Distance();
|
||||
dist.AddString("string", string.Empty, new List<string>());
|
||||
dist.Penalties.Should().BeEquivalentTo(new Dictionary<string, List<double>> { { "string", new List<double> { 0.0 } } });
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void test_distance()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -151,12 +151,26 @@ public void AddString(string key, string value, string target)
|
|||
|
||||
public void AddString(string key, string value, List<string> options)
|
||||
{
|
||||
Add(key, options.Min(x => StringScore(value, x)));
|
||||
if (!options.Any())
|
||||
{
|
||||
Add(key, StringScore(value, string.Empty));
|
||||
}
|
||||
else
|
||||
{
|
||||
Add(key, options.Min(x => StringScore(value, x)));
|
||||
}
|
||||
}
|
||||
|
||||
public void AddString(string key, List<string> values, string target)
|
||||
{
|
||||
Add(key, values.Min(v => StringScore(v, target)));
|
||||
if (!values.Any())
|
||||
{
|
||||
Add(key, StringScore(string.Empty, target));
|
||||
}
|
||||
else
|
||||
{
|
||||
Add(key, values.Min(v => StringScore(v, target)));
|
||||
}
|
||||
}
|
||||
|
||||
public void AddBool(string key, bool expr)
|
||||
|
|
|
|||
Loading…
Reference in a new issue