Example #1
0
        public void FromSpan_SuccessCase_All()
        {
            // Act
            var range = UnicodeRange.FromSpan('\u0000', '\uFFFF');

            // Assert
            Assert.Equal(0, range.FirstCodePoint);
            Assert.Equal(0x10000, range.RangeSize);
        }
Example #2
0
        public void FromSpan_SuccessCase()
        {
            // Act
            var range = UnicodeRange.FromSpan('\u0180', '\u024F'); // Latin Extended-B

            // Assert
            Assert.Equal(0x0180, range.FirstCodePoint);
            Assert.Equal(208, range.RangeSize);
        }
        [MethodImpl(MethodImplOptions.NoInlining)] // the caller should be inlined, not this method
        private static UnicodeRange CreateRange(ref UnicodeRange range, char first, char last)
        {
            // If the range hasn't been created, create it now.
            // It's ok if two threads race and one overwrites the other's 'range' value.
            Debug.Assert(last > first, "Code points were specified out of order.");
            var newRange = UnicodeRange.FromSpan(first, last);

            Volatile.Write(ref range, newRange);
            return(newRange);
        }
Example #4
0
        public void FromSpan_FailureCase()
        {
            var ex = Assert.Throws <ArgumentOutOfRangeException>(() => UnicodeRange.FromSpan('\u0020', '\u0010'));

            Assert.Equal("lastChar", ex.ParamName);
        }