|
1 | 1 | use random_access_memory as ram; |
2 | 2 | use random_access_storage::RandomAccess; |
3 | 3 |
|
4 | | -#[test] |
| 4 | +#[async_std::test] |
5 | 5 | // Postmortem: looks like we were reading out of bounds by accidentally |
6 | 6 | // adding an offset to the index while reading. |
7 | | -fn regress_1() { |
| 7 | +async fn regress_1() { |
8 | 8 | let mut file = ram::RandomAccessMemory::new(50); |
9 | | - file.write(30, &[30]).unwrap(); |
10 | | - file.read(15, 15).unwrap(); |
| 9 | + file.write(30, &[30]).await.unwrap(); |
| 10 | + file.read(15, 15).await.unwrap(); |
11 | 11 | } |
12 | 12 |
|
13 | | -#[test] |
| 13 | +#[async_std::test] |
14 | 14 | // Postmortem: our buffers weren't zero-filled. Intead we were relying on |
15 | 15 | // uninitialized (but claimed!) memory, which caused all sorts of weirdness. |
16 | | -fn regress_2() { |
| 16 | +async fn regress_2() { |
17 | 17 | let mut file = ram::RandomAccessMemory::new(50); |
18 | | - file.write(22, &[22, 22, 22, 22]).unwrap(); |
19 | | - let buf = file.read(1, 4).unwrap(); |
| 18 | + file.write(22, &[22, 22, 22, 22]).await.unwrap(); |
| 19 | + let buf = file.read(1, 4).await.unwrap(); |
20 | 20 | assert_eq!(buf, vec![0, 0, 0, 0]); |
21 | 21 |
|
22 | 22 | let mut file = ram::RandomAccessMemory::new(50); |
23 | | - file.write(48, &[48, 48, 48, 48]).unwrap(); |
24 | | - let buf = file.read(39, 9).unwrap(); |
| 23 | + file.write(48, &[48, 48, 48, 48]).await.unwrap(); |
| 24 | + let buf = file.read(39, 9).await.unwrap(); |
25 | 25 | assert_eq!(buf, vec![0, 0, 0, 0, 0, 0, 0, 0, 0]); |
26 | 26 | } |
27 | 27 |
|
28 | | -#[test] |
| 28 | +#[async_std::test] |
29 | 29 | // Postmortem: the way we were reading was off. We were messing up both reading |
30 | 30 | // and writing. We now keep two cursors, and compute the bounds of every loop |
31 | 31 | // ahead of time. Also simplified our allocation logic. |
32 | | -fn regress_3() { |
| 32 | +async fn regress_3() { |
33 | 33 | let mut file = ram::RandomAccessMemory::new(50); |
34 | | - file.write(45, &[56, 46, 14, 93, 15, 54, 2]).unwrap(); |
35 | | - let buf = file.read(42, 10).unwrap(); |
| 34 | + file.write(45, &[56, 46, 14, 93, 15, 54, 2]).await.unwrap(); |
| 35 | + let buf = file.read(42, 10).await.unwrap(); |
36 | 36 | assert_eq!(buf, vec![0, 0, 0, 56, 46, 14, 93, 15, 54, 2]); |
37 | 37 | } |
38 | 38 |
|
39 | | -#[test] |
| 39 | +#[async_std::test] |
40 | 40 | // Postmortem: we were having trouble when we were reading with an index that's |
41 | 41 | // larger than the page size. Turned out we weren't doing some math properly, |
42 | 42 | // which caused a cursor to jump. |
43 | | -fn regress_4() { |
| 43 | +async fn regress_4() { |
44 | 44 | let mut file = ram::RandomAccessMemory::new(10); |
45 | | - file.write(44, &[54, 59]).unwrap(); |
46 | | - file.read(13, 3).unwrap(); |
| 45 | + file.write(44, &[54, 59]).await.unwrap(); |
| 46 | + file.read(13, 3).await.unwrap(); |
47 | 47 | } |
0 commit comments