mirror of
https://codeberg.org/anoncontributorxmr/monero.git
synced 2024-11-27 05:13:25 +01:00
tests: slow_memmem now returns size_t
Makes more sense than uint64_t for an offset, and agrees with the %zu used to print results. Found by codacy.com
This commit is contained in:
parent
84dd674cd0
commit
3002307418
@ -1026,7 +1026,7 @@ namespace cryptonote
|
|||||||
//------------------------------------------------------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------------------------------------------------------
|
||||||
// equivalent of strstr, but with arbitrary bytes (ie, NULs)
|
// equivalent of strstr, but with arbitrary bytes (ie, NULs)
|
||||||
// This does not differentiate between "not found" and "found at offset 0"
|
// This does not differentiate between "not found" and "found at offset 0"
|
||||||
uint64_t slow_memmem(const void* start_buff, size_t buflen,const void* pat,size_t patlen)
|
size_t slow_memmem(const void* start_buff, size_t buflen,const void* pat,size_t patlen)
|
||||||
{
|
{
|
||||||
const void* buf = start_buff;
|
const void* buf = start_buff;
|
||||||
const void* end=(const char*)buf+buflen;
|
const void* end=(const char*)buf+buflen;
|
||||||
|
@ -45,7 +45,7 @@
|
|||||||
//#define VERBOSE
|
//#define VERBOSE
|
||||||
|
|
||||||
#ifdef TEST_ORIGINAL
|
#ifdef TEST_ORIGINAL
|
||||||
uint64_t slow_memmem_original(void* start_buff, size_t buflen,void* pat,size_t patlen)
|
size_t slow_memmem_original(void* start_buff, size_t buflen,void* pat,size_t patlen)
|
||||||
{
|
{
|
||||||
void* buf = start_buff;
|
void* buf = start_buff;
|
||||||
void* end=(char*)buf+buflen-patlen;
|
void* end=(char*)buf+buflen-patlen;
|
||||||
@ -63,7 +63,7 @@ uint64_t slow_memmem_original(void* start_buff, size_t buflen,void* pat,size_t p
|
|||||||
#define slow_memmem slow_memmem_original
|
#define slow_memmem slow_memmem_original
|
||||||
#else
|
#else
|
||||||
namespace cryptonote {
|
namespace cryptonote {
|
||||||
uint64_t slow_memmem(const void* start_buff, size_t buflen,const void* pat,size_t patlen);
|
size_t slow_memmem(const void* start_buff, size_t buflen,const void* pat,size_t patlen);
|
||||||
}
|
}
|
||||||
using namespace cryptonote;
|
using namespace cryptonote;
|
||||||
#endif
|
#endif
|
||||||
@ -73,7 +73,7 @@ static const struct {
|
|||||||
const char *buf;
|
const char *buf;
|
||||||
size_t patlen;
|
size_t patlen;
|
||||||
const char *pat;
|
const char *pat;
|
||||||
uint64_t res;
|
size_t res;
|
||||||
} T[]={
|
} T[]={
|
||||||
{0,"",0,"",0},
|
{0,"",0,"",0},
|
||||||
{1,"",0,"",0},
|
{1,"",0,"",0},
|
||||||
@ -117,7 +117,7 @@ TEST(slowmem,Success)
|
|||||||
memcpy(buf,T[n].buf,T[n].buflen);
|
memcpy(buf,T[n].buf,T[n].buflen);
|
||||||
void *pat=malloc(T[n].patlen);
|
void *pat=malloc(T[n].patlen);
|
||||||
memcpy(pat,T[n].pat,T[n].patlen);
|
memcpy(pat,T[n].pat,T[n].patlen);
|
||||||
uint64_t res=slow_memmem(buf,T[n].buflen,pat,T[n].patlen);
|
size_t res=slow_memmem(buf,T[n].buflen,pat,T[n].patlen);
|
||||||
free(pat);
|
free(pat);
|
||||||
free(buf);
|
free(buf);
|
||||||
ASSERT_EQ(res,T[n].res);
|
ASSERT_EQ(res,T[n].res);
|
||||||
|
Loading…
Reference in New Issue
Block a user