()
| 441 | |
| 442 | #[test] |
| 443 | fn test_well_behaved() -> Result<()> { |
| 444 | { |
| 445 | let c = simple_context(|g| { |
| 446 | let i1 = g.input(array_type(vec![5, 16], BIT))?; |
| 447 | let i2 = g.input(array_type(vec![1, 16], BIT))?; |
| 448 | g.custom_op( |
| 449 | CustomOperation::new(BinaryAdd { |
| 450 | overflow_bit: false, |
| 451 | }), |
| 452 | vec![i1, i2], |
| 453 | ) |
| 454 | })?; |
| 455 | let mapped_c = run_instantiation_pass(c)?; |
| 456 | let inputs1 = |
| 457 | Value::from_flattened_array(&vec![0, 1023, -1023, i16::MIN, i16::MAX], INT16)?; |
| 458 | let inputs2 = Value::from_flattened_array(&vec![1024], INT16)?; |
| 459 | let result_v = random_evaluate( |
| 460 | mapped_c.get_context().get_main_graph()?, |
| 461 | vec![inputs1, inputs2], |
| 462 | )? |
| 463 | .to_flattened_array_u64(array_type(vec![5], INT16))?; |
| 464 | assert_eq!( |
| 465 | result_v, |
| 466 | vec![ |
| 467 | 1024, |
| 468 | 2047, |
| 469 | 1, |
| 470 | (i16::MIN + 1024) as u64, |
| 471 | (i16::MAX.wrapping_add(1024)) as u64, |
| 472 | ] |
| 473 | ); |
| 474 | } |
| 475 | { |
| 476 | let c = simple_context(|g| { |
| 477 | let i1 = g.input(array_type(vec![64], BIT))?; |
| 478 | let i2 = g.input(array_type(vec![64], BIT))?; |
| 479 | g.custom_op( |
| 480 | CustomOperation::new(BinaryAdd { |
| 481 | overflow_bit: false, |
| 482 | }), |
| 483 | vec![i1, i2], |
| 484 | ) |
| 485 | })?; |
| 486 | let mapped_c = run_instantiation_pass(c)?; |
| 487 | let input0 = Value::from_scalar(123456790, INT64)?; |
| 488 | let input1 = Value::from_scalar(-123456789, INT64)?; |
| 489 | let result_v = random_evaluate( |
| 490 | mapped_c.get_context().get_main_graph()?, |
| 491 | vec![input0, input1], |
| 492 | )? |
| 493 | .to_u64(INT64)?; |
| 494 | assert_eq!(result_v, 1); |
| 495 | } |
| 496 | Ok(()) |
| 497 | } |
| 498 | |
| 499 | #[test] |
| 500 | fn test_malformed() -> Result<()> { |
nothing calls this directly
no test coverage detected