MCPcopy Index your code
hub / github.com/ciphermodelabs/ciphercore / test_not

Function test_not

ciphercore-base/src/custom_ops.rs:758–803  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

756
757 #[test]
758 fn test_not() {
759 || -> Result<()> {
760 let c = create_context()?;
761 let g = c.create_graph()?;
762 let i = g.input(scalar_type(BIT))?;
763 let o = g.custom_op(CustomOperation::new(Not {}), vec![i])?;
764 g.set_output_node(o)?;
765 g.finalize()?;
766 c.set_main_graph(g.clone())?;
767 c.finalize()?;
768 let mapped_c = run_instantiation_pass(c)?;
769 for x in vec![0, 1] {
770 let result = random_evaluate(
771 mapped_c.mappings.get_graph(g.clone()),
772 vec![Value::from_scalar(x, BIT)?],
773 )?;
774 let result = result.to_u8(BIT)?;
775 assert_eq!(result, !(x != 0) as u8);
776 }
777 Ok(())
778 }()
779 .unwrap();
780 // Test broadcasting
781 || -> Result<()> {
782 let c = create_context()?;
783 let g = c.create_graph()?;
784 let i = g.input(array_type(vec![3, 3], BIT))?;
785 let o = g.custom_op(CustomOperation::new(Not {}), vec![i])?;
786 g.set_output_node(o)?;
787 g.finalize()?;
788 c.set_main_graph(g.clone())?;
789 c.finalize()?;
790 let mapped_c = run_instantiation_pass(c)?;
791 let result = random_evaluate(
792 mapped_c.mappings.get_graph(g.clone()),
793 vec![Value::from_flattened_array(
794 &vec![0, 1, 1, 0, 1, 0, 0, 1, 1],
795 BIT,
796 )?],
797 )?;
798 let result = result.to_flattened_array_u64(array_type(vec![3, 3], BIT))?;
799 assert_eq!(result, vec![1, 0, 0, 1, 0, 1, 1, 0, 0]);
800 Ok(())
801 }()
802 .unwrap();
803 }
804
805 #[test]
806 fn test_or() {

Callers

nothing calls this directly

Calls 15

run_instantiation_passFunction · 0.85
random_evaluateFunction · 0.85
cloneMethod · 0.80
to_u8Method · 0.80
create_contextFunction · 0.70
scalar_typeFunction · 0.70
array_typeFunction · 0.70
create_graphMethod · 0.45
inputMethod · 0.45
custom_opMethod · 0.45
set_output_nodeMethod · 0.45

Tested by

no test coverage detected