1--TEST--
2Test strcspn() function : error conditions
3--FILE--
4<?php
5/* Prototype  : proto int strcspn(string str, string mask [, int start [, int len]])
6 * Description: Finds length of initial segment consisting entirely of characters not found in mask.
7                If start or/and length is provided works like strcspn(substr($s,$start,$len),$bad_chars)
8 * Source code: ext/standard/string.c
9 * Alias to functions: none
10*/
11
12/*
13* Test strcspn() : for error conditons
14*/
15
16echo "*** Testing strcspn() : error conditions ***\n";
17
18// Zero arguments
19echo "\n-- Testing strcspn() function with Zero arguments --\n";
20var_dump( strcspn() );
21
22//Test strcspn with one more than the expected number of arguments
23echo "\n-- Testing strcspn() function with more than expected no. of arguments --\n";
24$str = 'string_val';
25$mask = 'string_val';
26$start = 2;
27$len = 20;
28
29
30$extra_arg = 10;
31var_dump( strcspn($str,$mask,$start,$len, $extra_arg) );
32
33// Testing strcspn withone less than the expected number of arguments
34echo "\n-- Testing strcspn() function with less than expected no. of arguments --\n";
35$str = 'string_val';
36var_dump( strcspn($str) );
37
38echo "Done"
39?>
40--EXPECTF--
41*** Testing strcspn() : error conditions ***
42
43-- Testing strcspn() function with Zero arguments --
44
45Warning: strcspn() expects at least 2 parameters, 0 given in %s on line %d
46NULL
47
48-- Testing strcspn() function with more than expected no. of arguments --
49
50Warning: strcspn() expects at most 4 parameters, 5 given in %s on line %d
51NULL
52
53-- Testing strcspn() function with less than expected no. of arguments --
54
55Warning: strcspn() expects at least 2 parameters, 1 given in %s on line %d
56NULL
57Done
58