[core] fix buffer_to_upper()
fix buffer_to_upper() and case-insensitive filesystem detectionpersonal/stbuehler/fix-fdevent
parent
1c68589c67
commit
2e385a1a53
|
@ -955,7 +955,7 @@ void buffer_to_upper(buffer *b) {
|
|||
|
||||
for (i = 0; i < b->used; ++i) {
|
||||
char c = b->ptr[i];
|
||||
if (c >= 'A' && c <= 'Z') b->ptr[i] &= ~0x20;
|
||||
if (c >= 'a' && c <= 'z') b->ptr[i] &= ~0x20;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#include "first.h"
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
|
@ -83,8 +84,25 @@ static void test_buffer_path_simplify(void) {
|
|||
buffer_free(pdest);
|
||||
}
|
||||
|
||||
static void test_buffer_to_lower_upper(void) {
|
||||
buffer *psrc = buffer_init();
|
||||
|
||||
buffer_copy_string_len(psrc, CONST_STR_LEN("0123456789abcdefghijklmnopqrstuvwxyz"));
|
||||
buffer_to_lower(psrc);
|
||||
assert(buffer_is_equal_string(psrc, CONST_STR_LEN("0123456789abcdefghijklmnopqrstuvwxyz")));
|
||||
buffer_to_upper(psrc);
|
||||
assert(buffer_is_equal_string(psrc, CONST_STR_LEN("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ")));
|
||||
buffer_to_upper(psrc);
|
||||
assert(buffer_is_equal_string(psrc, CONST_STR_LEN("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ")));
|
||||
buffer_to_lower(psrc);
|
||||
assert(buffer_is_equal_string(psrc, CONST_STR_LEN("0123456789abcdefghijklmnopqrstuvwxyz")));
|
||||
|
||||
buffer_free(psrc);
|
||||
}
|
||||
|
||||
int main() {
|
||||
test_buffer_path_simplify();
|
||||
test_buffer_to_lower_upper();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue