Mercurial > vim
comparison src/blob.c @ 15456:f01eb1aed348 v8.1.0736
patch 8.1.0736: code for Blob not sufficiently tested
commit https://github.com/vim/vim/commit/c0f5a78c15b194f23bedb82e6825e34f481e6532
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Jan 13 15:16:13 2019 +0100
patch 8.1.0736: code for Blob not sufficiently tested
Problem: Code for Blob not sufficiently tested.
Solution: Add more tests. Fix uncovered crash. Add test_null_blob().
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sun, 13 Jan 2019 15:30:08 +0100 |
parents | 1d2b5c016f17 |
children | 435fcefd2c8e |
comparison
equal
deleted
inserted
replaced
15455:4e2baf1fe3eb | 15456:f01eb1aed348 |
---|---|
112 int | 112 int |
113 blob_equal( | 113 blob_equal( |
114 blob_T *b1, | 114 blob_T *b1, |
115 blob_T *b2) | 115 blob_T *b2) |
116 { | 116 { |
117 int i; | 117 int i; |
118 int len1 = blob_len(b1); | |
119 int len2 = blob_len(b2); | |
118 | 120 |
119 if (b1 == NULL || b2 == NULL) | 121 // empty and NULL are considered the same |
120 return FALSE; | 122 if (len1 == 0 && len2 == 0) |
123 return TRUE; | |
121 if (b1 == b2) | 124 if (b1 == b2) |
122 return TRUE; | 125 return TRUE; |
123 if (blob_len(b1) != blob_len(b2)) | 126 if (len1 != len2) |
124 return FALSE; | 127 return FALSE; |
125 | 128 |
126 for (i = 0; i < b1->bv_ga.ga_len; i++) | 129 for (i = 0; i < b1->bv_ga.ga_len; i++) |
127 if (blob_get(b1, i) != blob_get(b2, i)) return FALSE; | 130 if (blob_get(b1, i) != blob_get(b2, i)) return FALSE; |
128 return TRUE; | 131 return TRUE; |