]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
test-bitmap: add tests for bitmap_copy()
authorYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 28 Nov 2017 09:19:04 +0000 (18:19 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 28 Nov 2017 11:34:36 +0000 (20:34 +0900)
src/test/test-bitmap.c

index 6bc88a456646bfcf2dd2fadb7d7c784a292e7767..fa38056126428976517d6aa1f6b49d233eb74652 100644 (file)
@@ -97,8 +97,19 @@ int main(int argc, const char *argv[]) {
 
         assert_se(i == (unsigned) -1);
 
+        b2 = bitmap_copy(b);
+        assert_se(b2);
+        assert_se(bitmap_equal(b, b2) == true);
+        assert_se(bitmap_equal(b, b) == true);
+        assert_se(bitmap_equal(b, NULL) == false);
+        assert_se(bitmap_equal(NULL, b) == false);
+        assert_se(bitmap_equal(NULL, NULL) == true);
+
         bitmap_clear(b);
         assert_se(bitmap_isclear(b) == true);
+        assert_se(bitmap_equal(b, b2) == false);
+        bitmap_free(b2);
+        b2 = NULL;
 
         assert_se(bitmap_set(b, (unsigned) -1) == -ERANGE);