Skip to content

Commit e24d99c

Browse files
committed
Add back array overloads; add unit test for TryUTF8toUTF16
1 parent 1845c38 commit e24d99c

File tree

2 files changed

+171
-31
lines changed

2 files changed

+171
-31
lines changed

src/Lucene.Net.Tests/Util/TestUnicodeUtil.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -327,5 +327,18 @@ public virtual void TestUTF8UTF16CharsRef()
327327
Assert.AreEqual(cRef.ToString(), unicode);
328328
}
329329
}
330+
331+
[Test]
332+
[LuceneNetSpecific] // this is a Lucene.NET specific method
333+
public void TestTryUTF8toUTF16()
334+
{
335+
string unicode = TestUtil.RandomRealisticUnicodeString(Random);
336+
var utf8 = new BytesRef(IOUtils.CHARSET_UTF_8.GetBytes(unicode));
337+
338+
bool success = UnicodeUtil.TryUTF8toUTF16(utf8, out var chars);
339+
340+
Assert.IsTrue(success);
341+
Assert.AreEqual(unicode, chars?.ToString());
342+
}
330343
}
331344
}

0 commit comments

Comments
 (0)