summaryrefslogtreecommitdiff
path: root/ext/sodium/tests/inc_add.phpt
blob: 2ab9b92696f6a525583e92af757c0e78f6e6a380 (plain)
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
--TEST--
increment and add edge cases
--SKIPIF--
<?php if (!extension_loaded("sodium")) print "skip"; ?>
--FILE--
<?php

$notStr = 123;
try {
	sodium_increment($notStr);
} catch (SodiumException $e) {
	echo $e->getMessage(), "\n";
}

$str = "abc";
$str2 = $str;
sodium_increment($str);
var_dump($str, $str2);

$str = "ab" . ($x = "c");
$str2 = $str;
sodium_increment($str);
var_dump($str, $str2);

$addStr = "\2\0\0";

$notStr = 123;
try {
	sodium_add($notStr, $addStr);
} catch (SodiumException $e) {
	echo $e->getMessage(), "\n";
}

$str = "abc";
$str2 = $str;
sodium_add($str, $addStr);
var_dump($str, $str2);

$str = "ab" . ($x = "c");
$str2 = $str;
sodium_add($str, $addStr);
var_dump($str, $str2);

?>
--EXPECT--
increment(): a PHP string is required
string(3) "bbc"
string(3) "abc"
string(3) "bbc"
string(3) "abc"
add(): PHP strings are required
string(3) "cbc"
string(3) "abc"
string(3) "cbc"
string(3) "abc"