Skip to content

Commit

Permalink
Add back array overloads; add unit test for TryUTF8toUTF16
Browse files Browse the repository at this point in the history
  • Loading branch information
paulirwin committed Dec 5, 2024
1 parent 7581aa7 commit 000f20f
Show file tree
Hide file tree
Showing 2 changed files with 171 additions and 31 deletions.
13 changes: 13 additions & 0 deletions src/Lucene.Net.Tests/Util/TestUnicodeUtil.cs
Original file line number Diff line number Diff line change
Expand Up @@ -327,5 +327,18 @@ public virtual void TestUTF8UTF16CharsRef()
Assert.AreEqual(cRef.ToString(), unicode);
}
}

[Test]
[LuceneNetSpecific] // this is a Lucene.NET specific method
public void TestTryUTF8toUTF16()
{
string unicode = TestUtil.RandomRealisticUnicodeString(Random);
var utf8 = new BytesRef(IOUtils.CHARSET_UTF_8.GetBytes(unicode));

bool success = UnicodeUtil.TryUTF8toUTF16(utf8, out var chars);

Assert.IsTrue(success);
Assert.AreEqual(unicode, chars?.ToString());
}
}
}
Loading

0 comments on commit 000f20f

Please sign in to comment.