From: Matt Kuruc Date: Tue, 12 Dec 2023 18:11:34 +0000 (-0800) Subject: Validate code point ordering for non-ASCII range X-Git-Tag: accepted/tizen/unified/x/20250428.070456~5^2~101^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=bf763ced51e3670d212c7fec413829cccf26df97;p=platform%2Fcore%2Fuifw%2FOpenUSD.git Validate code point ordering for non-ASCII range --- diff --git a/pxr/base/tf/testenv/unicodeUtils.cpp b/pxr/base/tf/testenv/unicodeUtils.cpp index 1c8f77d71..3fc37516d 100644 --- a/pxr/base/tf/testenv/unicodeUtils.cpp +++ b/pxr/base/tf/testenv/unicodeUtils.cpp @@ -217,6 +217,41 @@ TestUtf8CodePointSurrogateRange() return true; } +/// Ensure that code points outside of the ASCII range are ordered by +/// code point value. +static bool +TestUtf8DictionaryLessThanOrdering() +{ + // All ASCII code points should be less than the first non-ASCII + // code point. + for (uint32_t value = 0; value <= 127; value++) { + const TfUtf8CodePoint asciiCodePoint(value); + TF_AXIOM(TfDictionaryLessThan{}( + TfStringify(asciiCodePoint), + TfStringify(TfUtf8CodePoint{128}))); + } + // All non-ASCII code points should be numerically ordered. + for (uint32_t value = 129; + value <= TfUtf8CodePoint::MaximumValue; value++) { + if ((value < TfUtf8CodePoint::SurrogateRange.first) || + (value > TfUtf8CodePoint::SurrogateRange.second + 1)) { + const TfUtf8CodePoint codePoint(value); + const TfUtf8CodePoint previousCodePoint(value-1); + TF_AXIOM(TfDictionaryLessThan{}( + TfStringify(previousCodePoint), + TfStringify(codePoint)) + ); + } + } + // Test that the first value after the surrogate range is greater than + // the last value before the surrogate range. + TF_AXIOM(TfDictionaryLessThan{}( + TfStringify(TfUtf8CodePoint::SurrogateRange.first - 1), + TfStringify(TfUtf8CodePoint::SurrogateRange.second + 1)) + ); + return true; +} + static bool TestCharacterClasses() { @@ -385,7 +420,8 @@ Test_TfUnicodeUtils() TestUtf8CodePointView() && TestCharacterClasses() && TestUtf8CodePointReflection() && - TestUtf8CodePointSurrogateRange(); + TestUtf8CodePointSurrogateRange() && + TestUtf8DictionaryLessThanOrdering(); } TF_ADD_REGTEST(TfUnicodeUtils);