Skip to content

Commit

Permalink
Allow for zero corpora
Browse files Browse the repository at this point in the history
  • Loading branch information
johnml1135 committed Nov 26, 2024
1 parent d284a33 commit 4cad944
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 0 additions & 2 deletions src/SIL.Machine/Corpora/NParallelTextCorpus.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ public class NParallelTextCorpus : NParallelTextCorpusBase
public NParallelTextCorpus(IEnumerable<ITextCorpus> corpora, IComparer<object> rowRefComparer = null)
{
Corpora = corpora.ToImmutableArray();
if (Corpora.Count < 1)
throw new ArgumentException("There must be at least one corpora.", nameof(corpora));
RowRefComparer = rowRefComparer ?? new DefaultRowRefComparer();
AllRows = new bool[Corpora.Count]
.Select(_ => false)
Expand Down
8 changes: 8 additions & 0 deletions tests/SIL.Machine.Tests/Corpora/NParallelTextCorpusTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@ namespace SIL.Machine.Corpora;
[TestFixture]
public class NParallelTextCorpusTests
{
[Test]
public void GetRows_ZeroCorpora()
{
var nParallelCorpus = new NParallelTextCorpus([]);
NParallelTextRow[] rows = nParallelCorpus.ToArray();
Assert.That(rows.Length, Is.EqualTo(0));
}

[Test]
public void GetRows_ThreeCorpora()
{
Expand Down

0 comments on commit 4cad944

Please sign in to comment.