summaryrefslogtreecommitdiff
path: root/tests/basic-types
diff options
context:
space:
mode:
authorRico Tzschichholz <ricotz@ubuntu.com>2020-05-24 19:25:41 +0200
committerRico Tzschichholz <ricotz@ubuntu.com>2020-05-24 19:25:41 +0200
commit6312d8c7563c227b77d2098c9de1048f65c3b51f (patch)
tree54f2db4851ca32f697d1b234ef91487d43a3ca49 /tests/basic-types
parent18847c9221362081c9a9d37e2922f3e3ea648088 (diff)
downloadvala-6312d8c7563c227b77d2098c9de1048f65c3b51f.tar.gz
tests: Extend "s[p]lice" tests to increase coverage
Diffstat (limited to 'tests/basic-types')
-rw-r--r--tests/basic-types/arrays.vala4
-rw-r--r--tests/basic-types/strings.vala9
2 files changed, 13 insertions, 0 deletions
diff --git a/tests/basic-types/arrays.vala b/tests/basic-types/arrays.vala
index ac43c2050..f4777a7a7 100644
--- a/tests/basic-types/arrays.vala
+++ b/tests/basic-types/arrays.vala
@@ -38,6 +38,10 @@ void test_integer_array () {
assert (c[0] == 23);
assert (c[1] == 11);
+ int[]? c0 = a[0:0];
+ assert (c0 == null);
+ assert (c0.length == 0);
+
// in expressions
assert (23 in a);
assert (!(-1 in a));
diff --git a/tests/basic-types/strings.vala b/tests/basic-types/strings.vala
index a4fcda4f7..ecead74c0 100644
--- a/tests/basic-types/strings.vala
+++ b/tests/basic-types/strings.vala
@@ -70,6 +70,9 @@ void test_string_slice () {
r = s.slice (-7, -5);
assert (r == "my");
+
+ r = s.slice (0, 0);
+ assert (r == "");
}
void test_string_splice () {
@@ -89,6 +92,12 @@ void test_string_splice () {
s = s.splice (-14, -5);
assert (s == "helloworld");
+
+ s = "hello".splice (0, 0);
+ assert (s == "hello");
+
+ s = "world".splice (0, 0, "hello");
+ assert (s == "helloworld");
}
void test_string_substring () {