Skip to content

Commit 6a7dcdf

Browse files
committed
fix tests
1 parent b8729ba commit 6a7dcdf

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
fn take_while_ascii_pred_simple() {
867867
let mut cur = Cursor::from(&b"abcdefghijk"[..]);
868868

869-
let mut buf: Vec<u8> = Vec::new();
869+
let mut 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
fn take_while_ascii_pred_immediate_stop() {
879880
let mut cur = Cursor::from(&b"abcdefghijk"[..]);
880881

881-
let mut buf: Vec<u8> = Vec::new();
882+
let mut 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
fn take_while_ascii_pred_entire_str() {
890891
let mut cur = Cursor::from(&b"abcdefghijk"[..]);
891892

892-
let mut buf: Vec<u8> = Vec::new();
893+
let mut 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
fn take_while_ascii_pred_non_ascii_stop() {
901902
let mut cur = Cursor::from("abcde😀fghijk".as_bytes());
902903

903-
let mut buf: Vec<u8> = Vec::new();
904+
let mut 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)