public void MutableString_Surrogates1() {
MutableString x;
// encoding doesn't produce surrogate characters //
foreach (var e in new[] { RubyEncoding.Binary, RubyEncoding.Ascii }) {
x = MutableString.Create("", e);
Assert(x.KnowsSurrogates);
Assert(!x.HasSurrogates());
Assert(x.KnowsSurrogates);
x = MutableString.CreateMutable("", e);
Assert(x.KnowsSurrogates);
Assert(!x.HasSurrogates());
Assert(x.KnowsSurrogates);
}
// encoding might produce surrogate characters //
foreach (var e in new[] { RubyEncoding.UTF8, RubyEncodingOps.UTF_16BE, RubyEncodingOps.UTF_32LE }) {
foreach (var str in new[] { "", "x", "xy", "hello world", "\uD7FF", "\uE000" }) {
x = MutableString.Create(str, e);
Assert(!x.KnowsSurrogates);
Assert(!x.HasSurrogates());
Assert(x.KnowsSurrogates);
x = MutableString.CreateMutable(str, e);
Assert(!x.KnowsSurrogates);
Assert(!x.HasSurrogates());
Assert(x.KnowsSurrogates);
}
foreach (var str in new[] { "\uD800", "\uD800a", "a\uD800", "\uDFFF" }) {
x = MutableString.Create(str, e);
Assert(!x.KnowsSurrogates);
Assert(x.HasSurrogates());
Assert(x.KnowsSurrogates);
x = MutableString.CreateMutable(str, e);
Assert(!x.KnowsSurrogates);
Assert(x.HasSurrogates());
Assert(x.KnowsSurrogates);
}
}
}