Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit6a7dcdf

Browse files
committed
fix tests
1 parentb8729ba commit6a7dcdf

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

‎core/parser/src/lexer/tests.rs‎

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -866,45 +866,46 @@ fn addition_no_spaces_e_number() {
866866
fntake_while_ascii_pred_simple(){
867867
letmut cur =Cursor::from(&b"abcdefghijk"[..]);
868868

869-
letmut buf:Vec<u8> =Vec::new();
869+
letmut buf:[u8;8] =[0;8];
870870

871-
cur.take_while_ascii_pred(&mut buf,&|c| c =='a' || c =='b' || c =='c')
871+
let slice = cur
872+
.take_while_ascii_pred(&mut buf,&|c| c =='a' || c =='b' || c =='c')
872873
.unwrap();
873874

874-
assert_eq!(str::from_utf8(buf.as_slice()).unwrap(),"abc");
875+
assert_eq!(str::from_utf8(slice).unwrap(),"abc");
875876
}
876877

877878
#[test]
878879
fntake_while_ascii_pred_immediate_stop(){
879880
letmut cur =Cursor::from(&b"abcdefghijk"[..]);
880881

881-
letmut buf:Vec<u8> =Vec::new();
882+
letmut buf:[u8;8] =[0;8];
882883

883-
cur.take_while_ascii_pred(&mut buf,&|_|false).unwrap();
884+
let slice =cur.take_while_ascii_pred(&mut buf,&|_|false).unwrap();
884885

885-
assert_eq!(str::from_utf8(buf.as_slice()).unwrap(),"");
886+
assert_eq!(str::from_utf8(slice).unwrap(),"");
886887
}
887888

888889
#[test]
889890
fntake_while_ascii_pred_entire_str(){
890891
letmut cur =Cursor::from(&b"abcdefghijk"[..]);
891892

892-
letmut buf:Vec<u8> =Vec::new();
893+
letmut buf:[u8;11] =[0;11];
893894

894-
cur.take_while_ascii_pred(&mut buf,&|_|true).unwrap();
895+
let slice =cur.take_while_ascii_pred(&mut buf,&|_|true).unwrap();
895896

896-
assert_eq!(str::from_utf8(buf.as_slice()).unwrap(),"abcdefghijk");
897+
assert_eq!(str::from_utf8(slice).unwrap(),"abcdefghijk");
897898
}
898899

899900
#[test]
900901
fntake_while_ascii_pred_non_ascii_stop(){
901902
letmut cur =Cursor::from("abcde😀fghijk".as_bytes());
902903

903-
letmut buf:Vec<u8> =Vec::new();
904+
letmut buf:[u8;12] =[0;12];
904905

905-
cur.take_while_ascii_pred(&mut buf,&|_|true).unwrap();
906+
let slice =cur.take_while_ascii_pred(&mut buf,&|_|true).unwrap();
906907

907-
assert_eq!(str::from_utf8(buf.as_slice()).unwrap(),"abcde");
908+
assert_eq!(str::from_utf8(slice).unwrap(),"abcde");
908909
}
909910

910911
#[test]

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp