-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInteger.php
More file actions
73 lines (60 loc) · 1.97 KB
/
Copy pathInteger.php
File metadata and controls
73 lines (60 loc) · 1.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<?php
declare(strict_types=1);
/*
* This file is part of the QuidPHP package <https://quidphp.com>
* Author: Pierre-Philippe Emond <emondpph@gmail.com>
* License: https://github.com/quidphp/base/blob/master/LICENSE
*/
namespace Quid\Test\Base;
use Quid\Base;
// integer
// class for testing Quid\Base\Integer
class Integer extends Base\Test
{
// trigger
final public static function trigger(array $data):bool
{
// typecast
$a = '23.2';
$b = 'string';
Base\Integer::typecast($a,$b);
assert($a === 23);
assert($b === 0);
// cast
assert(Base\Integer::cast('30MB') === null);
assert(Base\Integer::cast(true) === 1);
assert(Base\Integer::cast('1.5') === 1);
// is
assert(Base\Integer::is(1));
assert(!Base\Integer::is(2.3));
// isEmpty
assert(!Base\Integer::isEmpty(1));
assert(Base\Integer::isEmpty(0));
// isNotEmpty
assert(Base\Integer::isNotEmpty(1));
// isCast
assert(!Base\Integer::isCast('1.5'));
assert(Base\Integer::isCast(-1));
assert(!Base\Integer::isCast(1.5));
assert(Base\Integer::isCast(0));
// isCastNotEmpty
assert(!Base\Integer::isCastNotEmpty('1.5'));
assert(Base\Integer::isCastNotEmpty(-1));
assert(!Base\Integer::isCastNotEmpty(1.5));
assert(!Base\Integer::isCastNotEmpty(0));
// toBool
assert(Base\Integer::toBool(1) === true);
assert(Base\Integer::toBool(0) === false);
assert(Base\Integer::toBool(2) === null);
// toggle
assert(1 === Base\Integer::toggle(0));
// range
assert([0,2,4] === Base\Integer::range(0,5,2));
assert([2] === Base\Integer::range(2,3,2));
assert(Base\Integer::range(2,3,2,true) === [2=>2]);
assert(count(Base\Integer::range(1,100,1)) === 100);
assert(count(Base\Integer::range(2,18,3)) === 6);
return true;
}
}
?>