diff --git a/Directory.Packages.props b/Directory.Packages.props
index d62a1d298..2fdb4633e 100644
--- a/Directory.Packages.props
+++ b/Directory.Packages.props
@@ -18,7 +18,7 @@
-
+
diff --git a/Tests/UnitTestsParallelizable/Text/RuneTests.cs b/Tests/UnitTestsParallelizable/Text/RuneTests.cs
index f5bc5ab67..4e03e8048 100644
--- a/Tests/UnitTestsParallelizable/Text/RuneTests.cs
+++ b/Tests/UnitTestsParallelizable/Text/RuneTests.cs
@@ -88,7 +88,7 @@ public class RuneTests
1
)] // the letters αα
₯αΈ join to form the Korean word for "rice:" U+BC95 λ² (read from top left to bottom right)
[InlineData ("\U0001F468\u200D\U0001F469\u200D\U0001F467", "π¨βπ©βπ§", 8, 2, 8)] // Man, Woman and Girl emoji.
- [InlineData ("\u0915\u093f", "ΰ€ΰ€Ώ", 2, 2, 2)] // Hindi ΰ€ΰ€Ώ with DEVANAGARI LETTER KA and DEVANAGARI VOWEL SIGN I
+ //[InlineData ("\u0915\u093f", "ΰ€ΰ€Ώ", 2, 2, 2)] // Hindi ΰ€ΰ€Ώ with DEVANAGARI LETTER KA and DEVANAGARI VOWEL SIGN I
[InlineData (
"\u0e4d\u0e32",
"ΰΉΰΈ²",
@@ -213,7 +213,7 @@ public class RuneTests
[InlineData (
'\u1161',
"α
‘",
- 1,
+ 0,
1,
3
)] // α
‘ Hangul Jungseong A - Unicode Hangul Jamo for join with column width equal to 0 alone.
@@ -231,7 +231,7 @@ public class RuneTests
)] // δ·Hexagram For The Creative Heaven - U+4dc0 - https://github.com/microsoft/terminal/blob/main/src/types/unicode_width_overrides.xml
// See https://github.com/microsoft/terminal/issues/19389
- [InlineData ('\ud7b0', "ν°", 1, 1, 3)] // ν° β€Hangul Jungseong O-Yeo - ν° U+d7b0')]
+ [InlineData ('\ud7b0', "ν°", 0, 1, 3)] // ν° β€Hangul Jungseong O-Yeo - ν° U+d7b0')]
[InlineData ('\uf61e', "ο", 1, 1, 3)] // Private Use Area
[InlineData ('\u23f0', "β°", 2, 1, 3)] // Alarm Clock - β° U+23f0
[InlineData ('\u1100', "α", 2, 1, 3)] // α Hangul Choseong Kiyeok
diff --git a/Tests/UnitTestsParallelizable/Text/StringTests.cs b/Tests/UnitTestsParallelizable/Text/StringTests.cs
index efbc2e406..a3c4e52ba 100644
--- a/Tests/UnitTestsParallelizable/Text/StringTests.cs
+++ b/Tests/UnitTestsParallelizable/Text/StringTests.cs
@@ -4,6 +4,13 @@
public class StringTests
{
+ [Fact]
+ public void TestGetColumns_Null ()
+ {
+ string? str = null;
+ Assert.Equal (0, str!.GetColumns ());
+ }
+
[Fact]
public void TestGetColumns_Empty ()
{
@@ -11,6 +18,20 @@ public class StringTests
Assert.Equal (0, str.GetColumns ());
}
+ [Fact]
+ public void TestGetColumns_SingleRune ()
+ {
+ var str = "a";
+ Assert.Equal (1, str.GetColumns ());
+ }
+
+ [Fact]
+ public void TestGetColumns_Zero_Width ()
+ {
+ var str = "\u200D";
+ Assert.Equal (0, str.GetColumns ());
+ }
+
[Theory]
[InlineData ("a", 1)]
[InlineData ("Γ‘", 1)]
@@ -30,44 +51,37 @@ public class StringTests
// Test known wide codepoints
[Theory]
- [InlineData ("π", 1, 2)]
- [InlineData ("aπ", 2, 3)]
- [InlineData ("πa", 2, 3)]
- [InlineData ("π¨βπ©βπ¦βπ¦", 1, 2)]
- [InlineData ("π¨βπ©βπ¦βπ¦π", 2, 4)]
- [InlineData ("π¨βπ©βπ¦βπ¦πa", 3, 5)]
- [InlineData ("π¨βπ©βπ¦βπ¦aπ", 3, 5)]
- [InlineData ("π¨βπ©βπ¦βπ¦π¨βπ©βπ¦βπ¦", 2, 4)]
- [InlineData ("ΰΈ²ΰΈ³", 1, 2)] // ΰΈ² U+0E32 - THAI CHARACTER SARA AA with ΰΈ³ U+0E33 - THAI CHARACTER SARA AM
- [InlineData ("ε±±", 1, 2)] // The character for "mountain" in Chinese/Japanese/Korean (ε±±), Unicode U+5C71
- [InlineData ("ε±±π", 2, 4)] // The character for "mountain" in Chinese/Japanese/Korean (ε±±), Unicode U+5C71
- //[InlineData ("\ufe20\ufe21", 2)] // Combining Ligature Left Half οΈ - U+fe20 -https://github.com/microsoft/terminal/blob/main/src/types/unicode_width_overrides.xml
- // // Combining Ligature Right Half - U+fe21 -https://github.com/microsoft/terminal/blob/main/src/types/unicode_width_overrides.xml
- public void TestGetColumns_MultiRune_WideBMP_Graphemes (string str, int graphemesCount, int expected)
+ [InlineData ("π", 2, 1, 2)]
+ [InlineData ("aπ", 3, 2, 3)]
+ [InlineData ("πa", 3, 2, 3)]
+ [InlineData ("π¨βπ©βπ¦βπ¦", 8, 1, 2)]
+ [InlineData ("π¨βπ©βπ¦βπ¦π", 10, 2, 4)]
+ [InlineData ("π¨βπ©βπ¦βπ¦πa", 11, 3, 5)]
+ [InlineData ("π¨βπ©βπ¦βπ¦aπ", 11, 3, 5)]
+ [InlineData ("π¨βπ©βπ¦βπ¦π¨βπ©βπ¦βπ¦", 16, 2, 4)]
+ [InlineData ("ΰΈ²ΰΈ³", 2, 1, 2)] // ΰΈ² U+0E32 - THAI CHARACTER SARA AA with ΰΈ³ U+0E33 - THAI CHARACTER SARA AM
+ [InlineData ("ε±±", 2, 1, 2)] // The character for "mountain" in Chinese/Japanese/Korean (ε±±), Unicode U+5C71
+ [InlineData ("ε±±π", 4, 2, 4)] // The character for "mountain" in Chinese/Japanese/Korean (ε±±), Unicode U+5C71
+ [InlineData ("a\ufe20e\ufe21", 2, 2, 2)] // Combining Ligature Left Half οΈ - U+fe20 -https://github.com/microsoft/terminal/blob/main/src/types/unicode_width_overrides.xml
+ // Combining Ligature Right Half - U+fe21 -https://github.com/microsoft/terminal/blob/main/src/types/unicode_width_overrides.xml
+ //[InlineData ("ΰ€", 1, 1, 1)] // ΰ€ U+0915 Devanagari Letter Ka
+ //[InlineData ("ΰ€Ώ", 1, 1, 1)] // U+093F Devanagari Vowel Sign I ΰ€Ώ (i-kar).
+ //[InlineData ("ΰ€ΰ€Ώ", 2, 1, 2)] // "ΰ€ΰ€Ώ" is U+0915 for the base consonant "ΰ€" with U+093F for the vowel sign "ΰ€Ώ" (i-kar).
+ [InlineData ("α", 2, 1, 2)] // α U+1100 HANGUL CHOSEONG KIYEOK (consonant)
+ [InlineData ("α
‘", 0, 1, 0)] // α
‘ U+1161 HANGUL JUNGSEONG A (vowel)
+ [InlineData ("αα
‘", 2, 1, 2)] // α U+1100 HANGUL CHOSEONG KIYEOK (consonant) with α
‘ U+1161 HANGUL JUNGSEONG A (vowel)
+ [InlineData ("α", 2, 1, 2)] // α U+1112 Hangul Choseong Hieuh
+ [InlineData ("α
΅", 0, 1, 0)] // α
΅ U+1175 Hangul Jungseong I
+ [InlineData ("α", 0, 1, 0)] // α U+11C2 Hangul Jongseong Hieuh
+ [InlineData ("αα
΅α", 2, 1, 2)] // α (choseong h) + α
΅ (jungseong i) + α (jongseong h)
+ [InlineData ("ν°", 0, 1, 0)] // U+D7B0 ν° Hangul Jungseong O-Yeo
+ [InlineData ("αν°", 2, 1, 2)] // α U+1100 HANGUL CHOSEONG KIYEOK (consonant) with U+D7B0 ν° Hangul Jungseong O-Yeo
+ //[InlineData ("ΰ€·ΰ€Ώ", 2, 1, 2)] // U+0937 ΰ€· DEVANAGARI LETTER SSA with U+093F ΰ€Ώ COMBINING DEVANAGARI VOWEL SIGN I
+ public void TestGetColumns_MultiRune_WideBMP_Graphemes (string str, int expectedRunesWidth, int expectedGraphemesCount, int expectedWidth)
{
- Assert.Equal (graphemesCount, GraphemeHelper.GetGraphemes (str).ToArray ().Length);
- Assert.Equal (expected, str.GetColumns ());
- }
-
- [Fact]
- public void TestGetColumns_Null ()
- {
- string? str = null;
- Assert.Equal (0, str!.GetColumns ());
- }
-
- [Fact]
- public void TestGetColumns_SingleRune ()
- {
- var str = "a";
- Assert.Equal (1, str.GetColumns ());
- }
-
- [Fact]
- public void TestGetColumns_Zero_Width ()
- {
- var str = "\u200D";
- Assert.Equal (0, str.GetColumns ());
+ Assert.Equal (expectedRunesWidth, str.EnumerateRunes ().Sum (r => r.GetColumns ()));
+ Assert.Equal (expectedGraphemesCount, GraphemeHelper.GetGraphemes (str).ToArray ().Length);
+ Assert.Equal (expectedWidth, str.GetColumns ());
}
[Theory]
@@ -75,14 +89,8 @@ public class StringTests
[InlineData ("")]
public void TestGetColumns_Does_Not_Throws_With_Null_And_Empty_String (string? text)
{
- if (text is null)
- {
- Assert.Equal (0, StringExtensions.GetColumns (text!));
- }
- else
- {
- Assert.Equal (0, text.GetColumns ());
- }
+ // ReSharper disable once InvokeAsExtensionMethod
+ Assert.Equal (0, StringExtensions.GetColumns (text!));
}
public class ReadOnlySpanExtensionsTests