xref: /PHP-8.2/ext/sodium/tests/inc_add.phpt (revision 6c9a0566)
1--TEST--
2increment and add edge cases
3--EXTENSIONS--
4sodium
5--FILE--
6<?php
7
8$notStr = 123;
9try {
10    sodium_increment($notStr);
11} catch (SodiumException $e) {
12    echo $e->getMessage(), "\n";
13}
14
15$str = "abc";
16$str2 = $str;
17sodium_increment($str);
18var_dump($str, $str2);
19
20$str = "ab" . ($x = "c");
21$str2 = $str;
22sodium_increment($str);
23var_dump($str, $str2);
24
25$addStr = "\2\0\0";
26
27$notStr = 123;
28try {
29    sodium_add($notStr, $addStr);
30} catch (SodiumException $e) {
31    echo $e->getMessage(), "\n";
32}
33
34$str = "abc";
35$str2 = $str;
36sodium_add($str, $addStr);
37var_dump($str, $str2);
38
39$str = "ab" . ($x = "c");
40$str2 = $str;
41sodium_add($str, $addStr);
42var_dump($str, $str2);
43
44?>
45--EXPECT--
46a PHP string is required
47string(3) "bbc"
48string(3) "abc"
49string(3) "bbc"
50string(3) "abc"
51PHP strings are required
52string(3) "cbc"
53string(3) "abc"
54string(3) "cbc"
55string(3) "abc"
56