@@ -320,27 +320,25 @@ mod simd {
320320 }
321321
322322 #[ test]
323- fn string_search_4 ( ) {
324- const NEEDLE : [ u8 ; 4 ] = [ b'a' , b'b' , b'c' , b'd' ] ;
325-
326- assert_eq ! ( crate :: simd:: find4( b"e" , NEEDLE ) , None ) ;
327- assert_eq ! ( crate :: simd:: find4( b"a" , NEEDLE ) , Some ( 0 ) ) ;
328- assert_eq ! ( crate :: simd:: find4( b"ea" , NEEDLE ) , Some ( 1 ) ) ;
329- assert_eq ! ( crate :: simd:: find4( b"ef" , NEEDLE ) , None ) ;
330- assert_eq ! ( crate :: simd:: find4( b"ef a" , NEEDLE ) , Some ( 3 ) ) ;
331- assert_eq ! ( crate :: simd:: find4( b"ef g" , NEEDLE ) , None ) ;
332- assert_eq ! ( crate :: simd:: find4( b"ef ghijk" , NEEDLE ) , None ) ;
333- assert_eq ! ( crate :: simd:: find4( b"ef ghijkl" , NEEDLE ) , None ) ;
334- assert_eq ! ( crate :: simd:: find4( b"ef ghijkla" , NEEDLE ) , Some ( 9 ) ) ;
335- assert_eq ! ( crate :: simd:: find4( b"ef ghiajklm" , NEEDLE ) , Some ( 6 ) ) ;
336- assert_eq ! ( crate :: simd:: find4( b"ef ghibjklm" , NEEDLE ) , Some ( 6 ) ) ;
337- assert_eq ! ( crate :: simd:: find4( b"ef ghicjklm" , NEEDLE ) , Some ( 6 ) ) ;
338- assert_eq ! ( crate :: simd:: find4( b"ef ghidjklm" , NEEDLE ) , Some ( 6 ) ) ;
339- assert_eq ! ( crate :: simd:: find4( b"ef ghijklmnopqrstua" , NEEDLE ) , Some ( 18 ) ) ;
340- assert_eq ! ( crate :: simd:: find4( b"ef ghijklmnopqrstub" , NEEDLE ) , Some ( 18 ) ) ;
341- assert_eq ! ( crate :: simd:: find4( b"ef ghijklmnopqrstuc" , NEEDLE ) , Some ( 18 ) ) ;
342- assert_eq ! ( crate :: simd:: find4( b"ef ghijklmnopqrstud" , NEEDLE ) , Some ( 18 ) ) ;
343- assert_eq ! ( crate :: simd:: find4( b"ef ghijklmnopqrstu" , NEEDLE ) , None ) ;
323+ fn string_search_3 ( ) {
324+ const NEEDLE : [ u8 ; 3 ] = [ b'a' , b'b' , b'c' ] ;
325+
326+ assert_eq ! ( crate :: simd:: find3( b"e" , NEEDLE ) , None ) ;
327+ assert_eq ! ( crate :: simd:: find3( b"a" , NEEDLE ) , Some ( 0 ) ) ;
328+ assert_eq ! ( crate :: simd:: find3( b"ea" , NEEDLE ) , Some ( 1 ) ) ;
329+ assert_eq ! ( crate :: simd:: find3( b"ef" , NEEDLE ) , None ) ;
330+ assert_eq ! ( crate :: simd:: find3( b"ef a" , NEEDLE ) , Some ( 3 ) ) ;
331+ assert_eq ! ( crate :: simd:: find3( b"ef g" , NEEDLE ) , None ) ;
332+ assert_eq ! ( crate :: simd:: find3( b"ef ghijk" , NEEDLE ) , None ) ;
333+ assert_eq ! ( crate :: simd:: find3( b"ef ghijkl" , NEEDLE ) , None ) ;
334+ assert_eq ! ( crate :: simd:: find3( b"ef ghijkla" , NEEDLE ) , Some ( 9 ) ) ;
335+ assert_eq ! ( crate :: simd:: find3( b"ef ghiajklm" , NEEDLE ) , Some ( 6 ) ) ;
336+ assert_eq ! ( crate :: simd:: find3( b"ef ghibjklm" , NEEDLE ) , Some ( 6 ) ) ;
337+ assert_eq ! ( crate :: simd:: find3( b"ef ghicjklm" , NEEDLE ) , Some ( 6 ) ) ;
338+ assert_eq ! ( crate :: simd:: find3( b"ef ghijklmnopqrstua" , NEEDLE ) , Some ( 18 ) ) ;
339+ assert_eq ! ( crate :: simd:: find3( b"ef ghijklmnopqrstub" , NEEDLE ) , Some ( 18 ) ) ;
340+ assert_eq ! ( crate :: simd:: find3( b"ef ghijklmnopqrstuc" , NEEDLE ) , Some ( 18 ) ) ;
341+ assert_eq ! ( crate :: simd:: find3( b"ef ghijklmnopqrstu" , NEEDLE ) , None ) ;
344342 }
345343
346344 #[ test]
@@ -510,6 +508,56 @@ fn unquoted() {
510508 ) ;
511509}
512510
511+ #[ test]
512+ fn unquoted_href ( ) {
513+ // https://github.com/y21/tl/issues/12
514+ let input = r#"
515+ <a id=u54423 href=https://www.google.com>Hello World</a>
516+ "# ;
517+
518+ let dom = parse ( input, ParserOptions :: default ( ) ) . unwrap ( ) ;
519+ let parser = dom. parser ( ) ;
520+ let element = dom. get_element_by_id ( "u54423" ) ;
521+
522+ assert_eq ! (
523+ element. and_then( |x| x. get( parser) . map( |x| x
524+ . as_tag( )
525+ . unwrap( )
526+ . attributes( )
527+ . get( "href" )
528+ . flatten( )
529+ . unwrap( )
530+ . try_as_utf8_str( )
531+ . unwrap( )
532+ . to_string( ) ) ) ,
533+ Some ( "https://www.google.com" . into( ) )
534+ ) ;
535+ }
536+
537+ #[ test]
538+ fn unquoted_self_closing ( ) {
539+ // https://github.com/y21/tl/issues/12
540+ let input = r#"
541+ <a id=u54423 />
542+ "# ;
543+
544+ let dom = parse ( input, ParserOptions :: default ( ) ) . unwrap ( ) ;
545+ let element = dom. get_element_by_id ( "u54423" ) ;
546+
547+ assert ! ( element. is_some( ) ) ;
548+
549+ // According to MDN, if there's no space between an unquoted attribute and the closing tag,
550+ // the slash is treated as part of the attribute value.
551+ let input = r#"
552+ <a id=u54423/>
553+ "# ;
554+
555+ let dom = parse ( input, ParserOptions :: default ( ) ) . unwrap ( ) ;
556+ let element = dom. get_element_by_id ( "u54423/" ) ;
557+
558+ assert ! ( element. is_some( ) ) ;
559+ }
560+
513561mod query_selector {
514562 use super :: * ;
515563 #[ test]
0 commit comments