-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #104 from sustech-cs304/test-simulator2
Test simulator
- Loading branch information
Showing
17 changed files
with
850 additions
and
94 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,5 @@ | |
mod instruction; | ||
mod memory; | ||
pub mod simulator; | ||
#[cfg(test)] | ||
mod test; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
mod memory { | ||
use super::super::memory::Memory; | ||
|
||
#[test] | ||
fn test() { | ||
let mut mem = Memory::new(); | ||
mem[0] = 1; | ||
assert_eq!(mem[0], 1); | ||
assert_eq!(mem[1], 0); | ||
assert_eq!(mem[0x54365453u32], 0); | ||
let start = 0x95478806u32; | ||
mem.set_range(start, &[1, 2]); | ||
assert_eq!(mem.get_range(start - 2, 6), [0, 0, 1, 2, 0, 0]); | ||
let start = 0x07637855u32; | ||
const LEN: usize = 16666; | ||
mem.set_range(start, &[1; LEN]); | ||
assert_eq!(mem.get_range(start, LEN as u32), [1; 16666]); | ||
mem.reset(); | ||
} | ||
} |
Oops, something went wrong.