Skip to content

Commit c636693

Browse files
committed
add test framework
1 parent 81ad792 commit c636693

File tree

5 files changed

+33
-17
lines changed

5 files changed

+33
-17
lines changed

Cargo.lock

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,16 @@
22
members = [
33
]
44
[package]
5-
name = "c2rust_out"
6-
authors = ["C2Rust"]
5+
name = "z80"
6+
authors = ["kirjavasciprt"]
77
version = "0.0.0"
88
publish = false
99
edition = "2021"
1010
autobins = false
1111

1212
[lib]
13-
name = "c2rust_out"
14-
path = "c2rust-lib.rs"
13+
name = "z80"
14+
path = "lib.rs"
1515
crate-type = ["staticlib", "rlib"]
1616

1717
[dependencies]

c2rust-lib.rs renamed to lib.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,6 @@
99
#[macro_use]
1010
extern crate c2rust_bitfields;
1111
pub mod z80;
12+
13+
#[cfg(tests)]
14+
mod z80_tests;

z80.rs

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,23 @@ pub type uint32_t = u32;
77
pub const Z80_ASSERT: u32 = 2;
88
pub const Z80_PULSE: u32 = 1;
99

10-
pub trait z80Controller {
10+
pub trait z80Mem {
1111
fn read_byte(&self, addr: u16) -> u8;
1212
fn write_byte(&mut self, addr: u16, value: u8);
1313
}
1414

15+
impl z80 {
16+
17+
}
18+
19+
// setup tests
20+
// impl
21+
// add port to trait
22+
1523
#[derive(BitfieldStruct)]
1624
#[repr(C)]
1725
pub struct z80 {
18-
pub memory: Box<dyn z80Controller>,
26+
pub memory: Box<dyn z80Mem>,
1927
pub port_in: Option::<unsafe extern "C" fn(*mut z80, uint16_t) -> uint8_t>,
2028
pub port_out: Option::<unsafe extern "C" fn(*mut z80, uint16_t, uint8_t) -> ()>,
2129
pub pc: uint16_t,
@@ -45,6 +53,7 @@ pub struct z80 {
4553
#[bitfield(padding)]
4654
pub c2rust_padding: [u8; 6],
4755
}
56+
4857
#[derive(Copy, Clone)]
4958
#[repr(C)]
5059
pub union C2RustUnnamed_0 {
@@ -1045,10 +1054,6 @@ pub unsafe extern "C" fn z80_step_n(
10451054
return cyc;
10461055
}
10471056
#[no_mangle]
1048-
pub unsafe extern "C" fn z80_debug_output(z: *mut z80) {
1049-
!z.is_null();
1050-
}
1051-
#[no_mangle]
10521057
pub unsafe extern "C" fn z80_assert_nmi(z: *mut z80) {
10531058
(*z)
10541059
.nmi_pending = ((*z).nmi_pending as i32 | Z80_ASSERT as i32)

z80_tests.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
use crate::z80;
2+
3+
4+
#[test]
5+
pub fn main_0() {
6+
7+
8+
}

0 commit comments

Comments
 (0)