/** * Unit test for {@link INConstraint#accept(IBindingSet)} */ public void testAccept () { super.testAccept () ; // specific test because the implementation does a sort, etc... Var<?> x = Var.var ( "x" ) ; IConstant [] vals = new IConstant [ 100 ] ; for ( int i = 0; i < vals.length; i++ ) vals [ i ] = new Constant<Integer> ( i ) ; List<IConstant> list = Arrays.asList ( vals ) ; Collections.shuffle ( list ) ; vals = list.toArray ( vals ) ; INConstraint op = new INBinarySearch ( x, vals ) ; assertTrue ( op.get ( new ListBindingSet ( new IVariable<?> [] { x }, new IConstant [] { new Constant<Integer> ( 21 ) } ) ) ) ; assertTrue ( op.get ( new ListBindingSet ( new IVariable<?> [] { x }, new IConstant [] { new Constant<Integer> ( 37 ) } ) ) ) ; assertTrue ( op.get ( new ListBindingSet ( new IVariable<?> [] { x }, new IConstant [] { new Constant<Integer> ( 75 ) } ) ) ) ; assertFalse ( op.get ( new ListBindingSet ( new IVariable<?> [] { x }, new IConstant [] { new Constant<Integer> ( 101 ) } ) ) ) ; }
/** * Unit test for {@link INConstraint#accept(IBindingSet)} */ public void testAccept () { super.testAccept () ; // specific test because the implementation does a sort, etc... Var<?> x = Var.var ( "x" ) ; IConstant [] vals = new IConstant [ 100 ] ; for ( int i = 0; i < vals.length; i++ ) vals [ i ] = new Constant<Integer> ( i ) ; List<IConstant> list = Arrays.asList ( vals ) ; Collections.shuffle ( list ) ; vals = list.toArray ( vals ) ; INConstraint op = new INBinarySearch ( x, vals ) ; assertTrue ( op.get ( new ListBindingSet ( new IVariable<?> [] { x }, new IConstant [] { new Constant<Integer> ( 21 ) } ) ) ) ; assertTrue ( op.get ( new ListBindingSet ( new IVariable<?> [] { x }, new IConstant [] { new Constant<Integer> ( 37 ) } ) ) ) ; assertTrue ( op.get ( new ListBindingSet ( new IVariable<?> [] { x }, new IConstant [] { new Constant<Integer> ( 75 ) } ) ) ) ; assertFalse ( op.get ( new ListBindingSet ( new IVariable<?> [] { x }, new IConstant [] { new Constant<Integer> ( 101 ) } ) ) ) ; }