@@ -42,42 +42,42 @@ describe('String format validation utilities', () => {
4242 } ) ;
4343
4444 test ( 'returns false for unpaired high surrogates' , ( ) => {
45- const highSurrogate = String . fromCharCode ( 0xD800 ) ;
45+ const highSurrogate = String . fromCharCode ( 0xd800 ) ;
4646 expect ( isUtf8 ( highSurrogate ) ) . toBe ( false ) ;
4747 expect ( isUtf8 ( 'hello' + highSurrogate ) ) . toBe ( false ) ;
4848 expect ( isUtf8 ( highSurrogate + 'world' ) ) . toBe ( false ) ;
4949 } ) ;
5050
5151 test ( 'returns false for orphaned low surrogates' , ( ) => {
52- const lowSurrogate = String . fromCharCode ( 0xDC00 ) ;
52+ const lowSurrogate = String . fromCharCode ( 0xdc00 ) ;
5353 expect ( isUtf8 ( lowSurrogate ) ) . toBe ( false ) ;
5454 expect ( isUtf8 ( 'hello' + lowSurrogate ) ) . toBe ( false ) ;
5555 expect ( isUtf8 ( lowSurrogate + 'world' ) ) . toBe ( false ) ;
5656 } ) ;
5757
5858 test ( 'returns false for high surrogate not followed by low surrogate' , ( ) => {
59- const highSurrogate = String . fromCharCode ( 0xD800 ) ;
60- const notLowSurrogate = String . fromCharCode ( 0xE000 ) ; // Outside surrogate range
59+ const highSurrogate = String . fromCharCode ( 0xd800 ) ;
60+ const notLowSurrogate = String . fromCharCode ( 0xe000 ) ; // Outside surrogate range
6161 expect ( isUtf8 ( highSurrogate + notLowSurrogate ) ) . toBe ( false ) ;
6262 expect ( isUtf8 ( highSurrogate + 'a' ) ) . toBe ( false ) ;
6363 } ) ;
6464
6565 test ( 'returns true for valid surrogate pairs' , ( ) => {
6666 // Create a valid surrogate pair manually
67- const highSurrogate = String . fromCharCode ( 0xD800 ) ;
68- const lowSurrogate = String . fromCharCode ( 0xDC00 ) ;
67+ const highSurrogate = String . fromCharCode ( 0xd800 ) ;
68+ const lowSurrogate = String . fromCharCode ( 0xdc00 ) ;
6969 expect ( isUtf8 ( highSurrogate + lowSurrogate ) ) . toBe ( true ) ;
70-
70+
7171 // Test with real emoji
7272 expect ( isUtf8 ( '👨💻' ) ) . toBe ( true ) ; // Complex emoji with ZWJ
7373 expect ( isUtf8 ( '🏳️🌈' ) ) . toBe ( true ) ; // Rainbow flag emoji
7474 } ) ;
7575
7676 test ( 'handles sequences correctly' , ( ) => {
77- const highSurrogate = String . fromCharCode ( 0xD800 ) ;
78- const lowSurrogate = String . fromCharCode ( 0xDC00 ) ;
77+ const highSurrogate = String . fromCharCode ( 0xd800 ) ;
78+ const lowSurrogate = String . fromCharCode ( 0xdc00 ) ;
7979 const validPair = highSurrogate + lowSurrogate ;
80-
80+
8181 expect ( isUtf8 ( validPair + validPair ) ) . toBe ( true ) ; // Two valid pairs
8282 expect ( isUtf8 ( validPair + highSurrogate ) ) . toBe ( false ) ; // Valid pair + unpaired high
8383 expect ( isUtf8 ( 'hello' + validPair + 'world' ) ) . toBe ( true ) ; // Valid pair in middle
@@ -93,11 +93,11 @@ describe('String format validation utilities', () => {
9393 test ( 'delegates to isUtf8 for utf8 format' , ( ) => {
9494 expect ( validateStringFormat ( 'hello' , 'utf8' ) ) . toBe ( true ) ;
9595 expect ( validateStringFormat ( 'héllo' , 'utf8' ) ) . toBe ( true ) ;
96- expect ( validateStringFormat ( String . fromCharCode ( 0xD800 ) , 'utf8' ) ) . toBe ( false ) ;
96+ expect ( validateStringFormat ( String . fromCharCode ( 0xd800 ) , 'utf8' ) ) . toBe ( false ) ;
9797 } ) ;
9898
9999 test ( 'returns true for invalid format (defensive)' , ( ) => {
100100 expect ( validateStringFormat ( 'hello' , 'invalid' as any ) ) . toBe ( true ) ;
101101 } ) ;
102102 } ) ;
103- } ) ;
103+ } ) ;
0 commit comments