@@ -701,19 +701,22 @@ private let fuzzUnicodeSpecial = [
701701
702702/// Generate emoji-heavy text content
703703private func fuzzEmojiText( ) -> String {
704- let count = Int . random ( in: 1 ... 10 )
704+ let count = Int . random ( in: 1 ... 10 )
705705 var result = " "
706- for _ in 0 ..< count {
707- let choice = Int . random ( in: 0 ..< 4 )
706+ for _ in 0 ..< count {
707+ let choice = Int . random ( in: 0 ..< 4 )
708708 switch choice {
709- case 0 :
710- result += fuzzEmoji. randomElement ( ) !
711- case 1 :
712- result += fuzzUnicodeScripts. randomElement ( ) !
713- case 2 :
714- result += fuzzUnicodeSpecial. randomElement ( ) !
715- default :
716- result += fuzzRandomString ( minLen: 1 , maxLen: 5 )
709+ case 0 :
710+ result += fuzzEmoji. randomElement ( ) !
711+
712+ case 1 :
713+ result += fuzzUnicodeScripts. randomElement ( ) !
714+
715+ case 2 :
716+ result += fuzzUnicodeSpecial. randomElement ( ) !
717+
718+ default :
719+ result += fuzzRandomString ( minLen: 1 , maxLen: 5 )
717720 }
718721 }
719722 return result
@@ -838,24 +841,28 @@ private func fuzzEmojiAtBoundaries() -> String {
838841/// Generate completely random Unicode strings
839842private func fuzzRandomUnicode( length: Int ) -> String {
840843 var result = " "
841- for _ in 0 ..< length {
842- let choice = Int . random ( in: 0 ..< 5 )
844+ for _ in 0 ..< length {
845+ let choice = Int . random ( in: 0 ..< 5 )
843846 switch choice {
844- case 0 :
845- result += fuzzEmoji. randomElement ( ) !
846- case 1 :
847- result += fuzzUnicodeScripts. randomElement ( ) !
848- case 2 :
849- result += fuzzUnicodeSpecial. randomElement ( ) !
850- case 3 :
851- // Random valid Unicode scalar
852- if let scalar = UnicodeScalar ( UInt32 . random ( in: 0x20 ... 0x10FFFF ) ) {
853- if scalar. isASCII || !scalar. properties. isNoncharacterCodePoint {
854- result. append ( Character ( scalar) )
847+ case 0 :
848+ result += fuzzEmoji. randomElement ( ) !
849+
850+ case 1 :
851+ result += fuzzUnicodeScripts. randomElement ( ) !
852+
853+ case 2 :
854+ result += fuzzUnicodeSpecial. randomElement ( ) !
855+
856+ case 3 :
857+ // Random valid Unicode scalar
858+ if let scalar = UnicodeScalar ( UInt32 . random ( in: 0x20 ... 0x10FFFF ) ) {
859+ if scalar. isASCII || !scalar. properties. isNoncharacterCodePoint {
860+ result. append ( Character ( scalar) )
861+ }
855862 }
856- }
857- default :
858- result += String ( ( 0 ..< Int . random ( in: 1 ... 3 ) ) . map { _ in " abcdef " . randomElement ( ) ! } )
863+
864+ default :
865+ result += String ( ( 0 ..< Int . random ( in: 1 ... 3 ) ) . map { _ in " abcdef " . randomElement ( ) ! } )
859866 }
860867 }
861868 return result
@@ -875,21 +882,21 @@ private func fuzzRandomUnicode(length: Int) -> String {
875882
876883 // Test emoji in tag names
877884 print ( " Testing emoji in tag names... " )
878- for _ in 0 ..< testsPerCategory {
885+ for _ in 0 ..< testsPerCategory {
879886 let html = fuzzEmojiInTagName ( )
880887 let doc = try JustHTML ( html)
881888 let output = doc. toHTML ( )
882889 // Verify emoji survives round-trip
883890 for emoji in fuzzEmoji where html. contains ( emoji) {
884891 #expect( output. contains ( emoji) || doc. toText ( ) . contains ( emoji) ,
885- " Emoji should survive parsing: \( emoji) " )
892+ " Emoji should survive parsing: \( emoji) " )
886893 }
887894 completed += 1
888895 }
889896
890897 // Test emoji in attributes
891898 print ( " Testing emoji in attributes... " )
892- for _ in 0 ..< testsPerCategory {
899+ for _ in 0 ..< testsPerCategory {
893900 let html = fuzzEmojiInAttributes ( )
894901 let doc = try JustHTML ( html)
895902 _ = doc. toHTML ( )
@@ -898,7 +905,7 @@ private func fuzzRandomUnicode(length: Int) -> String {
898905
899906 // Test emoji mid-tag
900907 print ( " Testing emoji mid-tag... " )
901- for _ in 0 ..< testsPerCategory {
908+ for _ in 0 ..< testsPerCategory {
902909 let html = fuzzEmojiMidTag ( )
903910 let doc = try JustHTML ( html)
904911 _ = doc. toHTML ( )
@@ -907,7 +914,7 @@ private func fuzzRandomUnicode(length: Int) -> String {
907914
908915 // Test emoji in comments
909916 print ( " Testing emoji in comments... " )
910- for _ in 0 ..< testsPerCategory {
917+ for _ in 0 ..< testsPerCategory {
911918 let html = fuzzEmojiInComments ( )
912919 let doc = try JustHTML ( html)
913920 _ = doc. toHTML ( )
@@ -916,7 +923,7 @@ private func fuzzRandomUnicode(length: Int) -> String {
916923
917924 // Test emoji with entities
918925 print ( " Testing emoji with entities... " )
919- for _ in 0 ..< testsPerCategory {
926+ for _ in 0 ..< testsPerCategory {
920927 let html = fuzzEmojiWithEntities ( )
921928 let doc = try JustHTML ( html)
922929 _ = doc. toHTML ( )
@@ -925,7 +932,7 @@ private func fuzzRandomUnicode(length: Int) -> String {
925932
926933 // Test emoji in raw text elements
927934 print ( " Testing emoji in script/style/title... " )
928- for _ in 0 ..< testsPerCategory {
935+ for _ in 0 ..< testsPerCategory {
929936 let html = fuzzEmojiInRawText ( )
930937 let doc = try JustHTML ( html)
931938 _ = doc. toHTML ( )
@@ -934,7 +941,7 @@ private func fuzzRandomUnicode(length: Int) -> String {
934941
935942 // Test emoji at byte boundaries
936943 print ( " Testing emoji at byte boundaries... " )
937- for _ in 0 ..< testsPerCategory {
944+ for _ in 0 ..< testsPerCategory {
938945 let html = fuzzEmojiAtBoundaries ( )
939946 let doc = try JustHTML ( html)
940947 _ = doc. toHTML ( )
@@ -943,8 +950,8 @@ private func fuzzRandomUnicode(length: Int) -> String {
943950
944951 // Test random Unicode soup
945952 print ( " Testing random Unicode strings... " )
946- for _ in 0 ..< testsPerCategory {
947- let unicode = fuzzRandomUnicode ( length: Int . random ( in: 10 ... 100 ) )
953+ for _ in 0 ..< testsPerCategory {
954+ let unicode = fuzzRandomUnicode ( length: Int . random ( in: 10 ... 100 ) )
948955 let html = " <div> \( unicode) </div> "
949956 let doc = try JustHTML ( html)
950957 _ = doc. toHTML ( )
@@ -953,7 +960,7 @@ private func fuzzRandomUnicode(length: Int) -> String {
953960
954961 // Test combined chaos
955962 print ( " Testing combined Unicode chaos... " )
956- for _ in 0 ..< testsPerCategory {
963+ for _ in 0 ..< testsPerCategory {
957964 var parts : [ String ] = [ ]
958965 parts. append ( fuzzEmojiInTagName ( ) )
959966 parts. append ( fuzzEmojiInAttributes ( ) )
0 commit comments