Skip to content

Commit

Permalink
Add unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
Pedro Fontana authored and Pedro Fontana committed Feb 15, 2024
1 parent ba46719 commit 0277cb8
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
8 changes: 8 additions & 0 deletions cairo1-run/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -554,4 +554,12 @@ mod tests {
let args = args.iter().cloned().map(String::from);
assert_matches!(run(args), Ok(Some(res)) if res == "1");
}

#[rstest]
#[case(["cairo1-run", "../cairo_programs/cairo-1-programs/nullable_dict.cairo", "--print_output", "--trace_file", "/dev/null", "--memory_file", "/dev/null", "--layout", "all_cairo", "--cairo_pie_output", "/dev/null"].as_slice())]
#[case(["cairo1-run", "../cairo_programs/cairo-1-programs/nullable_dict.cairo", "--print_output", "--trace_file", "/dev/null", "--memory_file", "/dev/null", "--layout", "all_cairo", "--proof_mode", "--air_public_input", "/dev/null", "--air_private_input", "/dev/null"].as_slice())]
fn test_run_nullable_dict_ok(#[case] args: &[&str]) {
let args = args.iter().cloned().map(String::from);
assert_matches!(run(args), Ok(Some(res)) if res == "");
}
}
12 changes: 12 additions & 0 deletions cairo_programs/cairo-1-programs/nullable_dict.cairo
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
use core::nullable::{nullable_from_box, match_nullable, FromNullableResult};

fn main() {
// Create the dictionary
let mut d: Felt252Dict<Nullable<Span<felt252>>> = Default::default();

// Create the array to insert
let a = array![8, 9, 10];

// Insert it as a `Span`
d.insert(0, nullable_from_box(BoxTrait::new(a.span())));
}

0 comments on commit 0277cb8

Please sign in to comment.