mirror of
https://github.com/stefanocasazza/ULib.git
synced 2025-09-28 19:05:55 +08:00
558 lines
36 KiB
C
558 lines
36 KiB
C
/* test_utility.c */
|
||
|
||
/*
|
||
#define DEBUG_DEBUG
|
||
*/
|
||
|
||
#include <ulib/base/utility.h>
|
||
#include <ulib/base/coder/escape.h>
|
||
|
||
#include <ctype.h>
|
||
#include <stdlib.h>
|
||
|
||
#ifdef HAVE_FNMATCH
|
||
# include <fnmatch.h>
|
||
#endif
|
||
|
||
#ifndef FNM_CASEFOLD
|
||
#define FNM_CASEFOLD FNM_IGNORECASE
|
||
#endif
|
||
|
||
#ifndef FNM_LEADING_DIR
|
||
#define FNM_LEADING_DIR FNM_PERIOD
|
||
#endif
|
||
|
||
static int compare_str(const void* str1, const void* str2) { return u_strnatcmp(*(const char**)str1, *(const char**)str2); }
|
||
|
||
static void check_match(void)
|
||
{
|
||
U_INTERNAL_ASSERT( u_pfn_match(U_CONSTANT_TO_PARAM("01000000002345"),
|
||
U_CONSTANT_TO_PARAM("01*2345"), u_pfn_flags) == true )
|
||
U_INTERNAL_ASSERT( u_pfn_match(U_CONSTANT_TO_PARAM("01000000002345"),
|
||
U_CONSTANT_TO_PARAM("01*2?46"), u_pfn_flags) == false )
|
||
U_INTERNAL_ASSERT( u_pfn_match(U_CONSTANT_TO_PARAM("01000000002345"),
|
||
U_CONSTANT_TO_PARAM("010000000 2?45"), u_pfn_flags) == false )
|
||
U_INTERNAL_ASSERT( u_pfn_match(U_CONSTANT_TO_PARAM("01000000002345"),
|
||
U_CONSTANT_TO_PARAM("01*2?4?"), u_pfn_flags) == true )
|
||
U_INTERNAL_ASSERT( u_pfn_match(U_CONSTANT_TO_PARAM("01000000002345"),
|
||
U_CONSTANT_TO_PARAM("01*00*00*2?46"), u_pfn_flags) == false )
|
||
U_INTERNAL_ASSERT( u_pfn_match(U_CONSTANT_TO_PARAM("01000000002345"),
|
||
U_CONSTANT_TO_PARAM("01*2?46?????????????????????"), u_pfn_flags) == false )
|
||
U_INTERNAL_ASSERT( u_pfn_match(U_CONSTANT_TO_PARAM("01000000002345"),
|
||
U_CONSTANT_TO_PARAM("*****01*2?46?????????????????????"), u_pfn_flags) == false )
|
||
U_INTERNAL_ASSERT( u_pfn_match(U_CONSTANT_TO_PARAM("aaAA4b334"),
|
||
U_CONSTANT_TO_PARAM("aaAA?b*4"), u_pfn_flags) == true )
|
||
U_INTERNAL_ASSERT( u_pfn_match(U_CONSTANT_TO_PARAM("aaAA4b334"),
|
||
U_CONSTANT_TO_PARAM("aaaa?b*4"), u_pfn_flags | FNM_CASEFOLD) == true )
|
||
}
|
||
|
||
#define U_TESTO_SEMPLICE "testosemplicetxt" /* no _.:?! */
|
||
|
||
int main(int argc, char* argv[])
|
||
{
|
||
static char buf[4096], buffer[4096];
|
||
|
||
bool ok;
|
||
int i, n;
|
||
char buf8[9];
|
||
char* sargv[128];
|
||
uint32_t path_len;
|
||
const char* path_rel;
|
||
char path[PATH_MAX + 1];
|
||
|
||
const char* vec[] = {
|
||
"libpng-1.0.10.tar.gz",
|
||
"libpng-1.0.11.tar.gz",
|
||
"libpng-1.0.12.tar.gz",
|
||
"libpng-1.0.3.tar.gz",
|
||
"libpng-1.0.5.tar.gz",
|
||
"libpng-1.0.6-patch-a.txt.gz",
|
||
"libpng-1.0.6-patch-b.txt.gz",
|
||
"libpng-1.0.6-patch-c.txt.gz",
|
||
"libpng-1.0.6.tar.gz",
|
||
"libpng-1.0.7.tar.gz",
|
||
"libpng-1.0.8.tar.gz",
|
||
"libpng-1.0.9.tar.gz",
|
||
"libpng-1.2.0.tar.gz" };
|
||
|
||
u_init_ulib(argv);
|
||
|
||
U_INTERNAL_TRACE("main(%d,%p)", argc, argv)
|
||
|
||
U_INTERNAL_ASSERT( u_dosmatch_with_OR(U_CONSTANT_TO_PARAM("index.shtml"), U_CONSTANT_TO_PARAM("*.css|*.js|*.*html|*.png|*.gif|*.jpg"), 0) == true)
|
||
|
||
U_INTERNAL_ASSERT( u__isdigit('1') )
|
||
U_INTERNAL_ASSERT( u__ispunct('.') )
|
||
U_INTERNAL_ASSERT( u__isprint('1') )
|
||
U_INTERNAL_ASSERT( u__isprint('.') )
|
||
U_INTERNAL_ASSERT( u_isText((const unsigned char*)U_CONSTANT_TO_PARAM("binary: |