Initial commit
This commit is contained in:
29
tests/07_case_cmp.c
Normal file
29
tests/07_case_cmp.c
Normal file
@@ -0,0 +1,29 @@
|
||||
#define DEBUG
|
||||
#include <stdlib.h>
|
||||
#include <assert.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include "../include/sv.h"
|
||||
|
||||
int main(void){
|
||||
const char *s = " Hello World! ";
|
||||
const char *s2 = "Hello World!";
|
||||
const char *s3 = "hElLo wOrLD!";
|
||||
const char *s4 = "Goodbye World!";
|
||||
|
||||
SV sv = sv_str(s);
|
||||
SV sv3 = sv_str(s3);
|
||||
SV sv4 = sv_str(s4);
|
||||
assert(sv.buf != NULL);
|
||||
assert(strlen(s) == sv.len);
|
||||
assert( memcmp(sv.buf, s, strlen(s)) == 0);
|
||||
SV sv2 = sv_trim(sv);
|
||||
assert(sv2.len == strlen(s2));
|
||||
assert(memcmp(s2, sv2.buf, sv2.len) == 0);
|
||||
assert(sv2.len != strlen(s));
|
||||
assert( memcmp(s, sv2.buf, sv2.len) != 0);
|
||||
assert( !sv_eq(sv, sv2));
|
||||
assert( sv_casecmp(sv2,sv3) == 0);
|
||||
assert( sv_casecmp(sv3,sv4) == 1);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
Reference in New Issue
Block a user