Rename from string to from slice and fuck utf8
This commit is contained in:
19
tests/fromstring.rs
Normal file
19
tests/fromstring.rs
Normal file
@@ -0,0 +1,19 @@
|
||||
extern crate rustijvm;
|
||||
|
||||
use rustijvm::binread::BinReadable;
|
||||
use std::fs::File;
|
||||
use std::io::Read;
|
||||
|
||||
#[test]
|
||||
fn test_create_from_slice() {
|
||||
let mut vec = Vec::<u8>::new();
|
||||
File::open("files/task1/program1.ijvm").unwrap().read_to_end(&mut vec).unwrap();
|
||||
|
||||
let machine = rustijvm::Machine::new_from_slice(&vec).unwrap();
|
||||
assert_eq!(machine.block.len(), 7);
|
||||
assert_eq!(machine.block[0], 0x10); // BIPUSH
|
||||
assert_eq!(machine.block[2], 0x10); // BIPUSH
|
||||
assert_eq!(machine.block[4], 0x60); // IADD
|
||||
assert_eq!(machine.block[5], 0xFD); // OUT
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user