cStyleCasts

This commit is contained in:
gtsoul-tech 2024-05-17 16:58:08 +03:00
parent 4abe31cbce
commit e261f286da
11 changed files with 396 additions and 396 deletions

View File

@ -145,7 +145,7 @@ int main(){
sizes[i], MAX_LOOPS / sizes[i], matches[m], false, bench,
[&](MicroBenchmark &b) {
b.chars.set('a');
ue2::shuftiBuildMasks(b.chars, (u8 *)&b.lo, (u8 *)&b.hi);
ue2::shuftiBuildMasks(b.chars, reinterpret_cast<u8 *>(&b.lo), reinterpret_cast<u8 *>(&b.hi));
memset(b.buf.data(), 'b', b.size);
},
[&](MicroBenchmark &b) {
@ -160,7 +160,7 @@ int main(){
sizes[i], MAX_LOOPS / sizes[i], matches[m], true, bench,
[&](MicroBenchmark &b) {
b.chars.set('a');
ue2::shuftiBuildMasks(b.chars, (u8 *)&b.lo, (u8 *)&b.hi);
ue2::shuftiBuildMasks(b.chars, reinterpret_cast<u8 *>(&b.lo), reinterpret_cast<u8 *>(&b.hi));
memset(b.buf.data(), 'b', b.size);
},
[&](MicroBenchmark &b) {
@ -175,7 +175,7 @@ int main(){
sizes[i], MAX_LOOPS / sizes[i], matches[m], false, bench,
[&](MicroBenchmark &b) {
b.chars.set('a');
ue2::truffleBuildMasks(b.chars, (u8 *)&b.lo, (u8 *)&b.hi);
ue2::truffleBuildMasks(b.chars, reinterpret_cast<u8 *>(&b.lo), reinterpret_cast<u8 *>(&b.hi));
memset(b.buf.data(), 'b', b.size);
},
[&](MicroBenchmark &b) {
@ -190,7 +190,7 @@ int main(){
sizes[i], MAX_LOOPS / sizes[i], matches[m], true, bench,
[&](MicroBenchmark &b) {
b.chars.set('a');
ue2::truffleBuildMasks(b.chars, (u8 *)&b.lo, (u8 *)&b.hi);
ue2::truffleBuildMasks(b.chars, reinterpret_cast<u8 *>(&b.lo), reinterpret_cast<u8 *>(&b.hi));
memset(b.buf.data(), 'b', b.size);
},
[&](MicroBenchmark &b) {
@ -205,7 +205,7 @@ int main(){
sizes[i], MAX_LOOPS / sizes[i], matches[m], false, bench,
[&](MicroBenchmark &b) {
b.chars.set('a');
ue2::truffleBuildMasks(b.chars, (u8 *)&b.lo, (u8 *)&b.hi);
ue2::truffleBuildMasks(b.chars, reinterpret_cast<u8 *>(&b.lo), reinterpret_cast<u8 *>(&b.hi));
memset(b.buf.data(), 'b', b.size);
},
[&](MicroBenchmark &b) {
@ -220,7 +220,7 @@ int main(){
sizes[i], MAX_LOOPS / sizes[i], matches[m], true, bench,
[&](MicroBenchmark &b) {
b.chars.set('a');
ue2::truffleBuildMasks(b.chars, (u8 *)&b.lo, (u8 *)&b.hi);
ue2::truffleBuildMasks(b.chars, reinterpret_cast<u8 *>(&b.lo), reinterpret_cast<u8 *>(&b.hi));
memset(b.buf.data(), 'b', b.size);
},
[&](MicroBenchmark &b) {

View File

@ -209,8 +209,8 @@ struct FiveTuple {
dstAddr = iphdr->ip_dst.s_addr;
// UDP/TCP ports
const struct udphdr *uh = (const struct udphdr *)
(((const char *)iphdr) + (iphdr->ip_hl * 4));
const struct udphdr *uh = reinterpret_cast<const struct udphdr *>
((reinterpret_cast<const char *>(iphdr)) + (iphdr->ip_hl * 4));
srcPort = uh->uh_sport;
dstPort = uh->uh_dport;
}
@ -239,7 +239,7 @@ static
int onMatch(unsigned int id, unsigned long long from, unsigned long long to,
unsigned int flags, void *ctx) {
// Our context points to a size_t storing the match count
size_t *matches = (size_t *)ctx;
size_t *matches = static_cast<size_t *>(ctx);
(*matches)++;
return 0; // continue matching
}
@ -340,9 +340,9 @@ public:
}
// Valid TCP or UDP packet
const struct ip *iphdr = (const struct ip *)(pktData
const struct ip *iphdr = reinterpret_cast<const struct ip *>(pktData
+ sizeof(struct ether_header));
const char *payload = (const char *)pktData + offset;
const char *payload = reinterpret_cast<const char *>(pktData) + offset;
size_t id = stream_map.insert(std::make_pair(FiveTuple(iphdr),
stream_map.size())).first->second;
@ -798,7 +798,7 @@ int main(int argc, char **argv) {
static
bool payloadOffset(const unsigned char *pkt_data, unsigned int *offset,
unsigned int *length) {
const ip *iph = (const ip *)(pkt_data + sizeof(ether_header));
const ip *iph = reinterpret_cast<const ip *>(pkt_data + sizeof(ether_header));
const tcphdr *th = nullptr;
// Ignore packets that aren't IPv4
@ -817,7 +817,7 @@ bool payloadOffset(const unsigned char *pkt_data, unsigned int *offset,
switch (iph->ip_p) {
case IPPROTO_TCP:
th = (const tcphdr *)((const char *)iph + ihlen);
th = reinterpret_cast<const tcphdr *>(reinterpret_cast<const char *>(iph) + ihlen);
thlen = th->th_off * 4;
break;
case IPPROTO_UDP:

View File

@ -49,7 +49,7 @@ void readRow(sqlite3_stmt *statement, vector<DataBlock> &blocks,
map<unsigned int, unsigned int> &stream_indices) {
unsigned int id = sqlite3_column_int(statement, 0);
unsigned int stream_id = sqlite3_column_int(statement, 1);
const char *blob = (const char *)sqlite3_column_blob(statement, 2);
const char *blob = reinterpret_cast<const char *>(sqlite3_column_blob(statement, 2));
unsigned int bytes = sqlite3_column_bytes(statement, 2);
if (!contains(stream_indices, stream_id)) {

View File

@ -98,10 +98,10 @@ hs_database_t *get_huge(hs_database_t *db) {
// Mark this segment to be destroyed after this process detaches.
shmctl(hsdb_shmid, IPC_RMID, nullptr);
err = hs_deserialize_database_at(bytes, len, (hs_database_t *)shmaddr);
err = hs_deserialize_database_at(bytes, len, reinterpret_cast<hs_database_t *>(shmaddr));
if (err != HS_SUCCESS) {
printf("Failed to deserialize database into shm: %d\n", err);
shmdt((const void *)shmaddr);
shmdt(reinterpret_cast<const void *>(shmaddr));
goto fini;
}
@ -121,7 +121,7 @@ fini:
void release_huge(hs_database_t *db) {
#if defined(HAVE_SHMGET) && defined(SHM_HUGETLB)
if (hsdb_shmid != -1) {
if (shmdt((const void *)db) != 0) {
if (shmdt(reinterpret_cast<const void *>(db)) != 0) {
perror("Detach failure");
}
} else {

View File

@ -485,7 +485,7 @@ void stopTotalTimer(const ThreadContext *ctx) {
/** Run a benchmark over a given engine and corpus in block mode. */
static
void benchBlock(void *context) {
ThreadContext *ctx = (ThreadContext *)context;
ThreadContext *ctx = reinterpret_cast<ThreadContext *>(context);
// Synchronization point
ctx->barrier();
@ -603,7 +603,7 @@ void benchStreamingInternal(ThreadContext *ctx, vector<StreamInfo> &streams,
/** Run a benchmark over a given engine and corpus in streaming mode. */
static
void benchStreaming(void *context) {
ThreadContext *ctx = (ThreadContext *)context;
ThreadContext *ctx = reinterpret_cast<ThreadContext *>(context);
vector<StreamInfo> streams = prepStreamingData(ctx);
// Synchronization point
@ -622,7 +622,7 @@ void benchStreaming(void *context) {
static
void benchStreamingCompress(void *context) {
ThreadContext *ctx = (ThreadContext *)context;
ThreadContext *ctx = reinterpret_cast<ThreadContext *>(context);
vector<StreamInfo> streams = prepStreamingData(ctx);
// Synchronization point
@ -671,8 +671,8 @@ vector<VectoredInfo> prepVectorData(const ThreadContext *ctx) {
/** Run a benchmark over a given engine and corpus in vectored mode. */
static
void benchVectored(void *context) {
ThreadContext *ctx = (ThreadContext *)context;
ThreadContext *ctx = reinterpret_cast<ThreadContext *>(context);
vector<VectoredInfo> v_plans = prepVectorData(ctx);
// Synchronization point

View File

@ -179,7 +179,7 @@ TEST_P(FDRp, Simple) {
struct hs_scratch scratch;
scratch.fdr_conf = NULL;
fdrExec(fdr.get(), (const u8 *)data, sizeof(data), 0, decentCallback,
fdrExec(fdr.get(), reinterpret_cast<const u8 *>(data), sizeof(data), 0, decentCallback,
&scratch, HWLM_ALL_GROUPS);
ASSERT_EQ(3U, matches.size());
@ -204,7 +204,7 @@ TEST_P(FDRp, SimpleSingle) {
struct hs_scratch scratch;
scratch.fdr_conf = NULL;
fdrExec(fdr.get(), (const u8 *)data, sizeof(data) - 1 /* skip nul */, 0,
fdrExec(fdr.get(), reinterpret_cast<const u8 *>(data), sizeof(data) - 1 /* skip nul */, 0,
decentCallback, &scratch, HWLM_ALL_GROUPS);
ASSERT_EQ(4U, matches.size());
@ -258,7 +258,7 @@ TEST_P(FDRp, NoRepeat1) {
struct hs_scratch scratch;
scratch.fdr_conf = NULL;
fdrExec(fdr.get(), (const u8 *)data, sizeof(data) - 1 /* skip nul */, 0,
fdrExec(fdr.get(), reinterpret_cast<const u8 *>(data), sizeof(data) - 1 /* skip nul */, 0,
decentCallback, &scratch, HWLM_ALL_GROUPS);
ASSERT_EQ(1U, matches.size());
@ -282,7 +282,7 @@ TEST_P(FDRp, NoRepeat2) {
struct hs_scratch scratch;
scratch.fdr_conf = NULL;
fdrExec(fdr.get(), (const u8 *)data, sizeof(data) - 1 /* skip nul */, 0,
fdrExec(fdr.get(), reinterpret_cast<const u8 *>(data), sizeof(data) - 1 /* skip nul */, 0,
decentCallback, &scratch, HWLM_ALL_GROUPS);
ASSERT_EQ(3U, matches.size());
@ -307,7 +307,7 @@ TEST_P(FDRp, NoRepeat3) {
struct hs_scratch scratch;
scratch.fdr_conf = NULL;
fdrExec(fdr.get(), (const u8 *)data, sizeof(data) - 1 /* skip nul */, 0,
fdrExec(fdr.get(), reinterpret_cast<const u8 *>(data), sizeof(data) - 1 /* skip nul */, 0,
decentCallback, &scratch, HWLM_ALL_GROUPS);
ASSERT_EQ(1U, matches.size());
@ -352,7 +352,7 @@ TEST_P(FDRp, SmallStreaming) {
expected.push_back(match(1, 1));
expected.push_back(match(2, 1));
safeExecStreaming(fdr.get(), (const u8 *)"", 0, (const u8 *)"aaar", 4, 0,
safeExecStreaming(fdr.get(), reinterpret_cast<const u8 *>(""), 0, reinterpret_cast<const u8 *>("aaar"), 4, 0,
decentCallback, HWLM_ALL_GROUPS);
for (u32 i = 0; i < MIN(expected.size(), matches.size()); i++) {
EXPECT_EQ(expected[i], matches[i]);
@ -364,7 +364,7 @@ TEST_P(FDRp, SmallStreaming) {
expected.push_back(match(6, 1));
expected.push_back(match(8, 10));
safeExecStreaming(fdr.get(), (const u8 *)"aaar", 4, (const u8 *)"dvark", 5,
safeExecStreaming(fdr.get(), reinterpret_cast<const u8 *>("aaar"), 4, reinterpret_cast<const u8 *>("dvark"), 5,
0, decentCallback, HWLM_ALL_GROUPS);
for (u32 i = 0; i < MIN(expected.size(), matches.size()); i++) {
@ -394,8 +394,8 @@ TEST_P(FDRp, SmallStreaming2) {
expected.push_back(match(14,2));
expected.push_back(match(15,2));
safeExecStreaming(fdr.get(), (const u8 *)"foobar", 6,
(const u8 *)"aardvarkkk", 10, 0, decentCallback,
safeExecStreaming(fdr.get(), reinterpret_cast<const u8 *>("foobar"), 6,
reinterpret_cast<const u8 *>("aardvarkkk"), 10, 0, decentCallback,
HWLM_ALL_GROUPS);
for (u32 i = 0; i < MIN(expected.size(), matches.size()); i++) {
@ -427,14 +427,14 @@ TEST_P(FDRp, moveByteStream) {
// bugger up original
for (size_t i = 0 ; i < size; i++) {
((char *)fdrTable0.get())[i] = (i % 2) ? 0xCA : 0xFE;
(reinterpret_cast<char *>(fdrTable0.get()))[i] = (i % 2) ? 0xCA : 0xFE;
}
// check matches
struct hs_scratch scratch;
scratch.fdr_conf = NULL;
hwlm_error_t fdrStatus = fdrExec(fdrTable.get(), (const u8 *)data,
hwlm_error_t fdrStatus = fdrExec(fdrTable.get(), reinterpret_cast<const u8 *>(data),
data_len, 0, decentCallback, &scratch,
HWLM_ALL_GROUPS);
ASSERT_EQ(0, fdrStatus);
@ -463,8 +463,8 @@ TEST_P(FDRp, Stream1) {
// check matches
fdrStatus = safeExecStreaming(fdr.get(), (const u8 *)data1, data_len1,
(const u8 *)data2, data_len2, 0,
fdrStatus = safeExecStreaming(fdr.get(), reinterpret_cast<const u8 *>(data1), data_len1,
reinterpret_cast<const u8 *>(data2), data_len2, 0,
decentCallback, HWLM_ALL_GROUPS);
ASSERT_EQ(0, fdrStatus);
@ -509,7 +509,7 @@ TEST_P(FDRpp, AlignAndTooEarly) {
// allocate aligned buffer
auto dataBufAligned = shared_ptr<char>(
(char *)aligned_malloc_internal(data_len, buf_alignment),
reinterpret_cast<char *>(aligned_malloc_internal(data_len, buf_alignment)),
aligned_free_internal);
vector<hwlmLiteral> lits;
@ -535,7 +535,7 @@ TEST_P(FDRpp, AlignAndTooEarly) {
for (size_t j = 0; j <= litLen; j++) {
hwlm_error_t fdrStatus = fdrExec(fdr.get(),
(const u8 *)dataBufAligned.get() + i + j,
reinterpret_cast<const u8 *>(dataBufAligned.get()) + i + j,
4 * buf_alignment - j * 2, 0, decentCallback,
&scratch, HWLM_ALL_GROUPS);
ASSERT_EQ(0, fdrStatus);
@ -656,7 +656,7 @@ TEST_P(FDRpa, ShortWritings) {
const string &buf = bufs[bufIdx];
size_t bufLen = buf.size();
hwlm_error_t fdrStatus = fdrExec(fdr.get(), (const u8 *)buf.data(),
hwlm_error_t fdrStatus = fdrExec(fdr.get(), reinterpret_cast<const u8 *>(buf.data()),
bufLen, 0, decentCallback, &scratch, HWLM_ALL_GROUPS);
ASSERT_EQ(0, fdrStatus);
@ -710,8 +710,8 @@ TEST(FDR, FDRTermS) {
// check matches
fdrStatus = safeExecStreaming(fdr.get(), (const u8 *)data1, data_len1,
(const u8 *)data2, data_len2, 0,
fdrStatus = safeExecStreaming(fdr.get(), reinterpret_cast<const u8 *>(data1), data_len1,
reinterpret_cast<const u8 *>(data2), data_len2, 0,
decentCallbackT, HWLM_ALL_GROUPS);
ASSERT_EQ(HWLM_TERMINATED, fdrStatus);
@ -735,7 +735,7 @@ TEST(FDR, FDRTermB) {
struct hs_scratch scratch;
scratch.fdr_conf = NULL;
fdrStatus = fdrExec(fdr.get(), (const u8 *)data1, data_len1,
fdrStatus = fdrExec(fdr.get(), reinterpret_cast<const u8 *>(data1), data_len1,
0, decentCallbackT, &scratch, HWLM_ALL_GROUPS);
ASSERT_EQ(HWLM_TERMINATED, fdrStatus);

View File

@ -51,7 +51,7 @@ static const u32 MATCH_REPORT = 1024;
static
int onMatch(u64a, u64a, ReportID, void *ctx) {
unsigned *matches = (unsigned *)ctx;
unsigned *matches = reinterpret_cast<unsigned *>(ctx);
(*matches)++;
return MO_CONTINUE_MATCHING;
}
@ -100,7 +100,7 @@ protected:
q.state = full_state.get();
q.streamState = stream_state.get();
q.offset = 0;
q.buffer = (const u8 *)SCAN_DATA.c_str();
q.buffer = reinterpret_cast<const u8 *>(SCAN_DATA.c_str());
q.length = SCAN_DATA.size();
q.history = nullptr;
q.hlength = 0;
@ -341,7 +341,7 @@ TEST_P(LimExReverseTest, BlockExecReverse) {
ASSERT_TRUE(nfa.get() != nullptr);
u64a offset = 0;
const u8 *buf = (const u8 *)SCAN_DATA.c_str();
const u8 *buf = reinterpret_cast<const u8 *>(SCAN_DATA.c_str());
const size_t buflen = SCAN_DATA.size();
const u8 *hbuf = nullptr;
const size_t hlen = 0;
@ -394,7 +394,7 @@ protected:
q.state = full_state.get();
q.streamState = stream_state.get();
q.offset = 0;
q.buffer = (const u8 *)ZOMBIE_SCAN_DATA.c_str();
q.buffer = reinterpret_cast<const u8 *>(ZOMBIE_SCAN_DATA.c_str());
q.length = ZOMBIE_SCAN_DATA.length();
q.history = nullptr;
q.hlength = 0;

View File

@ -48,11 +48,11 @@ TEST(Shufti, BuildMask1) {
chars.set('a');
int ret = shuftiBuildMasks(chars, (u8 *)&lomask, (u8 *)&himask);
int ret = shuftiBuildMasks(chars, reinterpret_cast<u8 *>(&lomask), reinterpret_cast<u8 *>(&himask));
ASSERT_NE(-1, ret);
u8 *lo = (u8 *)&lomask;
u8 *hi = (u8 *)&himask;
u8 *lo = reinterpret_cast<u8 *>(&lomask);
u8 *hi = reinterpret_cast<u8 *>(&himask);
for (int i = 0; i < 16; i++) {
if (i == 'a' % 16) {
ASSERT_EQ(1, lo[i]);
@ -76,11 +76,11 @@ TEST(Shufti, BuildMask2) {
chars.set('a');
chars.set('B');
int ret = shuftiBuildMasks(chars, (u8 *)&lomask, (u8 *)&himask);
int ret = shuftiBuildMasks(chars, reinterpret_cast<u8 *>(&lomask), reinterpret_cast<u8 *>(&himask));
ASSERT_NE(-1, ret);
const u8 *lo = (u8 *)&lomask;
const u8 *hi = (u8 *)&himask;
const u8 *lo = reinterpret_cast<u8 *>(&lomask);
const u8 *hi = reinterpret_cast<u8 *>(&himask);
ASSERT_TRUE(lo['a' % 16] & hi['a' >> 4]);
ASSERT_TRUE(lo['B' % 16] & hi['B' >> 4]);
ASSERT_FALSE(lo['a' % 16] & hi['B' >> 4]);
@ -97,11 +97,11 @@ TEST(Shufti, BuildMask4) {
chars.set('A');
chars.set('b');
int ret = shuftiBuildMasks(chars, (u8 *)&lomask, (u8 *)&himask);
int ret = shuftiBuildMasks(chars, reinterpret_cast<u8 *>(&lomask), reinterpret_cast<u8 *>(&himask));
ASSERT_NE(-1, ret);
const u8 *lo = (u8 *)&lomask;
const u8 *hi = (u8 *)&himask;
const u8 *lo = reinterpret_cast<u8 *>(&lomask);
const u8 *hi = reinterpret_cast<u8 *>(&himask);
ASSERT_TRUE(lo['a' % 16] & hi['a' >> 4]);
ASSERT_TRUE(lo['A' % 16] & hi['A' >> 4]);
ASSERT_TRUE(lo['b' % 16] & hi['b' >> 4]);
@ -114,13 +114,13 @@ TEST(Shufti, ExecNoMatch1) {
CharReach chars;
chars.set('a');
int ret = shuftiBuildMasks(chars, (u8 *)&lo, (u8 *)&hi);
int ret = shuftiBuildMasks(chars, reinterpret_cast<u8 *>(&lo), reinterpret_cast<u8 *>(&hi));
ASSERT_NE(-1, ret);
char t1[] = "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb";
for (size_t i = 0; i < 32; i++) {
const u8 *rv = shuftiExec(lo, hi, (u8 *)t1 + i, (u8 *)t1 + strlen(t1));
const u8 *rv = shuftiExec(lo, hi, reinterpret_cast<u8 *>(t1) + i, reinterpret_cast<u8 *>(t1) + strlen(t1));
ASSERT_LE(((size_t)t1 + strlen(t1)) & ~0xf, (size_t)rv);
}
@ -133,13 +133,13 @@ TEST(Shufti, ExecNoMatch2) {
chars.set('a');
chars.set('B');
int ret = shuftiBuildMasks(chars, (u8 *)&lo, (u8 *)&hi);
int ret = shuftiBuildMasks(chars, reinterpret_cast<u8 *>(&lo), reinterpret_cast<u8 *>(&hi));
ASSERT_NE(-1, ret);
char t1[] = "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb";
for (size_t i = 0; i < 16; i++) {
const u8 *rv = shuftiExec(lo, hi, (u8 *)t1 + i, (u8 *)t1 + strlen(t1));
const u8 *rv = shuftiExec(lo, hi, reinterpret_cast<u8 *>(t1) + i, reinterpret_cast<u8 *>(t1) + strlen(t1));
ASSERT_LE(((size_t)t1 + strlen(t1)) & ~0xf, (size_t)rv);
}
@ -151,13 +151,13 @@ TEST(Shufti, ExecNoMatch3) {
CharReach chars;
chars.set('V'); /* V = 0x56, e = 0x65 */
int ret = shuftiBuildMasks(chars, (u8 *)&lo, (u8 *)&hi);
int ret = shuftiBuildMasks(chars, reinterpret_cast<u8 *>(&lo), reinterpret_cast<u8 *>(&hi));
ASSERT_NE(-1, ret);
char t1[] = "eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee";
for (size_t i = 0; i < 16; i++) {
const u8 *rv = shuftiExec(lo, hi, (u8 *)t1 + i, (u8 *)t1 + strlen(t1));
const u8 *rv = shuftiExec(lo, hi, reinterpret_cast<u8 *>(t1) + i, reinterpret_cast<u8 *>(t1) + strlen(t1));
ASSERT_LE(((size_t)t1 + strlen(t1)) & ~0xf, (size_t)rv);
}
@ -169,14 +169,14 @@ TEST(Shufti, ExecMatch1) {
CharReach chars;
chars.set('a');
int ret = shuftiBuildMasks(chars, (u8 *)&lo, (u8 *)&hi);
int ret = shuftiBuildMasks(chars, reinterpret_cast<u8 *>(&lo), reinterpret_cast<u8 *>(&hi));
ASSERT_NE(-1, ret);
/* 0123456789012345678901234567890 */
char t1[] = "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbabbbbbbbbbbbbbbabbbbbbbbbbbb";
for (size_t i = 0; i < 32; i++) {
const u8 *rv = shuftiExec(lo, hi, (u8 *)t1 + i, (u8 *)t1 + strlen(t1));
const u8 *rv = shuftiExec(lo, hi, reinterpret_cast<u8 *>(t1) + i, reinterpret_cast<u8 *>(t1) + strlen(t1));
ASSERT_EQ((size_t)t1 + 33, (size_t)rv);
}
@ -188,14 +188,14 @@ TEST(Shufti, ExecMatch2) {
CharReach chars;
chars.set('a');
int ret = shuftiBuildMasks(chars, (u8 *)&lo, (u8 *)&hi);
int ret = shuftiBuildMasks(chars, reinterpret_cast<u8 *>(&lo), reinterpret_cast<u8 *>(&hi));
ASSERT_NE(-1, ret);
/* 0123456789012345678901234567890 */
char t1[] = "bbbbbbbbbbbbbbbbbaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbabbbbbbbbbbbb";
for (size_t i = 0; i < 16; i++) {
const u8 *rv = shuftiExec(lo, hi, (u8 *)t1 + i, (u8 *)t1 + strlen(t1));
const u8 *rv = shuftiExec(lo, hi, reinterpret_cast<u8 *>(t1) + i, reinterpret_cast<u8 *>(t1) + strlen(t1));
ASSERT_EQ((size_t)t1 + 17, (size_t)rv);
}
@ -208,14 +208,14 @@ TEST(Shufti, ExecMatch3) {
chars.set('a');
chars.set('B');
int ret = shuftiBuildMasks(chars, (u8 *)&lo, (u8 *)&hi);
int ret = shuftiBuildMasks(chars, reinterpret_cast<u8 *>(&lo), reinterpret_cast<u8 *>(&hi));
ASSERT_NE(-1, ret);
/* 0123456789012345678901234567890 */
char t1[] = "bbbbbbbbbbbbbbbbbBaaaaaaaaaaaaaaabbbbbbbbbbbbbbbabbbbbbbbbbbb";
for (size_t i = 0; i < 16; i++) {
const u8 *rv = shuftiExec(lo, hi, (u8 *)t1 + i, (u8 *)t1 + strlen(t1));
const u8 *rv = shuftiExec(lo, hi, reinterpret_cast<u8 *>(t1) + i, reinterpret_cast<u8 *>(t1) + strlen(t1));
ASSERT_EQ((size_t)t1 + 17, (size_t)rv);
}
@ -230,7 +230,7 @@ TEST(Shufti, ExecMatch4) {
chars.set('A');
chars.set('c');
int ret = shuftiBuildMasks(chars, (u8 *)&lo, (u8 *)&hi);
int ret = shuftiBuildMasks(chars, reinterpret_cast<u8 *>(&lo), reinterpret_cast<u8 *>(&hi));
ASSERT_NE(-1, ret);
/* 0123456789012345678901234567890 */
@ -240,19 +240,19 @@ TEST(Shufti, ExecMatch4) {
char t4[] = "bbbbbbbbbbbbbbbbbaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbabbbbbbbbbbbb";
for (size_t i = 0; i < 16; i++) {
const u8 *rv = shuftiExec(lo, hi, (u8 *)t1 + i, (u8 *)t1 + strlen(t1));
const u8 *rv = shuftiExec(lo, hi, reinterpret_cast<u8 *>(t1) + i, reinterpret_cast<u8 *>(t1) + strlen(t1));
ASSERT_EQ((size_t)t1 + 17, (size_t)rv);
rv = shuftiExec(lo, hi, (u8 *)t2 + i, (u8 *)t2 + strlen(t1));
rv = shuftiExec(lo, hi, reinterpret_cast<u8 *>(t2) + i, reinterpret_cast<u8 *>(t2) + strlen(t1));
ASSERT_EQ((size_t)t2 + 17, (size_t)rv);
rv = shuftiExec(lo, hi, (u8 *)t3 + i, (u8 *)t3 + strlen(t3));
rv = shuftiExec(lo, hi, reinterpret_cast<u8 *>(t3) + i, reinterpret_cast<u8 *>(t3) + strlen(t3));
ASSERT_EQ((size_t)t3 + 17, (size_t)rv);
rv = shuftiExec(lo, hi, (u8 *)t4 + i, (u8 *)t4 + strlen(t4));
rv = shuftiExec(lo, hi, reinterpret_cast<u8 *>(t4) + i, reinterpret_cast<u8 *>(t4) + strlen(t4));
ASSERT_EQ((size_t)t4 + 17, (size_t)rv);
}
@ -264,14 +264,14 @@ TEST(Shufti, ExecMatch5) {
CharReach chars;
chars.set('a');
int ret = shuftiBuildMasks(chars, (u8 *)&lo, (u8 *)&hi);
int ret = shuftiBuildMasks(chars, reinterpret_cast<u8 *>(&lo), reinterpret_cast<u8 *>(&hi));
ASSERT_NE(-1, ret);
char t1[] = "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb";
for (size_t i = 0; i < 31; i++) {
t1[48 - i] = 'a';
const u8 *rv = shuftiExec(lo, hi, (u8 *)t1, (u8 *)t1 + strlen(t1));
const u8 *rv = shuftiExec(lo, hi, reinterpret_cast<u8 *>(t1), reinterpret_cast<u8 *>(t1) + strlen(t1));
ASSERT_EQ((size_t)&t1[48 - i], (size_t)rv);
}
@ -284,14 +284,14 @@ TEST(DoubleShufti, BuildMask1) {
lits.insert(make_pair('a', 'B'));
bool ret = shuftiBuildDoubleMasks(CharReach(), lits, (u8 *)&lo1m, (u8 *)&hi1m,
(u8 *)&lo2m, (u8 *)&hi2m);
bool ret = shuftiBuildDoubleMasks(CharReach(), lits, reinterpret_cast<u8 *>(&lo1m), reinterpret_cast<u8 *>(&hi1m),
reinterpret_cast<u8 *>(&lo2m), reinterpret_cast<u8 *>(&hi2m));
ASSERT_TRUE(ret);
u8 *lo1 = (u8 *)&lo1m;
u8 *lo2 = (u8 *)&lo2m;
u8 *hi1 = (u8 *)&hi1m;
u8 *hi2 = (u8 *)&hi2m;
u8 *lo1 = reinterpret_cast<u8 *>(&lo1m);
u8 *lo2 = reinterpret_cast<u8 *>(&lo2m);
u8 *hi1 = reinterpret_cast<u8 *>(&hi1m);
u8 *hi2 = reinterpret_cast<u8 *>(&hi2m);
for (int i = 0; i < 16; i++) {
if (i == 'a' % 16) {
ASSERT_EQ(254, lo1[i]);
@ -327,14 +327,14 @@ TEST(DoubleShufti, BuildMask2) {
lits.insert(make_pair('a','z'));
lits.insert(make_pair('B','z'));
bool ret = shuftiBuildDoubleMasks(CharReach(), lits, (u8 *)&lo1m, (u8 *)&hi1m,
(u8 *)&lo2m, (u8 *)&hi2m);
bool ret = shuftiBuildDoubleMasks(CharReach(), lits, reinterpret_cast<u8 *>(&lo1m), reinterpret_cast<u8 *>(&hi1m),
reinterpret_cast<u8 *>(&lo2m), reinterpret_cast<u8 *>(&hi2m));
ASSERT_TRUE(ret);
const u8 *lo1 = (u8 *)&lo1m;
const u8 *lo2 = (u8 *)&lo2m;
const u8 *hi1 = (u8 *)&hi1m;
const u8 *hi2 = (u8 *)&hi2m;
const u8 *lo1 = reinterpret_cast<u8 *>(&lo1m);
const u8 *lo2 = reinterpret_cast<u8 *>(&lo2m);
const u8 *hi1 = reinterpret_cast<u8 *>(&hi1m);
const u8 *hi2 = reinterpret_cast<u8 *>(&hi2m);
ASSERT_NE(0xff,
lo1['a' % 16] | hi1['a' >> 4] | lo2['z' % 16] | hi2['z' >> 4]);
ASSERT_NE(0xff,
@ -355,14 +355,14 @@ TEST(DoubleShufti, BuildMask4) {
lits.insert(make_pair('A','z'));
lits.insert(make_pair('b','z'));
bool ret = shuftiBuildDoubleMasks(CharReach(), lits, (u8 *)&lo1m, (u8 *)&hi1m,
(u8 *)&lo2m, (u8 *)&hi2m);
bool ret = shuftiBuildDoubleMasks(CharReach(), lits, reinterpret_cast<u8 *>(&lo1m), reinterpret_cast<u8 *>(&hi1m),
reinterpret_cast<u8 *>(&lo2m), reinterpret_cast<u8 *>(&hi2m));
ASSERT_TRUE(ret);
const u8 *lo1 = (u8 *)&lo1m;
const u8 *lo2 = (u8 *)&lo2m;
const u8 *hi1 = (u8 *)&hi1m;
const u8 *hi2 = (u8 *)&hi2m;
const u8 *lo1 = reinterpret_cast<u8 *>(&lo1m);
const u8 *lo2 = reinterpret_cast<u8 *>(&lo2m);
const u8 *hi1 = reinterpret_cast<u8 *>(&hi1m);
const u8 *hi2 = reinterpret_cast<u8 *>(&hi2m);
ASSERT_NE(0xff,
lo1['a' % 16] | hi1['a' >> 4] | lo2['z' % 16] | hi2['z' >> 4]);
ASSERT_NE(0xff,
@ -384,14 +384,14 @@ TEST(DoubleShufti, BuildMask5) {
CharReach bytes;
bytes.set('X');
bool ret = shuftiBuildDoubleMasks(bytes, lits, (u8 *)&lo1m, (u8 *)&hi1m,
(u8 *)&lo2m, (u8 *)&hi2m);
bool ret = shuftiBuildDoubleMasks(bytes, lits, reinterpret_cast<u8 *>(&lo1m), reinterpret_cast<u8 *>(&hi1m),
reinterpret_cast<u8 *>(&lo2m), reinterpret_cast<u8 *>(&hi2m));
ASSERT_TRUE(ret);
const u8 *lo1 = (u8 *)&lo1m;
const u8 *lo2 = (u8 *)&lo2m;
const u8 *hi1 = (u8 *)&hi1m;
const u8 *hi2 = (u8 *)&hi2m;
const u8 *lo1 = reinterpret_cast<u8 *>(&lo1m);
const u8 *lo2 = reinterpret_cast<u8 *>(&lo2m);
const u8 *hi1 = reinterpret_cast<u8 *>(&hi1m);
const u8 *hi2 = reinterpret_cast<u8 *>(&hi2m);
ASSERT_NE(0xff,
lo1['a' % 16] | hi1['a' >> 4] | lo2['z' % 16] | hi2['z' >> 4]);
ASSERT_EQ(0xff,
@ -422,14 +422,14 @@ TEST(DoubleShufti, BuildMask6) {
lits.insert(make_pair('A','x'));
lits.insert(make_pair('b','x'));
bool ret = shuftiBuildDoubleMasks(CharReach(), lits, (u8 *)&lo1m, (u8 *)&hi1m,
(u8 *)&lo2m, (u8 *)&hi2m);
bool ret = shuftiBuildDoubleMasks(CharReach(), lits, reinterpret_cast<u8 *>(&lo1m), reinterpret_cast<u8 *>(&hi1m),
reinterpret_cast<u8 *>(&lo2m), reinterpret_cast<u8 *>(&hi2m));
ASSERT_TRUE(ret);
const u8 *lo1 = (u8 *)&lo1m;
const u8 *lo2 = (u8 *)&lo2m;
const u8 *hi1 = (u8 *)&hi1m;
const u8 *hi2 = (u8 *)&hi2m;
const u8 *lo1 = reinterpret_cast<u8 *>(&lo1m);
const u8 *lo2 = reinterpret_cast<u8 *>(&lo2m);
const u8 *hi1 = reinterpret_cast<u8 *>(&hi1m);
const u8 *hi2 = reinterpret_cast<u8 *>(&hi2m);
ASSERT_NE(0xff,
lo1['a' % 16] | hi1['a' >> 4] | lo2['z' % 16] | hi2['z' >> 4]);
ASSERT_NE(0xff,
@ -474,8 +474,8 @@ TEST(DoubleShufti, BuildMask7) {
lits.insert(make_pair('u','v'));
lits.insert(make_pair('w','x'));
bool rv = shuftiBuildDoubleMasks(CharReach(), lits, (u8 *)&lo1m, (u8 *)&hi1m,
(u8 *)&lo2m, (u8 *)&hi2m);
bool rv = shuftiBuildDoubleMasks(CharReach(), lits, reinterpret_cast<u8 *>(&lo1m), reinterpret_cast<u8 *>(&hi1m),
reinterpret_cast<u8 *>(&lo2m), reinterpret_cast<u8 *>(&hi2m));
ASSERT_FALSE(rv);
}
@ -486,15 +486,15 @@ TEST(DoubleShufti, ExecNoMatch1) {
lits.insert(make_pair('a','b'));
bool ret = shuftiBuildDoubleMasks(CharReach(), lits, (u8 *)&lo1, (u8 *)&hi1,
(u8 *)&lo2, (u8 *)&hi2);
bool ret = shuftiBuildDoubleMasks(CharReach(), lits, reinterpret_cast<u8 *>(&lo1), reinterpret_cast<u8 *>(&hi1),
reinterpret_cast<u8 *>(&lo2), reinterpret_cast<u8 *>(&hi2));
ASSERT_TRUE(ret);
char t1[] = "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb";
for (size_t i = 0; i < 16; i++) {
const u8 *rv = shuftiDoubleExec(lo1, hi1, lo2, hi2,
(u8 *)t1 + i, (u8 *)t1 + strlen(t1));
reinterpret_cast<u8 *>(t1) + i, reinterpret_cast<u8 *>(t1) + strlen(t1));
ASSERT_LE(((size_t)t1 + strlen(t1)) & ~0xf, (size_t)rv);
}
@ -507,15 +507,15 @@ TEST(DoubleShufti, ExecNoMatch1b) {
lits.insert(make_pair('b','a'));
bool ret = shuftiBuildDoubleMasks(CharReach(), lits, (u8 *)&lo1, (u8 *)&hi1,
(u8 *)&lo2, (u8 *)&hi2);
bool ret = shuftiBuildDoubleMasks(CharReach(), lits, reinterpret_cast<u8 *>(&lo1), reinterpret_cast<u8 *>(&hi1),
reinterpret_cast<u8 *>(&lo2), reinterpret_cast<u8 *>(&hi2));
ASSERT_TRUE(ret);
char t1[] = "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb";
for (size_t i = 0; i < 16; i++) {
const u8 *rv = shuftiDoubleExec(lo1, hi1, lo2, hi2,
(u8 *)t1 + i, (u8 *)t1 + strlen(t1));
reinterpret_cast<u8 *>(t1) + i, reinterpret_cast<u8 *>(t1) + strlen(t1));
ASSERT_LE((size_t)t1 + i + 15, (size_t)rv);
}
@ -529,15 +529,15 @@ TEST(DoubleShufti, ExecNoMatch2) {
lits.insert(make_pair('a','b'));
lits.insert(make_pair('B','b'));
bool ret = shuftiBuildDoubleMasks(CharReach(), lits, (u8 *)&lo1, (u8 *)&hi1,
(u8 *)&lo2, (u8 *)&hi2);
bool ret = shuftiBuildDoubleMasks(CharReach(), lits, reinterpret_cast<u8 *>(&lo1), reinterpret_cast<u8 *>(&hi1),
reinterpret_cast<u8 *>(&lo2), reinterpret_cast<u8 *>(&hi2));
ASSERT_TRUE(ret);
char t1[] = "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb";
for (size_t i = 0; i < 16; i++) {
const u8 *rv = shuftiDoubleExec(lo1, hi1, lo2, hi2,
(u8 *)t1 + i, (u8 *)t1 + strlen(t1));
reinterpret_cast<u8 *>(t1) + i, reinterpret_cast<u8 *>(t1) + strlen(t1));
ASSERT_LE(((size_t)t1 + strlen(t1)) & ~0xf, (size_t)rv);
}
@ -551,15 +551,15 @@ TEST(DoubleShufti, ExecNoMatch2b) {
lits.insert(make_pair('b','a'));
lits.insert(make_pair('b','B'));
bool ret = shuftiBuildDoubleMasks(CharReach(), lits, (u8 *)&lo1, (u8 *)&hi1,
(u8 *)&lo2, (u8 *)&hi2);
bool ret = shuftiBuildDoubleMasks(CharReach(), lits, reinterpret_cast<u8 *>(&lo1), reinterpret_cast<u8 *>(&hi1),
reinterpret_cast<u8 *>(&lo2), reinterpret_cast<u8 *>(&hi2));
ASSERT_TRUE(ret);
char t1[] = "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb";
for (size_t i = 0; i < 16; i++) {
const u8 *rv = shuftiDoubleExec(lo1, hi1, lo2, hi2, (u8 *)t1 + i,
(u8 *)t1 + strlen(t1));
const u8 *rv = shuftiDoubleExec(lo1, hi1, lo2, hi2, reinterpret_cast<u8 *>(t1) + i,
reinterpret_cast<u8 *>(t1) + strlen(t1));
ASSERT_LE((size_t)t1 + i + 15, (size_t)rv);
}
@ -572,15 +572,15 @@ TEST(DoubleShufti, ExecNoMatch3) {
lits.insert(make_pair('V','e'));
bool ret = shuftiBuildDoubleMasks(CharReach(), lits, (u8 *)&lo1, (u8 *)&hi1,
(u8 *)&lo2, (u8 *)&hi2);
bool ret = shuftiBuildDoubleMasks(CharReach(), lits, reinterpret_cast<u8 *>(&lo1), reinterpret_cast<u8 *>(&hi1),
reinterpret_cast<u8 *>(&lo2), reinterpret_cast<u8 *>(&hi2));
ASSERT_TRUE(ret);
char t1[] = "eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee";
for (size_t i = 0; i < 16; i++) {
const u8 *rv = shuftiDoubleExec(lo1, hi1, lo2, hi2,
(u8 *)t1 + i, (u8 *)t1 + strlen(t1));
reinterpret_cast<u8 *>(t1) + i, reinterpret_cast<u8 *>(t1) + strlen(t1));
ASSERT_LE(((size_t)t1 + strlen(t1)) & ~0xf, (size_t)rv);
}
@ -593,15 +593,15 @@ TEST(DoubleShufti, ExecNoMatch3b) {
lits.insert(make_pair('e','V'));
bool ret = shuftiBuildDoubleMasks(CharReach(), lits, (u8 *)&lo1, (u8 *)&hi1,
(u8 *)&lo2, (u8 *)&hi2);
bool ret = shuftiBuildDoubleMasks(CharReach(), lits, reinterpret_cast<u8 *>(&lo1), reinterpret_cast<u8 *>(&hi1),
reinterpret_cast<u8 *>(&lo2), reinterpret_cast<u8 *>(&hi2));
ASSERT_TRUE(ret);
char t1[] = "eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee";
for (size_t i = 0; i < 16; i++) {
const u8 *rv = shuftiDoubleExec(lo1, hi1, lo2, hi2,
(u8 *)t1 + i, (u8 *)t1 + strlen(t1));
reinterpret_cast<u8 *>(t1) + i, reinterpret_cast<u8 *>(t1) + strlen(t1));
ASSERT_LE((size_t)t1 + i + 15, (size_t)rv);
}
@ -614,8 +614,8 @@ TEST(DoubleShufti, ExecMatchShort1) {
lits.insert(make_pair('a','b'));
bool ret = shuftiBuildDoubleMasks(CharReach(), lits, (u8 *)&lo1, (u8 *)&hi1,
(u8 *)&lo2, (u8 *)&hi2);
bool ret = shuftiBuildDoubleMasks(CharReach(), lits, reinterpret_cast<u8 *>(&lo1), reinterpret_cast<u8 *>(&hi1),
reinterpret_cast<u8 *>(&lo2), reinterpret_cast<u8 *>(&hi2));
ASSERT_TRUE(ret);
/* 0123456789012345678901234567890 */
@ -623,7 +623,7 @@ TEST(DoubleShufti, ExecMatchShort1) {
for (size_t i = 0; i < 16; i++) {
const u8 *rv = shuftiDoubleExec(lo1, hi1, lo2, hi2,
(u8 *)t1 + i, (u8 *)t1 + strlen(t1));
reinterpret_cast<u8 *>(t1) + i, reinterpret_cast<u8 *>(t1) + strlen(t1));
ASSERT_EQ((size_t)t1 + 17, (size_t)rv);
}
@ -636,8 +636,8 @@ TEST(DoubleShufti, ExecMatch1) {
lits.insert(make_pair('a','b'));
bool ret = shuftiBuildDoubleMasks(CharReach(), lits, (u8 *)&lo1, (u8 *)&hi1,
(u8 *)&lo2, (u8 *)&hi2);
bool ret = shuftiBuildDoubleMasks(CharReach(), lits, reinterpret_cast<u8 *>(&lo1), reinterpret_cast<u8 *>(&hi1),
reinterpret_cast<u8 *>(&lo2), reinterpret_cast<u8 *>(&hi2));
ASSERT_TRUE(ret);
/* 0123456789012345678901234567890 */
@ -645,7 +645,7 @@ TEST(DoubleShufti, ExecMatch1) {
for (size_t i = 0; i < 16; i++) {
const u8 *rv = shuftiDoubleExec(lo1, hi1, lo2, hi2,
(u8 *)t1 + i, (u8 *)t1 + strlen(t1));
reinterpret_cast<u8 *>(t1) + i, reinterpret_cast<u8 *>(t1) + strlen(t1));
ASSERT_EQ((size_t)t1 + 17, (size_t)rv);
}
@ -658,8 +658,8 @@ TEST(DoubleShufti, ExecMatch2) {
lits.insert(make_pair('a','a'));
bool ret = shuftiBuildDoubleMasks(CharReach(), lits, (u8 *)&lo1, (u8 *)&hi1,
(u8 *)&lo2, (u8 *)&hi2);
bool ret = shuftiBuildDoubleMasks(CharReach(), lits, reinterpret_cast<u8 *>(&lo1), reinterpret_cast<u8 *>(&hi1),
reinterpret_cast<u8 *>(&lo2), reinterpret_cast<u8 *>(&hi2));
ASSERT_TRUE(ret);
/* 0123456789012345678901234567890 */
@ -667,7 +667,7 @@ TEST(DoubleShufti, ExecMatch2) {
for (size_t i = 0; i < 16; i++) {
const u8 *rv = shuftiDoubleExec(lo1, hi1, lo2, hi2,
(u8 *)t1 + i, (u8 *)t1 + strlen(t1));
reinterpret_cast<u8 *>(t1) + i, reinterpret_cast<u8 *>(t1) + strlen(t1));
ASSERT_EQ((size_t)t1 + 17, (size_t)rv);
}
@ -681,8 +681,8 @@ TEST(DoubleShufti, ExecMatch3) {
lits.insert(make_pair('B','a'));
lits.insert(make_pair('a','a'));
bool ret = shuftiBuildDoubleMasks(CharReach(), lits, (u8 *)&lo1, (u8 *)&hi1,
(u8 *)&lo2, (u8 *)&hi2);
bool ret = shuftiBuildDoubleMasks(CharReach(), lits, reinterpret_cast<u8 *>(&lo1), reinterpret_cast<u8 *>(&hi1),
reinterpret_cast<u8 *>(&lo2), reinterpret_cast<u8 *>(&hi2));
ASSERT_TRUE(ret);
/* 0123456789012345678901234567890 */
@ -690,7 +690,7 @@ TEST(DoubleShufti, ExecMatch3) {
for (size_t i = 0; i < 16; i++) {
const u8 *rv = shuftiDoubleExec(lo1, hi1, lo2, hi2,
(u8 *)t1 + i, (u8 *)t1 + strlen(t1));
reinterpret_cast<u8 *>(t1) + i, reinterpret_cast<u8 *>(t1) + strlen(t1));
ASSERT_EQ((size_t)t1 + 17, (size_t)rv);
}
@ -706,8 +706,8 @@ TEST(DoubleShufti, ExecMatch4) {
lits.insert(make_pair('C','a'));
lits.insert(make_pair('c','a'));
bool ret = shuftiBuildDoubleMasks(CharReach(), lits, (u8 *)&lo1, (u8 *)&hi1,
(u8 *)&lo2, (u8 *)&hi2);
bool ret = shuftiBuildDoubleMasks(CharReach(), lits, reinterpret_cast<u8 *>(&lo1), reinterpret_cast<u8 *>(&hi1),
reinterpret_cast<u8 *>(&lo2), reinterpret_cast<u8 *>(&hi2));
ASSERT_TRUE(ret);
/* 0123456789012345678901234567890 */
@ -718,22 +718,22 @@ TEST(DoubleShufti, ExecMatch4) {
for (size_t i = 0; i < 16; i++) {
const u8 *rv = shuftiDoubleExec(lo1, hi1, lo2, hi2,
(u8 *)t1 + i, (u8 *)t1 + strlen(t1));
reinterpret_cast<u8 *>(t1) + i, reinterpret_cast<u8 *>(t1) + strlen(t1));
ASSERT_EQ((size_t)t1 + 17, (size_t)rv);
rv = shuftiDoubleExec(lo1, hi1, lo2, hi2,
(u8 *)t2 + i, (u8 *)t2 + strlen(t2));
reinterpret_cast<u8 *>(t2) + i, reinterpret_cast<u8 *>(t2) + strlen(t2));
ASSERT_EQ((size_t)t2 + 17, (size_t)rv);
rv = shuftiDoubleExec(lo1, hi1, lo2, hi2,
(u8 *)t3+ i, (u8 *)t3 + strlen(t3));
reinterpret_cast<u8 *>(t3)+ i, reinterpret_cast<u8 *>(t3) + strlen(t3));
ASSERT_EQ((size_t)t3 + 17, (size_t)rv);
rv = shuftiDoubleExec(lo1, hi1, lo2, hi2,
(u8 *)t4 + i, (u8 *)t4 + strlen(t4));
reinterpret_cast<u8 *>(t4) + i, reinterpret_cast<u8 *>(t4) + strlen(t4));
ASSERT_EQ((size_t)t4 + 17, (size_t)rv);
}
@ -749,8 +749,8 @@ TEST(DoubleShufti, ExecMatch4b) {
lits.insert(make_pair('a','C'));
lits.insert(make_pair('a','c'));
bool ret = shuftiBuildDoubleMasks(CharReach(), lits, (u8 *)&lo1, (u8 *)&hi1,
(u8 *)&lo2, (u8 *)&hi2);
bool ret = shuftiBuildDoubleMasks(CharReach(), lits, reinterpret_cast<u8 *>(&lo1), reinterpret_cast<u8 *>(&hi1),
reinterpret_cast<u8 *>(&lo2), reinterpret_cast<u8 *>(&hi2));
ASSERT_TRUE(ret);
/* 0123456789012345678901234567890 */
@ -761,22 +761,22 @@ TEST(DoubleShufti, ExecMatch4b) {
for (size_t i = 0; i < 16; i++) {
const u8 *rv = shuftiDoubleExec(lo1, hi1, lo2, hi2,
(u8 *)t1 + i, (u8 *)t1 + strlen(t1));
reinterpret_cast<u8 *>(t1) + i, reinterpret_cast<u8 *>(t1) + strlen(t1));
ASSERT_EQ((size_t)t1 + 17, (size_t)rv);
rv = shuftiDoubleExec(lo1, hi1, lo2, hi2,
(u8 *)t2 + i, (u8 *)t2 + strlen(t2));
reinterpret_cast<u8 *>(t2) + i, reinterpret_cast<u8 *>(t2) + strlen(t2));
ASSERT_EQ((size_t)t2 + 17, (size_t)rv);
rv = shuftiDoubleExec(lo1, hi1, lo2, hi2,
(u8 *)t3+ i, (u8 *)t3 + strlen(t3));
reinterpret_cast<u8 *>(t3)+ i, reinterpret_cast<u8 *>(t3) + strlen(t3));
ASSERT_EQ((size_t)t3 + 17, (size_t)rv);
rv = shuftiDoubleExec(lo1, hi1, lo2, hi2,
(u8 *)t4 + i, (u8 *)t4 + strlen(t4));
reinterpret_cast<u8 *>(t4) + i, reinterpret_cast<u8 *>(t4) + strlen(t4));
ASSERT_EQ((size_t)t4 + 17, (size_t)rv);
}
@ -789,8 +789,8 @@ TEST(DoubleShufti, ExecMatch5) {
lits.insert(make_pair('a','A'));
bool ret = shuftiBuildDoubleMasks(CharReach(), lits, (u8 *)&lo1, (u8 *)&hi1,
(u8 *)&lo2, (u8 *)&hi2);
bool ret = shuftiBuildDoubleMasks(CharReach(), lits, reinterpret_cast<u8 *>(&lo1), reinterpret_cast<u8 *>(&hi1),
reinterpret_cast<u8 *>(&lo2), reinterpret_cast<u8 *>(&hi2));
ASSERT_TRUE(ret);
char t1[] = "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb";
@ -799,7 +799,7 @@ TEST(DoubleShufti, ExecMatch5) {
t1[48 - i] = 'a';
t1[48 - i + 1] = 'A';
const u8 *rv = shuftiDoubleExec(lo1, hi1, lo2, hi2,
(u8 *)t1, (u8 *)t1 + strlen(t1));
reinterpret_cast<u8 *>(t1), reinterpret_cast<u8 *>(t1) + strlen(t1));
ASSERT_EQ((size_t)&t1[48 - i], (size_t)rv);
}
@ -814,8 +814,8 @@ TEST(DoubleShufti, ExecMatchMixed1) {
// just one one-byte literal
onebyte.set('a');
bool ret = shuftiBuildDoubleMasks(onebyte, twobyte, (u8 *)&lo1, (u8 *)&hi1,
(u8 *)&lo2, (u8 *)&hi2);
bool ret = shuftiBuildDoubleMasks(onebyte, twobyte, reinterpret_cast<u8 *>(&lo1), reinterpret_cast<u8 *>(&hi1),
reinterpret_cast<u8 *>(&lo2), reinterpret_cast<u8 *>(&hi2));
ASSERT_TRUE(ret);
char t1[] = "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb";
@ -823,7 +823,7 @@ TEST(DoubleShufti, ExecMatchMixed1) {
for (size_t i = 0; i < 31; i++) {
t1[48 - i] = 'a';
const u8 *rv = shuftiDoubleExec(lo1, hi1, lo2, hi2,
(u8 *)t1, (u8 *)t1 + strlen(t1));
reinterpret_cast<u8 *>(t1), reinterpret_cast<u8 *>(t1) + strlen(t1));
ASSERT_EQ((size_t)&t1[48 - i], (size_t)rv);
}
@ -839,8 +839,8 @@ TEST(DoubleShufti, ExecMatchMixed2) {
onebyte.set('a');
twobyte.insert(make_pair('x', 'y'));
bool ret = shuftiBuildDoubleMasks(onebyte, twobyte, (u8 *)&lo1, (u8 *)&hi1,
(u8 *)&lo2, (u8 *)&hi2);
bool ret = shuftiBuildDoubleMasks(onebyte, twobyte, reinterpret_cast<u8 *>(&lo1), reinterpret_cast<u8 *>(&hi1),
reinterpret_cast<u8 *>(&lo2), reinterpret_cast<u8 *>(&hi2));
ASSERT_TRUE(ret);
char t1[] = "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb";
@ -849,7 +849,7 @@ TEST(DoubleShufti, ExecMatchMixed2) {
for (size_t i = 0; i < 31; i++) {
t1[48 - i] = 'a';
const u8 *rv = shuftiDoubleExec(lo1, hi1, lo2, hi2,
(u8 *)t1, (u8 *)t1 + strlen(t1));
reinterpret_cast<u8 *>(t1), reinterpret_cast<u8 *>(t1) + strlen(t1));
ASSERT_EQ((size_t)&t1[48 - i], (size_t)rv);
}
@ -858,7 +858,7 @@ TEST(DoubleShufti, ExecMatchMixed2) {
t2[48 - i] = 'x';
t2[48 - i + 1] = 'y';
const u8 *rv = shuftiDoubleExec(lo1, hi1, lo2, hi2,
(u8 *)t2, (u8 *)t2 + strlen(t1));
reinterpret_cast<u8 *>(t2), reinterpret_cast<u8 *>(t2) + strlen(t1));
ASSERT_EQ((size_t)&t2[48 - i], (size_t)rv);
}
@ -874,8 +874,8 @@ TEST(DoubleShufti, ExecMatchMixed3) {
onebyte.set('a');
twobyte.insert(make_pair('x', 'y'));
bool ret = shuftiBuildDoubleMasks(onebyte, twobyte, (u8 *)&lo1, (u8 *)&hi1,
(u8 *)&lo2, (u8 *)&hi2);
bool ret = shuftiBuildDoubleMasks(onebyte, twobyte, reinterpret_cast<u8 *>(&lo1), reinterpret_cast<u8 *>(&hi1),
reinterpret_cast<u8 *>(&lo2), reinterpret_cast<u8 *>(&hi2));
ASSERT_TRUE(ret);
const int len = 420;
@ -887,7 +887,7 @@ TEST(DoubleShufti, ExecMatchMixed3) {
for (size_t i = 0; i < 400; i++) {
t1[len - i] = 'a';
const u8 *rv = shuftiDoubleExec(lo1, hi1, lo2, hi2,
(u8 *)t1, (u8 *)t1 + len);
reinterpret_cast<u8 *>(t1), reinterpret_cast<u8 *>(t1) + len);
ASSERT_EQ((size_t)&t1[len - i], (size_t)rv);
}
@ -897,9 +897,9 @@ TEST(DoubleShufti, ExecMatchMixed3) {
t2[len - i + 1] = 'y';
DEBUG_PRINTF("i = %ld\n", i);
const u8 *rv = shuftiDoubleExec(lo1, hi1, lo2, hi2,
(u8 *)t2, (u8 *)t2 + len);
reinterpret_cast<u8 *>(t2), reinterpret_cast<u8 *>(t2) + len);
ASSERT_EQ((const u8 *)&t2[len - i], rv);
ASSERT_EQ(reinterpret_cast<const u8 *>(&t2[len - i]), rv);
}
}
@ -909,7 +909,7 @@ TEST(ReverseShufti, ExecNoMatch1) {
CharReach chars;
chars.set('a');
int ret = shuftiBuildMasks(chars, (u8 *)&lo, (u8 *)&hi);
int ret = shuftiBuildMasks(chars, reinterpret_cast<u8 *>(&lo), reinterpret_cast<u8 *>(&hi));
ASSERT_NE(-1, ret);
char t[] = " bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb";
@ -917,8 +917,8 @@ TEST(ReverseShufti, ExecNoMatch1) {
size_t len = strlen(t1);
for (size_t i = 0; i < 16; i++) {
const u8 *rv = rshuftiExec(lo, hi, (u8 *)t1, (u8 *)t1 + len - i);
ASSERT_EQ((const u8 *)t, rv);
const u8 *rv = rshuftiExec(lo, hi, reinterpret_cast<u8 *>(t1), reinterpret_cast<u8 *>(t1) + len - i);
ASSERT_EQ(reinterpret_cast<const u8 *>(t), rv);
}
}
@ -929,7 +929,7 @@ TEST(ReverseShufti, ExecNoMatch2) {
chars.set('a');
chars.set('B');
int ret = shuftiBuildMasks(chars, (u8 *)&lo, (u8 *)&hi);
int ret = shuftiBuildMasks(chars, reinterpret_cast<u8 *>(&lo), reinterpret_cast<u8 *>(&hi));
ASSERT_NE(-1, ret);
char t[] = " bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb";
@ -937,8 +937,8 @@ TEST(ReverseShufti, ExecNoMatch2) {
size_t len = strlen(t1);
for (size_t i = 0; i < 16; i++) {
const u8 *rv = rshuftiExec(lo, hi, (u8 *)t1, (u8 *)t1 + len - i);
ASSERT_EQ((const u8 *)t, rv);
const u8 *rv = rshuftiExec(lo, hi, reinterpret_cast<u8 *>(t1), reinterpret_cast<u8 *>(t1) + len - i);
ASSERT_EQ(reinterpret_cast<const u8 *>(t), rv);
}
}
@ -948,7 +948,7 @@ TEST(ReverseShufti, ExecNoMatch3) {
CharReach chars;
chars.set('V'); /* V = 0x56, e = 0x65 */
int ret = shuftiBuildMasks(chars, (u8 *)&lo, (u8 *)&hi);
int ret = shuftiBuildMasks(chars, reinterpret_cast<u8 *>(&lo), reinterpret_cast<u8 *>(&hi));
ASSERT_NE(-1, ret);
char t[] = "eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee";
@ -956,8 +956,8 @@ TEST(ReverseShufti, ExecNoMatch3) {
size_t len = strlen(t1);
for (size_t i = 0; i < 16; i++) {
const u8 *rv = rshuftiExec(lo, hi, (u8 *)t1, (u8 *)t1 + len - i);
ASSERT_EQ((const u8 *)t, rv);
const u8 *rv = rshuftiExec(lo, hi, reinterpret_cast<u8 *>(t1), reinterpret_cast<u8 *>(t1) + len - i);
ASSERT_EQ(reinterpret_cast<const u8 *>(t), rv);
}
}
@ -967,7 +967,7 @@ TEST(ReverseShufti, ExecMatch1) {
CharReach chars;
chars.set('a');
int ret = shuftiBuildMasks(chars, (u8 *)&lo, (u8 *)&hi);
int ret = shuftiBuildMasks(chars, reinterpret_cast<u8 *>(&lo), reinterpret_cast<u8 *>(&hi));
ASSERT_NE(-1, ret);
/* 0123456789012345678901234567890 */
@ -975,10 +975,10 @@ TEST(ReverseShufti, ExecMatch1) {
size_t len = strlen(t1);
for (size_t i = 0; i < 16; i++) {
const u8 *rv = rshuftiExec(lo, hi, (u8 *)t1, (u8 *)t1 + len - i);
ASSERT_NE((const u8 *)t1 - 1, rv); // not found
const u8 *rv = rshuftiExec(lo, hi, reinterpret_cast<u8 *>(t1), reinterpret_cast<u8 *>(t1) + len - i);
ASSERT_NE(reinterpret_cast<const u8 *>(t1) - 1, rv); // not found
EXPECT_EQ('a', (char)*rv);
ASSERT_EQ((const u8 *)t1 + 17, rv);
ASSERT_EQ(reinterpret_cast<const u8 *>(t1) + 17, rv);
}
}
@ -988,7 +988,7 @@ TEST(ReverseShufti, ExecMatch2) {
CharReach chars;
chars.set('a');
int ret = shuftiBuildMasks(chars, (u8 *)&lo, (u8 *)&hi);
int ret = shuftiBuildMasks(chars, reinterpret_cast<u8 *>(&lo), reinterpret_cast<u8 *>(&hi));
ASSERT_NE(-1, ret);
/* 0123456789012345678901234567890 */
@ -996,10 +996,10 @@ TEST(ReverseShufti, ExecMatch2) {
size_t len = strlen(t1);
for (size_t i = 0; i < 16; i++) {
const u8 *rv = rshuftiExec(lo, hi, (u8 *)t1, (u8 *)t1 + len - i);
ASSERT_NE((const u8 *)t1 - 1, rv); // not found
const u8 *rv = rshuftiExec(lo, hi, reinterpret_cast<u8 *>(t1), reinterpret_cast<u8 *>(t1) + len - i);
ASSERT_NE(reinterpret_cast<const u8 *>(t1) - 1, rv); // not found
EXPECT_EQ('a', (char)*rv);
ASSERT_EQ((const u8 *)t1 + 32, rv);
ASSERT_EQ(reinterpret_cast<const u8 *>(t1) + 32, rv);
}
}
@ -1010,7 +1010,7 @@ TEST(ReverseShufti, ExecMatch3) {
chars.set('a');
chars.set('B');
int ret = shuftiBuildMasks(chars, (u8 *)&lo, (u8 *)&hi);
int ret = shuftiBuildMasks(chars, reinterpret_cast<u8 *>(&lo), reinterpret_cast<u8 *>(&hi));
ASSERT_NE(-1, ret);
/* 0123456789012345678901234567890 */
@ -1018,20 +1018,20 @@ TEST(ReverseShufti, ExecMatch3) {
size_t len = strlen(t1);
for (size_t i = 0; i < 16; i++) {
const u8 *rv = rshuftiExec(lo, hi, (u8 *)t1, (u8 *)t1 + len - i);
ASSERT_NE((const u8 *)t1 - 1, rv); // not found
const u8 *rv = rshuftiExec(lo, hi, reinterpret_cast<u8 *>(t1), reinterpret_cast<u8 *>(t1) + len - i);
ASSERT_NE(reinterpret_cast<const u8 *>(t1) - 1, rv); // not found
EXPECT_EQ('B', (char)*rv);
ASSERT_EQ((const u8 *)t1 + 32, rv);
ASSERT_EQ(reinterpret_cast<const u8 *>(t1) + 32, rv);
}
// check that we match the 'a' bytes as well.
ASSERT_EQ('B', t1[32]);
t1[32] = 'b';
for (size_t i = 0; i < 16; i++) {
const u8 *rv = rshuftiExec(lo, hi, (u8 *)t1, (u8 *)t1 + len - i);
ASSERT_NE((const u8 *)t1 - 1, rv); // not found
const u8 *rv = rshuftiExec(lo, hi, reinterpret_cast<u8 *>(t1), reinterpret_cast<u8 *>(t1) + len - i);
ASSERT_NE(reinterpret_cast<const u8 *>(t1) - 1, rv); // not found
EXPECT_EQ('a', (char)*rv);
ASSERT_EQ((const u8 *)t1 + 31, rv);
ASSERT_EQ(reinterpret_cast<const u8 *>(t1) + 31, rv);
}
}
@ -1044,7 +1044,7 @@ TEST(ReverseShufti, ExecMatch4) {
chars.set('A');
chars.set('c');
int ret = shuftiBuildMasks(chars, (u8 *)&lo, (u8 *)&hi);
int ret = shuftiBuildMasks(chars, reinterpret_cast<u8 *>(&lo), reinterpret_cast<u8 *>(&hi));
ASSERT_NE(-1, ret);
/* 0123456789012345678901234567890 */
@ -1055,21 +1055,21 @@ TEST(ReverseShufti, ExecMatch4) {
size_t len = strlen(t1);
for (size_t i = 0; i < 16; i++) {
const u8 *rv = rshuftiExec(lo, hi, (u8 *)t1, (u8 *)t1 + len - i);
const u8 *rv = rshuftiExec(lo, hi, reinterpret_cast<u8 *>(t1), reinterpret_cast<u8 *>(t1) + len - i);
EXPECT_EQ('A', (char)*rv);
ASSERT_EQ((const u8 *)t1 + 32, rv);
ASSERT_EQ(reinterpret_cast<const u8 *>(t1) + 32, rv);
rv = rshuftiExec(lo, hi, (u8 *)t2, (u8 *)t2 + len - i);
rv = rshuftiExec(lo, hi, reinterpret_cast<u8 *>(t2), reinterpret_cast<u8 *>(t2) + len - i);
EXPECT_EQ('C', (char)*rv);
ASSERT_EQ((const u8 *)t2 + 32, rv);
ASSERT_EQ(reinterpret_cast<const u8 *>(t2) + 32, rv);
rv = rshuftiExec(lo, hi, (u8 *)t3, (u8 *)t3 + len - i);
rv = rshuftiExec(lo, hi, reinterpret_cast<u8 *>(t3), reinterpret_cast<u8 *>(t3) + len - i);
EXPECT_EQ('c', (char)*rv);
ASSERT_EQ((const u8 *)t3 + 32, rv);
ASSERT_EQ(reinterpret_cast<const u8 *>(t3) + 32, rv);
rv = rshuftiExec(lo, hi, (u8 *)t4, (u8 *)t4 + len - i);
rv = rshuftiExec(lo, hi, reinterpret_cast<u8 *>(t4), reinterpret_cast<u8 *>(t4) + len - i);
EXPECT_EQ('a', (char)*rv);
ASSERT_EQ((const u8 *)t4 + 32, rv);
ASSERT_EQ(reinterpret_cast<const u8 *>(t4) + 32, rv);
}
}
@ -1079,7 +1079,7 @@ TEST(ReverseShufti, ExecMatch5) {
CharReach chars;
chars.set('a');
int ret = shuftiBuildMasks(chars, (u8 *)&lo, (u8 *)&hi);
int ret = shuftiBuildMasks(chars, reinterpret_cast<u8 *>(&lo), reinterpret_cast<u8 *>(&hi));
ASSERT_NE(-1, ret);
char t1[] = "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb";
@ -1087,9 +1087,9 @@ TEST(ReverseShufti, ExecMatch5) {
for (size_t i = 0; i < len; i++) {
t1[i] = 'a';
const u8 *rv = rshuftiExec(lo, hi, (u8 *)t1, (u8 *)t1 + len);
const u8 *rv = rshuftiExec(lo, hi, reinterpret_cast<u8 *>(t1), reinterpret_cast<u8 *>(t1) + len);
ASSERT_EQ((const u8 *)t1 + i, rv);
ASSERT_EQ(reinterpret_cast<const u8 *>(t1) + i, rv);
}
}
@ -1099,7 +1099,7 @@ TEST(ReverseShufti, ExecMatch6) {
CharReach chars;
chars.set('a');
int ret = shuftiBuildMasks(chars, (u8 *)&lo, (u8 *)&hi);
int ret = shuftiBuildMasks(chars, reinterpret_cast<u8 *>(&lo), reinterpret_cast<u8 *>(&hi));
ASSERT_NE(-1, ret);
const size_t len = 256;
@ -1109,8 +1109,8 @@ TEST(ReverseShufti, ExecMatch6) {
for (size_t i = 0; i < len; i++) {
t1[i] = 'a';
DEBUG_PRINTF("i=%ld\n", i);
const u8 *rv = rshuftiExec(lo, hi, (u8 *)t1, (u8 *)t1 + len);
const u8 *rv = rshuftiExec(lo, hi, reinterpret_cast<u8 *>(t1), reinterpret_cast<u8 *>(t1) + len);
ASSERT_EQ((const u8 *)t1 + i, rv);
ASSERT_EQ(reinterpret_cast<const u8 *>(t1) + i, rv);
}
}

View File

@ -45,9 +45,9 @@ TEST(Truffle, CompileDot) {
chars.setall();
truffleBuildMasks(chars, (u8 *)&mask1, (u8 *)&mask2);
truffleBuildMasks(chars, reinterpret_cast<u8 *>(&mask1), reinterpret_cast<u8 *>(&mask2));
CharReach out = truffle2cr((u8 *)&mask1, (u8 *)&mask2);
CharReach out = truffle2cr(reinterpret_cast<u8 *>(&mask1), reinterpret_cast<u8 *>(&mask2));
ASSERT_EQ(out, chars);
@ -64,8 +64,8 @@ TEST(Truffle, CompileChars) {
mask2 = zeroes128();
chars.clear();
chars.set((u8)c);
truffleBuildMasks(chars, (u8 *)&mask1, (u8 *)&mask2);
CharReach out = truffle2cr((u8 *)&mask1, (u8 *)&mask2);
truffleBuildMasks(chars, reinterpret_cast<u8 *>(&mask1), reinterpret_cast<u8 *>(&mask2));
CharReach out = truffle2cr(reinterpret_cast<u8 *>(&mask1), reinterpret_cast<u8 *>(&mask2));
ASSERT_EQ(out, chars);
}
@ -74,8 +74,8 @@ TEST(Truffle, CompileChars) {
mask1 = zeroes128();
mask2 = zeroes128();
chars.set((u8)c);
truffleBuildMasks(chars, (u8 *)&mask1, (u8 *)&mask2);
CharReach out = truffle2cr((u8 *)&mask1, (u8 *)&mask2);
truffleBuildMasks(chars, reinterpret_cast<u8 *>(&mask1), reinterpret_cast<u8 *>(&mask2));
CharReach out = truffle2cr(reinterpret_cast<u8 *>(&mask1), reinterpret_cast<u8 *>(&mask2));
ASSERT_EQ(out, chars);
}
@ -84,8 +84,8 @@ TEST(Truffle, CompileChars) {
mask1 = zeroes128();
mask2 = zeroes128();
chars.clear((u8)c);
truffleBuildMasks(chars, (u8 *)&mask1, (u8 *)&mask2);
CharReach out = truffle2cr((u8 *)&mask1, (u8 *)&mask2);
truffleBuildMasks(chars, reinterpret_cast<u8 *>(&mask1), reinterpret_cast<u8 *>(&mask2));
CharReach out = truffle2cr(reinterpret_cast<u8 *>(&mask1), reinterpret_cast<u8 *>(&mask2));
ASSERT_EQ(out, chars);
}
@ -100,12 +100,12 @@ TEST(Truffle, ExecNoMatch1) {
chars.set('a');
truffleBuildMasks(chars, (u8 *)&mask1, (u8 *)&mask2);
truffleBuildMasks(chars, reinterpret_cast<u8 *>(&mask1), reinterpret_cast<u8 *>(&mask2));
char t1[] = "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\xff";
for (size_t i = 0; i < 16; i++) {
const u8 *rv = truffleExec(mask1, mask2, (u8 *)t1 + i, (u8 *)t1 + strlen(t1));
const u8 *rv = truffleExec(mask1, mask2, reinterpret_cast<u8 *>(t1) + i, reinterpret_cast<u8 *>(t1) + strlen(t1));
ASSERT_EQ((size_t)t1 + strlen(t1), (size_t)rv);
}
@ -119,12 +119,12 @@ TEST(Truffle, ExecNoMatch2) {
chars.set('a');
chars.set('B');
truffleBuildMasks(chars, (u8 *)&mask1, (u8 *)&mask2);
truffleBuildMasks(chars, reinterpret_cast<u8 *>(&mask1), reinterpret_cast<u8 *>(&mask2));
char t1[] = "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb";
for (size_t i = 0; i < 16; i++) {
const u8 *rv = truffleExec(mask1, mask2, (u8 *)t1 + i, (u8 *)t1 + strlen(t1));
const u8 *rv = truffleExec(mask1, mask2, reinterpret_cast<u8 *>(t1) + i, reinterpret_cast<u8 *>(t1) + strlen(t1));
ASSERT_EQ((size_t)t1 + strlen(t1), (size_t)rv);
}
@ -137,12 +137,12 @@ TEST(Truffle, ExecNoMatch3) {
chars.set('V'); /* V = 0x56, e = 0x65 */
truffleBuildMasks(chars, (u8 *)&mask1, (u8 *)&mask2);
truffleBuildMasks(chars, reinterpret_cast<u8 *>(&mask1), reinterpret_cast<u8 *>(&mask2));
char t1[] = "eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee";
for (size_t i = 0; i < 16; i++) {
const u8 *rv = truffleExec(mask1, mask2, (u8 *)t1 + i, (u8 *)t1 + strlen(t1));
const u8 *rv = truffleExec(mask1, mask2, reinterpret_cast<u8 *>(t1) + i, reinterpret_cast<u8 *>(t1) + strlen(t1));
ASSERT_EQ((size_t)t1 + strlen(t1), (size_t)rv);
}
@ -154,11 +154,11 @@ TEST(Truffle, ExecMiniMatch0) {
CharReach chars;
chars.set('a');
truffleBuildMasks(chars, (u8 *)&lo, (u8 *)&hi);
truffleBuildMasks(chars, reinterpret_cast<u8 *>(&lo), reinterpret_cast<u8 *>(&hi));
char t1[] = "a";
const u8 *rv = truffleExec(lo, hi, (u8 *)t1, (u8 *)t1 + strlen(t1));
const u8 *rv = truffleExec(lo, hi, reinterpret_cast<u8 *>(t1), reinterpret_cast<u8 *>(t1) + strlen(t1));
ASSERT_EQ((size_t)t1, (size_t)rv);
}
@ -169,11 +169,11 @@ TEST(Truffle, ExecMiniMatch1) {
CharReach chars;
chars.set('a');
truffleBuildMasks(chars, (u8 *)&lo, (u8 *)&hi);
truffleBuildMasks(chars, reinterpret_cast<u8 *>(&lo), reinterpret_cast<u8 *>(&hi));
char t1[] = "bbbbbbbabbb";
const u8 *rv = truffleExec(lo, hi, (u8 *)t1, (u8 *)t1 + strlen(t1));
const u8 *rv = truffleExec(lo, hi, reinterpret_cast<u8 *>(t1), reinterpret_cast<u8 *>(t1) + strlen(t1));
ASSERT_EQ((size_t)t1 + 7, (size_t)rv);
}
@ -184,11 +184,11 @@ TEST(Truffle, ExecMiniMatch2) {
CharReach chars;
chars.set(0);
truffleBuildMasks(chars, (u8 *)&lo, (u8 *)&hi);
truffleBuildMasks(chars, reinterpret_cast<u8 *>(&lo), reinterpret_cast<u8 *>(&hi));
char t1[] = "bbbbbbb\0bbb";
const u8 *rv = truffleExec(lo, hi, (u8 *)t1, (u8 *)t1 + 11);
const u8 *rv = truffleExec(lo, hi, reinterpret_cast<u8 *>(t1), reinterpret_cast<u8 *>(t1) + 11);
ASSERT_EQ((size_t)t1 + 7, (size_t)rv);
}
@ -199,11 +199,11 @@ TEST(Truffle, ExecMiniMatch3) {
CharReach chars;
chars.set('a');
truffleBuildMasks(chars, (u8 *)&lo, (u8 *)&hi);
truffleBuildMasks(chars, reinterpret_cast<u8 *>(&lo), reinterpret_cast<u8 *>(&hi));
char t1[] = "\0\0\0\0\0\0\0a\0\0\0";
const u8 *rv = truffleExec(lo, hi, (u8 *)t1, (u8 *)t1 + 11);
const u8 *rv = truffleExec(lo, hi, reinterpret_cast<u8 *>(t1), reinterpret_cast<u8 *>(t1) + 11);
ASSERT_EQ((size_t)t1 + 7, (size_t)rv);
}
@ -214,14 +214,14 @@ TEST(Truffle, ExecMatchBig) {
CharReach chars;
chars.set('a');
truffleBuildMasks(chars, (u8 *)&lo, (u8 *)&hi);
truffleBuildMasks(chars, reinterpret_cast<u8 *>(&lo), reinterpret_cast<u8 *>(&hi));
std::array<u8, 400> t1;
t1.fill('b');
t1[120] = 'a';
for (size_t i = 0; i < 16; i++) {
const u8 *rv = truffleExec(lo, hi, (u8 *)t1.data() + i, (u8 *)t1.data() + 399);
const u8 *rv = truffleExec(lo, hi, reinterpret_cast<u8 *>(t1.data()) + i, reinterpret_cast<u8 *>(t1.data()) + 399);
ASSERT_LE(((size_t)t1.data() + 120) & ~0xf, (size_t)rv);
}
@ -234,13 +234,13 @@ TEST(Truffle, ExecMatch1) {
chars.set('a');
truffleBuildMasks(chars, (u8 *)&mask1, (u8 *)&mask2);
truffleBuildMasks(chars, reinterpret_cast<u8 *>(&mask1), reinterpret_cast<u8 *>(&mask2));
/* 0123456789012345678901234567890 */
char t1[] = "bbbbbbbbbbbbbbbbbabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbabbbbbbbbbbbb";
for (size_t i = 0; i < 16; i++) {
const u8 *rv = truffleExec(mask1, mask2, (u8 *)t1 + i, (u8 *)t1 + strlen(t1));
const u8 *rv = truffleExec(mask1, mask2, reinterpret_cast<u8 *>(t1) + i, reinterpret_cast<u8 *>(t1) + strlen(t1));
ASSERT_EQ((size_t)t1 + 17, (size_t)rv);
}
@ -253,13 +253,13 @@ TEST(Truffle, ExecMatch2) {
chars.set('a');
truffleBuildMasks(chars, (u8 *)&mask1, (u8 *)&mask2);
truffleBuildMasks(chars, reinterpret_cast<u8 *>(&mask1), reinterpret_cast<u8 *>(&mask2));
/* 0123456789012345678901234567890 */
char t1[] = "bbbbbbbbbbbbbbbbbaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbabbbbbbbbbbbb";
for (size_t i = 0; i < 16; i++) {
const u8 *rv = truffleExec(mask1, mask2, (u8 *)t1 + i, (u8 *)t1 + strlen(t1));
const u8 *rv = truffleExec(mask1, mask2, reinterpret_cast<u8 *>(t1) + i, reinterpret_cast<u8 *>(t1) + strlen(t1));
ASSERT_EQ((size_t)t1 + 17, (size_t)rv);
}
@ -273,13 +273,13 @@ TEST(Truffle, ExecMatch3) {
chars.set('a');
chars.set('B');
truffleBuildMasks(chars, (u8 *)&mask1, (u8 *)&mask2);
truffleBuildMasks(chars, reinterpret_cast<u8 *>(&mask1), reinterpret_cast<u8 *>(&mask2));
/* 0123456789012345678901234567890 */
char t1[] = "bbbbbbbbbbbbbbbbbBaaaaaaaaaaaaaaabbbbbbbbbbbbbbbabbbbbbbbbbbb";
for (size_t i = 0; i < 16; i++) {
const u8 *rv = truffleExec(mask1, mask2, (u8 *)t1 + i, (u8 *)t1 + strlen(t1));
const u8 *rv = truffleExec(mask1, mask2, reinterpret_cast<u8 *>(t1) + i, reinterpret_cast<u8 *>(t1) + strlen(t1));
ASSERT_EQ((size_t)t1 + 17, (size_t)rv);
}
@ -295,7 +295,7 @@ TEST(Truffle, ExecMatch4) {
chars.set('A');
chars.set('c');
truffleBuildMasks(chars, (u8 *)&mask1, (u8 *)&mask2);
truffleBuildMasks(chars, reinterpret_cast<u8 *>(&mask1), reinterpret_cast<u8 *>(&mask2));
/* 0123456789012345678901234567890 */
char t1[] = "bbbbbbbbbbbbbbbbbAaaaaaaaaaaaaaaabbbbbbbbbbbbbbbabbbbbbbbbbbb";
@ -304,19 +304,19 @@ TEST(Truffle, ExecMatch4) {
char t4[] = "bbbbbbbbbbbbbbbbbaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbabbbbbbbbbbbb";
for (size_t i = 0; i < 16; i++) {
const u8 *rv = truffleExec(mask1, mask2, (u8 *)t1 + i, (u8 *)t1 + strlen(t1));
const u8 *rv = truffleExec(mask1, mask2, reinterpret_cast<u8 *>(t1) + i, reinterpret_cast<u8 *>(t1) + strlen(t1));
ASSERT_EQ((size_t)t1 + 17, (size_t)rv);
rv = truffleExec(mask1, mask2, (u8 *)t2 + i, (u8 *)t2 + strlen(t1));
rv = truffleExec(mask1, mask2, reinterpret_cast<u8 *>(t2) + i, reinterpret_cast<u8 *>(t2) + strlen(t1));
ASSERT_EQ((size_t)t2 + 17, (size_t)rv);
rv = truffleExec(mask1, mask2, (u8 *)t3 + i, (u8 *)t3 + strlen(t3));
rv = truffleExec(mask1, mask2, reinterpret_cast<u8 *>(t3) + i, reinterpret_cast<u8 *>(t3) + strlen(t3));
ASSERT_EQ((size_t)t3 + 17, (size_t)rv);
rv = truffleExec(mask1, mask2, (u8 *)t4 + i, (u8 *)t4 + strlen(t4));
rv = truffleExec(mask1, mask2, reinterpret_cast<u8 *>(t4) + i, reinterpret_cast<u8 *>(t4) + strlen(t4));
ASSERT_EQ((size_t)t4 + 17, (size_t)rv);
}
@ -329,13 +329,13 @@ TEST(Truffle, ExecMatch5) {
chars.set('a');
truffleBuildMasks(chars, (u8 *)&mask1, (u8 *)&mask2);
truffleBuildMasks(chars, reinterpret_cast<u8 *>(&mask1), reinterpret_cast<u8 *>(&mask2));
char t1[] = "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb";
for (size_t i = 0; i < 31; i++) {
t1[48 - i] = 'a';
const u8 *rv = truffleExec(mask1, mask2, (u8 *)t1, (u8 *)t1 + strlen(t1));
const u8 *rv = truffleExec(mask1, mask2, reinterpret_cast<u8 *>(t1), reinterpret_cast<u8 *>(t1) + strlen(t1));
ASSERT_EQ((size_t)&t1[48 - i], (size_t)rv);
}
@ -349,14 +349,14 @@ TEST(Truffle, ExecMatch6) {
// [0-Z] - includes some graph chars
chars.setRange('0', 'Z');
truffleBuildMasks(chars, (u8 *)&mask1, (u8 *)&mask2);
truffleBuildMasks(chars, reinterpret_cast<u8 *>(&mask1), reinterpret_cast<u8 *>(&mask2));
std::array<u8, 128> t1;
t1.fill('*'); // it's full of stars!
for (u8 c = '0'; c <= 'Z'; c++) {
t1[17] = c;
const u8 *rv = truffleExec(mask1, mask2, (u8 *)t1.data(), (u8 *)t1.data() + 128);
const u8 *rv = truffleExec(mask1, mask2, reinterpret_cast<u8 *>(t1.data()), reinterpret_cast<u8 *>(t1.data()) + 128);
ASSERT_EQ((size_t)t1.data() + 17, (size_t)rv);
}
@ -370,14 +370,14 @@ TEST(Truffle, ExecMatch7) {
// hi bits
chars.setRange(127, 255);
truffleBuildMasks(chars, (u8 *)&mask1, (u8 *)&mask2);
truffleBuildMasks(chars, reinterpret_cast<u8 *>(&mask1), reinterpret_cast<u8 *>(&mask2));
std::array<u8, 128> t1;
t1.fill('*'); // it's full of stars!
for (unsigned int c = 127; c <= 255; c++) {
t1[40] = (u8)c;
const u8 *rv = truffleExec(mask1, mask2, (u8 *)t1.data(), (u8 *)t1.data() + 128);
const u8 *rv = truffleExec(mask1, mask2, reinterpret_cast<u8 *>(t1.data()), reinterpret_cast<u8 *>(t1.data()) + 128);
ASSERT_EQ((size_t)t1.data() + 40, (size_t)rv);
}
@ -389,15 +389,15 @@ TEST(ReverseTruffle, ExecNoMatch1) {
CharReach chars;
chars.set('a');
truffleBuildMasks(chars, (u8 *)&mask1, (u8 *)&mask2);
truffleBuildMasks(chars, reinterpret_cast<u8 *>(&mask1), reinterpret_cast<u8 *>(&mask2));
char t[] = " bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb";
char *t1 = t + 1;
size_t len = strlen(t1);
for (size_t i = 0; i < 16; i++) {
const u8 *rv = rtruffleExec(mask1, mask2, (u8 *)t1, (u8 *)t1 + len - i);
ASSERT_EQ((const u8 *)t, rv);
const u8 *rv = rtruffleExec(mask1, mask2, reinterpret_cast<u8 *>(t1), reinterpret_cast<u8 *>(t1) + len - i);
ASSERT_EQ(reinterpret_cast<const u8 *>(t), rv);
}
}
@ -409,15 +409,15 @@ TEST(ReverseTruffle, ExecNoMatch2) {
chars.set('a');
chars.set('B');
truffleBuildMasks(chars, (u8 *)&mask1, (u8 *)&mask2);
truffleBuildMasks(chars, reinterpret_cast<u8 *>(&mask1), reinterpret_cast<u8 *>(&mask2));
char t[] = " bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb";
char *t1 = t + 1;
size_t len = strlen(t1);
for (size_t i = 0; i < 16; i++) {
const u8 *rv = rtruffleExec(mask1, mask2, (u8 *)t1, (u8 *)t1 + len - i);
ASSERT_EQ((const u8 *)t, rv);
const u8 *rv = rtruffleExec(mask1, mask2, reinterpret_cast<u8 *>(t1), reinterpret_cast<u8 *>(t1) + len - i);
ASSERT_EQ(reinterpret_cast<const u8 *>(t), rv);
}
}
@ -427,15 +427,15 @@ TEST(ReverseTruffle, ExecNoMatch3) {
CharReach chars;
chars.set('V'); /* V = 0x56, e = 0x65 */
truffleBuildMasks(chars, (u8 *)&mask1, (u8 *)&mask2);
truffleBuildMasks(chars, reinterpret_cast<u8 *>(&mask1), reinterpret_cast<u8 *>(&mask2));
char t[] = "eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee";
char *t1 = t + 1;
size_t len = strlen(t1);
for (size_t i = 0; i < 16; i++) {
const u8 *rv = rtruffleExec(mask1, mask2, (u8 *)t1, (u8 *)t1 + len - i);
ASSERT_EQ((const u8 *)t, rv);
const u8 *rv = rtruffleExec(mask1, mask2, reinterpret_cast<u8 *>(t1), reinterpret_cast<u8 *>(t1) + len - i);
ASSERT_EQ(reinterpret_cast<const u8 *>(t), rv);
}
}
@ -445,11 +445,11 @@ TEST(ReverseTruffle, ExecMiniMatch0) {
CharReach chars;
chars.set('a');
truffleBuildMasks(chars, (u8 *)&lo, (u8 *)&hi);
truffleBuildMasks(chars, reinterpret_cast<u8 *>(&lo), reinterpret_cast<u8 *>(&hi));
char t1[] = "a";
const u8 *rv = rtruffleExec(lo, hi, (u8 *)t1, (u8 *)t1 + strlen(t1));
const u8 *rv = rtruffleExec(lo, hi, reinterpret_cast<u8 *>(t1), reinterpret_cast<u8 *>(t1) + strlen(t1));
ASSERT_EQ((size_t)t1, (size_t)rv);
}
@ -460,16 +460,16 @@ TEST(ReverseTruffle, ExecMiniMatch1) {
CharReach chars;
chars.set('a');
truffleBuildMasks(chars, (u8 *)&mask1, (u8 *)&mask2);
truffleBuildMasks(chars, reinterpret_cast<u8 *>(&mask1), reinterpret_cast<u8 *>(&mask2));
/* 0123456789012345678901234567890 */
char t1[] = "bbbbbbbabbbb";
size_t len = strlen(t1);
const u8 *rv = rtruffleExec(mask1, mask2, (u8 *)t1, (u8 *)t1 + len);
ASSERT_NE((const u8 *)t1 - 1, rv); // not found
const u8 *rv = rtruffleExec(mask1, mask2, reinterpret_cast<u8 *>(t1), reinterpret_cast<u8 *>(t1) + len);
ASSERT_NE(reinterpret_cast<const u8 *>(t1) - 1, rv); // not found
EXPECT_EQ('a', (char)*rv);
ASSERT_EQ((const u8 *)t1 + 7, rv);
ASSERT_EQ(reinterpret_cast<const u8 *>(t1) + 7, rv);
}
TEST(ReverseTruffle, ExecMiniMatch2) {
@ -478,16 +478,16 @@ TEST(ReverseTruffle, ExecMiniMatch2) {
CharReach chars;
chars.set('a');
truffleBuildMasks(chars, (u8 *)&mask1, (u8 *)&mask2);
truffleBuildMasks(chars, reinterpret_cast<u8 *>(&mask1), reinterpret_cast<u8 *>(&mask2));
/* 0123456789012345678901234567890 */
char t1[] = "babbbbbabbbb";
size_t len = strlen(t1);
const u8 *rv = rtruffleExec(mask1, mask2, (u8 *)t1, (u8 *)t1 + len);
ASSERT_NE((const u8 *)t1 - 1, rv); // not found
const u8 *rv = rtruffleExec(mask1, mask2, reinterpret_cast<u8 *>(t1), reinterpret_cast<u8 *>(t1) + len);
ASSERT_NE(reinterpret_cast<const u8 *>(t1) - 1, rv); // not found
EXPECT_EQ('a', (char)*rv);
ASSERT_EQ((const u8 *)t1 + 7, rv);
ASSERT_EQ(reinterpret_cast<const u8 *>(t1) + 7, rv);
}
@ -497,17 +497,17 @@ TEST(ReverseTruffle, ExecMatch1) {
CharReach chars;
chars.set('a');
truffleBuildMasks(chars, (u8 *)&mask1, (u8 *)&mask2);
truffleBuildMasks(chars, reinterpret_cast<u8 *>(&mask1), reinterpret_cast<u8 *>(&mask2));
/* 0123456789012345678901234567890 */
char t1[] = "bbbbbbabbbbbbbbbbabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb";
size_t len = strlen(t1);
for (size_t i = 0; i < 16; i++) {
const u8 *rv = rtruffleExec(mask1, mask2, (u8 *)t1, (u8 *)t1 + len - i);
ASSERT_NE((const u8 *)t1 - 1, rv); // not found
const u8 *rv = rtruffleExec(mask1, mask2, reinterpret_cast<u8 *>(t1), reinterpret_cast<u8 *>(t1) + len - i);
ASSERT_NE(reinterpret_cast<const u8 *>(t1) - 1, rv); // not found
EXPECT_EQ('a', (char)*rv);
ASSERT_EQ((const u8 *)t1 + 17, rv);
ASSERT_EQ(reinterpret_cast<const u8 *>(t1) + 17, rv);
}
}
@ -517,17 +517,17 @@ TEST(ReverseTruffle, ExecMatch2) {
CharReach chars;
chars.set('a');
truffleBuildMasks(chars, (u8 *)&mask1, (u8 *)&mask2);
truffleBuildMasks(chars, reinterpret_cast<u8 *>(&mask1), reinterpret_cast<u8 *>(&mask2));
/* 0123456789012345678901234567890 */
char t1[] = "bbbbabbbbbbbbbbbbaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbb";
size_t len = strlen(t1);
for (size_t i = 0; i < 16; i++) {
const u8 *rv = rtruffleExec(mask1, mask2, (u8 *)t1, (u8 *)t1 + len - i);
ASSERT_NE((const u8 *)t1 - 1, rv); // not found
const u8 *rv = rtruffleExec(mask1, mask2, reinterpret_cast<u8 *>(t1), reinterpret_cast<u8 *>(t1) + len - i);
ASSERT_NE(reinterpret_cast<const u8 *>(t1) - 1, rv); // not found
EXPECT_EQ('a', (char)*rv);
ASSERT_EQ((const u8 *)t1 + 32, rv);
ASSERT_EQ(reinterpret_cast<const u8 *>(t1) + 32, rv);
}
}
@ -538,27 +538,27 @@ TEST(ReverseTruffle, ExecMatch3) {
chars.set('a');
chars.set('B');
truffleBuildMasks(chars, (u8 *)&mask1, (u8 *)&mask2);
truffleBuildMasks(chars, reinterpret_cast<u8 *>(&mask1), reinterpret_cast<u8 *>(&mask2));
/* 0123456789012345678901234567890 */
char t1[] = "bbbbbbbbbbbbbbbbbaaaaaaaaaaaaaaaBbbbbbbbbbbbbbbbbbbbbbbbbbbbb";
size_t len = strlen(t1);
for (size_t i = 0; i < 16; i++) {
const u8 *rv = rtruffleExec(mask1, mask2, (u8 *)t1, (u8 *)t1 + len - i);
ASSERT_NE((const u8 *)t1 - 1, rv); // not found
const u8 *rv = rtruffleExec(mask1, mask2, reinterpret_cast<u8 *>(t1), reinterpret_cast<u8 *>(t1) + len - i);
ASSERT_NE(reinterpret_cast<const u8 *>(t1) - 1, rv); // not found
EXPECT_EQ('B', (char)*rv);
ASSERT_EQ((const u8 *)t1 + 32, rv);
ASSERT_EQ(reinterpret_cast<const u8 *>(t1) + 32, rv);
}
// check that we match the 'a' bytes as well.
ASSERT_EQ('B', t1[32]);
t1[32] = 'b';
for (size_t i = 0; i < 16; i++) {
const u8 *rv = rtruffleExec(mask1, mask2, (u8 *)t1, (u8 *)t1 + len - i);
ASSERT_NE((const u8 *)t1 - 1, rv); // not found
const u8 *rv = rtruffleExec(mask1, mask2, reinterpret_cast<u8 *>(t1), reinterpret_cast<u8 *>(t1) + len - i);
ASSERT_NE(reinterpret_cast<const u8 *>(t1) - 1, rv); // not found
EXPECT_EQ('a', (char)*rv);
ASSERT_EQ((const u8 *)t1 + 31, rv);
ASSERT_EQ(reinterpret_cast<const u8 *>(t1) + 31, rv);
}
}
@ -571,7 +571,7 @@ TEST(ReverseTruffle, ExecMatch4) {
chars.set('A');
chars.set('c');
truffleBuildMasks(chars, (u8 *)&mask1, (u8 *)&mask2);
truffleBuildMasks(chars, reinterpret_cast<u8 *>(&mask1), reinterpret_cast<u8 *>(&mask2));
/* 0123456789012345678901234567890 */
char t1[] = "bbbbbbbbbbbbbbbbbaaaaaaaaaaaaaaaAbbbbbbbbbbbbbbbbbbbbbbbbbbbb";
@ -581,21 +581,21 @@ TEST(ReverseTruffle, ExecMatch4) {
size_t len = strlen(t1);
for (size_t i = 0; i < 16; i++) {
const u8 *rv = rtruffleExec(mask1, mask2, (u8 *)t1, (u8 *)t1 + len - i);
const u8 *rv = rtruffleExec(mask1, mask2, reinterpret_cast<u8 *>(t1), reinterpret_cast<u8 *>(t1) + len - i);
EXPECT_EQ('A', (char)*rv);
ASSERT_EQ((const u8 *)t1 + 32, rv);
ASSERT_EQ(reinterpret_cast<const u8 *>(t1) + 32, rv);
rv = rtruffleExec(mask1, mask2, (u8 *)t2, (u8 *)t2 + len - i);
rv = rtruffleExec(mask1, mask2, reinterpret_cast<u8 *>(t2), reinterpret_cast<u8 *>(t2) + len - i);
EXPECT_EQ('C', (char)*rv);
ASSERT_EQ((const u8 *)t2 + 32, rv);
ASSERT_EQ(reinterpret_cast<const u8 *>(t2) + 32, rv);
rv = rtruffleExec(mask1, mask2, (u8 *)t3, (u8 *)t3 + len - i);
rv = rtruffleExec(mask1, mask2, reinterpret_cast<u8 *>(t3), reinterpret_cast<u8 *>(t3) + len - i);
EXPECT_EQ('c', (char)*rv);
ASSERT_EQ((const u8 *)t3 + 32, rv);
ASSERT_EQ(reinterpret_cast<const u8 *>(t3) + 32, rv);
rv = rtruffleExec(mask1, mask2, (u8 *)t4, (u8 *)t4 + len - i);
rv = rtruffleExec(mask1, mask2, reinterpret_cast<u8 *>(t4), reinterpret_cast<u8 *>(t4) + len - i);
EXPECT_EQ('a', (char)*rv);
ASSERT_EQ((const u8 *)t4 + 32, rv);
ASSERT_EQ(reinterpret_cast<const u8 *>(t4) + 32, rv);
}
}
@ -605,15 +605,15 @@ TEST(ReverseTruffle, ExecMatch5) {
CharReach chars;
chars.set('a');
truffleBuildMasks(chars, (u8 *)&mask1, (u8 *)&mask2);
truffleBuildMasks(chars, reinterpret_cast<u8 *>(&mask1), reinterpret_cast<u8 *>(&mask2));
char t1[] = "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb";
size_t len = strlen(t1);
for (size_t i = 0; i < len; i++) {
t1[i] = 'a';
const u8 *rv = rtruffleExec(mask1, mask2, (u8 *)t1, (u8 *)t1 + len);
const u8 *rv = rtruffleExec(mask1, mask2, reinterpret_cast<u8 *>(t1), reinterpret_cast<u8 *>(t1) + len);
ASSERT_EQ((const u8 *)t1 + i, rv);
ASSERT_EQ(reinterpret_cast<const u8 *>(t1) + i, rv);
}
}

View File

@ -51,7 +51,7 @@ TEST(Uniform, Sizes) {
TEST(Uniform, loadstore_u8) {
for (int i = 0; i < 8; i++) {
u8 in = 1 << i;
const char *cin = (const char *)(&in);
const char *cin = reinterpret_cast<const char *>(&in);
u8 out = load_u8(cin);
EXPECT_EQ(in, out);
char ALIGN_DIRECTIVE stored[1];
@ -63,7 +63,7 @@ TEST(Uniform, loadstore_u8) {
TEST(Uniform, loadstore_u16) {
for (int i = 0; i < 16; i++) {
u16 in = 1 << i;
const char *cin = (const char *)(&in);
const char *cin = reinterpret_cast<const char *>(&in);
u16 out = load_u16(cin);
EXPECT_EQ(in, out);
void *stored = aligned_zmalloc(2);
@ -76,7 +76,7 @@ TEST(Uniform, loadstore_u16) {
TEST(Uniform, loadstore_u32) {
for (int i = 0; i < 32; i++) {
u32 in = 1U << i;
const char *cin = (const char *)(&in);
const char *cin = reinterpret_cast<const char *>(&in);
u32 out = load_u32(cin);
EXPECT_EQ(in, out);
void *stored = aligned_zmalloc(32/8);
@ -89,7 +89,7 @@ TEST(Uniform, loadstore_u32) {
TEST(Uniform, loadstore_u64a) {
for (int i = 0; i < 64; i++) {
u64a in = 1ULL << i;
const char *cin = (const char *)(&in);
const char *cin = reinterpret_cast<const char *>(&in);
u64a out = load_u64a(cin);
EXPECT_EQ(in, out);
void *stored = aligned_zmalloc(64/8);
@ -107,7 +107,7 @@ TEST(Uniform, loadstore_m128) {
for (int i = 0; i < 128; i++) {
memset(&in, 0, sizeof(in));
in.words[i/32] = 1U << (i % 32);
const char *cin = (const char *)(&in);
const char *cin = reinterpret_cast<const char *>(&in);
m128 out = load_m128(cin);
EXPECT_EQ(0, memcmp(&out, &in, sizeof(out)));
void *stored = aligned_zmalloc(128/8);
@ -125,7 +125,7 @@ TEST(Uniform, loadstore_m256) {
for (int i = 0; i < 256; i++) {
memset(&in, 0, sizeof(in));
in.words[i/32] = 1U << (i % 32);
const char *cin = (const char *)(&in);
const char *cin = reinterpret_cast<const char *>(&in);
m256 out = load_m256(cin);
EXPECT_EQ(0, memcmp(&out, &in, sizeof(out)));
void *stored = aligned_zmalloc(256/8);
@ -143,7 +143,7 @@ TEST(Uniform, loadstore_m512) {
for (int i = 0; i < 512; i++) {
memset(&in, 0, sizeof(in));
in.words[i/32] = 1U << (i % 32);
const char *cin = (const char *)(&in);
const char *cin = reinterpret_cast<const char *>(&in);
m512 out = load_m512(cin);
EXPECT_EQ(0, memcmp(&out, &in, sizeof(out)));
void *stored = aligned_zmalloc(512/8);

View File

@ -37,18 +37,18 @@ TEST(Vermicelli, ExecNoMatch1) {
for (size_t i = 0; i < 16; i++) {
for (size_t j = 0; j < 16; j++) {
const u8 *rv = vermicelliExec('a', 0, (u8 *)t1 + i,
(u8 *)t1 + strlen(t1) - j);
const u8 *rv = vermicelliExec('a', 0, reinterpret_cast<u8 *>(t1) + i,
reinterpret_cast<u8 *>(t1) + strlen(t1) - j);
ASSERT_EQ(((size_t)t1 + strlen(t1) - j), (size_t)rv);
rv = vermicelliExec('B', 0, (u8 *)t1 + i,
(u8 *)t1 + strlen(t1) - j);
rv = vermicelliExec('B', 0, reinterpret_cast<u8 *>(t1) + i,
reinterpret_cast<u8 *>(t1) + strlen(t1) - j);
ASSERT_EQ(((size_t)t1 + strlen(t1) - j), (size_t)rv);
rv = vermicelliExec('A', 1, (u8 *)t1 + i,
(u8 *)t1 + strlen(t1) - j);
rv = vermicelliExec('A', 1, reinterpret_cast<u8 *>(t1) + i,
reinterpret_cast<u8 *>(t1) + strlen(t1) - j);
ASSERT_EQ(((size_t)t1 + strlen(t1) - j), (size_t)rv);
}
@ -59,13 +59,13 @@ TEST(Vermicelli, Exec1) {
char t1[] = "bbbbbbbbbbbbbbbbbabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbabbbbbbbbbbbb";
for (size_t i = 0; i < 16; i++) {
const u8 *rv = vermicelliExec('a', 0, (u8 *)t1 + i,
(u8 *)t1 + strlen(t1));
const u8 *rv = vermicelliExec('a', 0, reinterpret_cast<u8 *>(t1) + i,
reinterpret_cast<u8 *>(t1) + strlen(t1));
ASSERT_EQ((size_t)t1 + 17, (size_t)rv);
rv = vermicelliExec('A', 1, (u8 *)t1 + i,
(u8 *)t1 + strlen(t1));
rv = vermicelliExec('A', 1, reinterpret_cast<u8 *>(t1) + i,
reinterpret_cast<u8 *>(t1) + strlen(t1));
ASSERT_EQ((size_t)t1 + 17, (size_t)rv);
}
@ -75,13 +75,13 @@ TEST(Vermicelli, Exec2) {
char t1[] = "bbbbbbbbbbbbbbbbbaaaaaaaaaaaaaaaaaaaaaaabbbbbbbbabbbbbbbbbbbb";
for (size_t i = 0; i < 16; i++) {
const u8 *rv = vermicelliExec('a', 0, (u8 *)t1 + i,
(u8 *)t1 + strlen(t1));
const u8 *rv = vermicelliExec('a', 0, reinterpret_cast<u8 *>(t1) + i,
reinterpret_cast<u8 *>(t1) + strlen(t1));
ASSERT_EQ((size_t)t1 + 17, (size_t)rv);
rv = vermicelliExec('A', 1, (u8 *)t1 + i,
(u8 *)t1 + strlen(t1));
rv = vermicelliExec('A', 1, reinterpret_cast<u8 *>(t1) + i,
reinterpret_cast<u8 *>(t1) + strlen(t1));
ASSERT_EQ((size_t)t1 + 17, (size_t)rv);
}
@ -91,13 +91,13 @@ TEST(Vermicelli, Exec3) {
char t1[] = "bbbbbbbbbbbbbbbbbAaaaaaaaaaaaaaaaaaaaaaabbbbbbbbabbbbbbbbbbbb";
for (size_t i = 0; i < 16; i++) {
const u8 *rv = vermicelliExec('a', 0, (u8 *)t1 + i,
(u8 *)t1 + strlen(t1));
const u8 *rv = vermicelliExec('a', 0, reinterpret_cast<u8 *>(t1) + i,
reinterpret_cast<u8 *>(t1) + strlen(t1));
ASSERT_EQ((size_t)t1 + 18, (size_t)rv);
rv = vermicelliExec('A', 1, (u8 *)t1 + i,
(u8 *)t1 + strlen(t1));
rv = vermicelliExec('A', 1, reinterpret_cast<u8 *>(t1) + i,
reinterpret_cast<u8 *>(t1) + strlen(t1));
ASSERT_EQ((size_t)t1 + 17, (size_t)rv);
}
@ -109,11 +109,11 @@ TEST(Vermicelli, Exec4) {
for (size_t i = 0; i < 31; i++) {
t1[48 - i] = 'a';
const u8 *rv = vermicelliExec('a', 0, (u8 *)t1, (u8 *)t1 + strlen(t1));
const u8 *rv = vermicelliExec('a', 0, reinterpret_cast<u8 *>(t1), reinterpret_cast<u8 *>(t1) + strlen(t1));
ASSERT_EQ((size_t)&t1[48 - i], (size_t)rv);
rv = vermicelliExec('A', 1, (u8 *)t1, (u8 *)t1 + strlen(t1));
rv = vermicelliExec('A', 1, reinterpret_cast<u8 *>(t1), reinterpret_cast<u8 *>(t1) + strlen(t1));
ASSERT_EQ((size_t)&t1[48 - i], (size_t)rv);
}
@ -124,30 +124,30 @@ TEST(DoubleVermicelli, ExecNoMatch1) {
for (size_t i = 0; i < 16; i++) {
for (size_t j = 0; j < 16; j++) {
const u8 *rv = vermicelliDoubleExec('a', 'b', 0, (u8 *)t1 + i,
(u8 *)t1 + strlen(t1) - j);
const u8 *rv = vermicelliDoubleExec('a', 'b', 0, reinterpret_cast<u8 *>(t1) + i,
reinterpret_cast<u8 *>(t1) + strlen(t1) - j);
ASSERT_EQ(((size_t)t1 + strlen(t1) - j), (size_t)rv);
rv = vermicelliDoubleExec('B', 'b', 0, (u8 *)t1 + i,
(u8 *)t1 + strlen(t1) - j);
rv = vermicelliDoubleExec('B', 'b', 0, reinterpret_cast<u8 *>(t1) + i,
reinterpret_cast<u8 *>(t1) + strlen(t1) - j);
ASSERT_EQ(((size_t)t1 + strlen(t1) - j), (size_t)rv);
rv = vermicelliDoubleExec('A', 'B', 1, (u8 *)t1 + i,
(u8 *)t1 + strlen(t1) - j);
rv = vermicelliDoubleExec('A', 'B', 1, reinterpret_cast<u8 *>(t1) + i,
reinterpret_cast<u8 *>(t1) + strlen(t1) - j);
ASSERT_EQ(((size_t)t1 + strlen(t1) - j), (size_t)rv);
/* partial match */
rv = vermicelliDoubleExec('b', 'B', 0, (u8 *)t1 + i,
(u8 *)t1 + strlen(t1) - j);
rv = vermicelliDoubleExec('b', 'B', 0, reinterpret_cast<u8 *>(t1) + i,
reinterpret_cast<u8 *>(t1) + strlen(t1) - j);
ASSERT_EQ(((size_t)t1 + strlen(t1) - j - 1), (size_t)rv);
/* partial match */
rv = vermicelliDoubleExec('B', 'A', 1, (u8 *)t1 + i,
(u8 *)t1 + strlen(t1) - j);
rv = vermicelliDoubleExec('B', 'A', 1, reinterpret_cast<u8 *>(t1) + i,
reinterpret_cast<u8 *>(t1) + strlen(t1) - j);
ASSERT_EQ(((size_t)t1 + strlen(t1) - j - 1), (size_t)rv);
}
@ -158,23 +158,23 @@ TEST(DoubleVermicelli, Exec1) {
char t1[] = "bbbbbbbbbbbbbbbbbbabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbabbbbbbbbbbb";
for (size_t i = 0; i < 16; i++) {
const u8 *rv = vermicelliDoubleExec('a', 'b', 0, (u8 *)t1 + i,
(u8 *)t1 + strlen(t1));
const u8 *rv = vermicelliDoubleExec('a', 'b', 0, reinterpret_cast<u8 *>(t1) + i,
reinterpret_cast<u8 *>(t1) + strlen(t1));
ASSERT_EQ((size_t)t1 + 18, (size_t)rv);
rv = vermicelliDoubleExec('A', 'B', 1, (u8 *)t1 + i,
(u8 *)t1 + strlen(t1));
rv = vermicelliDoubleExec('A', 'B', 1, reinterpret_cast<u8 *>(t1) + i,
reinterpret_cast<u8 *>(t1) + strlen(t1));
ASSERT_EQ((size_t)t1 + 18, (size_t)rv);
rv = vermicelliDoubleExec('b', 'a', 0, (u8 *)t1 + i,
(u8 *)t1 + strlen(t1));
rv = vermicelliDoubleExec('b', 'a', 0, reinterpret_cast<u8 *>(t1) + i,
reinterpret_cast<u8 *>(t1) + strlen(t1));
ASSERT_EQ((size_t)t1 + 17, (size_t)rv);
rv = vermicelliDoubleExec('B', 'A', 1, (u8 *)t1 + i,
(u8 *)t1 + strlen(t1));
rv = vermicelliDoubleExec('B', 'A', 1, reinterpret_cast<u8 *>(t1) + i,
reinterpret_cast<u8 *>(t1) + strlen(t1));
ASSERT_EQ((size_t)t1 + 17, (size_t)rv);
}
@ -184,13 +184,13 @@ TEST(DoubleVermicelli, Exec2) {
char t1[] = "bbbbbbbbbbbbbbbbbaaaaaaaaaaaaaaaaaaaaaaaabbbbbbbaaaaabbbbbbbb";
for (size_t i = 0; i < 16; i++) {
const u8 *rv = vermicelliDoubleExec('a', 'a', 0, (u8 *)t1 + i,
(u8 *)t1 + strlen(t1));
const u8 *rv = vermicelliDoubleExec('a', 'a', 0, reinterpret_cast<u8 *>(t1) + i,
reinterpret_cast<u8 *>(t1) + strlen(t1));
ASSERT_EQ((size_t)t1 + 17, (size_t)rv);
rv = vermicelliDoubleExec('A', 'A', 1, (u8 *)t1 + i,
(u8 *)t1 + strlen(t1));
rv = vermicelliDoubleExec('A', 'A', 1, reinterpret_cast<u8 *>(t1) + i,
reinterpret_cast<u8 *>(t1) + strlen(t1));
ASSERT_EQ((size_t)t1 + 17, (size_t)rv);
}
@ -201,23 +201,23 @@ TEST(DoubleVermicelli, Exec3) {
char t1[] = "bbbbbbbbbbbbbbbbbaAaaAAaaaaaaaaaaaaaaaaaabbbbbbbaaaaabbbbbbbb";
for (size_t i = 0; i < 16; i++) {
const u8 *rv = vermicelliDoubleExec('A', 'a', 0, (u8 *)t1 + i,
(u8 *)t1 + strlen(t1));
const u8 *rv = vermicelliDoubleExec('A', 'a', 0, reinterpret_cast<u8 *>(t1) + i,
reinterpret_cast<u8 *>(t1) + strlen(t1));
ASSERT_EQ((size_t)t1 + 18, (size_t)rv);
rv = vermicelliDoubleExec('A', 'A', 1, (u8 *)t1 + i,
(u8 *)t1 + strlen(t1));
rv = vermicelliDoubleExec('A', 'A', 1, reinterpret_cast<u8 *>(t1) + i,
reinterpret_cast<u8 *>(t1) + strlen(t1));
ASSERT_EQ((size_t)t1 + 17, (size_t)rv);
rv = vermicelliDoubleExec('A', 'A', 0, (u8 *)t1 + i,
(u8 *)t1 + strlen(t1));
rv = vermicelliDoubleExec('A', 'A', 0, reinterpret_cast<u8 *>(t1) + i,
reinterpret_cast<u8 *>(t1) + strlen(t1));
ASSERT_EQ((size_t)t1 + 21, (size_t)rv);
rv = vermicelliDoubleExec('a', 'A', 0, (u8 *)t1 + i,
(u8 *)t1 + strlen(t1));
rv = vermicelliDoubleExec('a', 'A', 0, reinterpret_cast<u8 *>(t1) + i,
reinterpret_cast<u8 *>(t1) + strlen(t1));
ASSERT_EQ((size_t)t1 + 17, (size_t)rv);
}
@ -230,12 +230,12 @@ TEST(DoubleVermicelli, Exec4) {
for (size_t i = 0; i < 31; i++) {
t1[48 - i] = 'a';
t1[48 - i + 1] = 'a';
const u8 *rv = vermicelliDoubleExec('a', 'a', 0, (u8 *)t1,
(u8 *)t1 + strlen(t1));
const u8 *rv = vermicelliDoubleExec('a', 'a', 0, reinterpret_cast<u8 *>(t1),
reinterpret_cast<u8 *>(t1) + strlen(t1));
ASSERT_EQ((size_t)&t1[48 - i], (size_t)rv);
rv = vermicelliDoubleExec('A', 'A', 1, (u8 *)t1, (u8 *)t1 + strlen(t1));
rv = vermicelliDoubleExec('A', 'A', 1, reinterpret_cast<u8 *>(t1), reinterpret_cast<u8 *>(t1) + strlen(t1));
ASSERT_EQ((size_t)&t1[48 - i], (size_t)rv);
}
@ -244,7 +244,7 @@ TEST(DoubleVermicelli, Exec4) {
TEST(Vermicelli, noodEarlyExit) {
// searches that should fail
static const u8 *lowerAlpha = (const u8*) "abcdefghijklmnopqrstuvwxyz";
static const u8 *lowerAlpha = reinterpret_cast<const u8 *>("abcdefghijklmnopqrstuvwxyz");
const u8 *la_end = lowerAlpha + 26;
EXPECT_EQ(la_end, vermicelliExec('0', 0, lowerAlpha, la_end));
EXPECT_EQ(la_end, vermicelliExec('A', 0, lowerAlpha, la_end));
@ -266,13 +266,13 @@ TEST(NVermicelli, ExecNoMatch1) {
SCOPED_TRACE(i);
for (size_t j = 0; j < 16; j++) {
SCOPED_TRACE(j);
const u8 *rv = nvermicelliExec('b', 0, (u8 *)t1 + i,
(u8 *)t1 + strlen(t1) - j);
const u8 *rv = nvermicelliExec('b', 0, reinterpret_cast<u8 *>(t1) + i,
reinterpret_cast<u8 *>(t1) + strlen(t1) - j);
ASSERT_EQ(((size_t)t1 + strlen(t1) - j), (size_t)rv);
rv = nvermicelliExec('B', 1, (u8 *)t1 + i,
(u8 *)t1 + strlen(t1) - j);
rv = nvermicelliExec('B', 1, reinterpret_cast<u8 *>(t1) + i,
reinterpret_cast<u8 *>(t1) + strlen(t1) - j);
ASSERT_EQ(((size_t)t1 + strlen(t1) - j), (size_t)rv);
}
@ -284,13 +284,13 @@ TEST(NVermicelli, Exec1) {
for (size_t i = 0; i < 16; i++) {
SCOPED_TRACE(i);
const u8 *rv = nvermicelliExec('b', 0, (u8 *)t1 + i,
(u8 *)t1 + strlen(t1));
const u8 *rv = nvermicelliExec('b', 0, reinterpret_cast<u8 *>(t1) + i,
reinterpret_cast<u8 *>(t1) + strlen(t1));
ASSERT_EQ((size_t)t1 + 17, (size_t)rv);
rv = nvermicelliExec('B', 1, (u8 *)t1 + i,
(u8 *)t1 + strlen(t1));
rv = nvermicelliExec('B', 1, reinterpret_cast<u8 *>(t1) + i,
reinterpret_cast<u8 *>(t1) + strlen(t1));
ASSERT_EQ((size_t)t1 + 17, (size_t)rv);
}
@ -301,13 +301,13 @@ TEST(NVermicelli, Exec2) {
for (size_t i = 0; i < 16; i++) {
SCOPED_TRACE(i);
const u8 *rv = nvermicelliExec('b', 0, (u8 *)t1 + i,
(u8 *)t1 + strlen(t1));
const u8 *rv = nvermicelliExec('b', 0, reinterpret_cast<u8 *>(t1) + i,
reinterpret_cast<u8 *>(t1) + strlen(t1));
ASSERT_EQ((size_t)t1 + 17, (size_t)rv);
rv = nvermicelliExec('B', 1, (u8 *)t1 + i,
(u8 *)t1 + strlen(t1));
rv = nvermicelliExec('B', 1, reinterpret_cast<u8 *>(t1) + i,
reinterpret_cast<u8 *>(t1) + strlen(t1));
ASSERT_EQ((size_t)t1 + 17, (size_t)rv);
}
@ -318,13 +318,13 @@ TEST(NVermicelli, Exec3) {
for (size_t i = 0; i < 16; i++) {
SCOPED_TRACE(i);
const u8 *rv = nvermicelliExec('b', 0, (u8 *)t1 + i,
(u8 *)t1 + strlen(t1));
const u8 *rv = nvermicelliExec('b', 0, reinterpret_cast<u8 *>(t1) + i,
reinterpret_cast<u8 *>(t1) + strlen(t1));
ASSERT_EQ((size_t)t1 + 17, (size_t)rv);
rv = nvermicelliExec('B', 1, (u8 *)t1 + i,
(u8 *)t1 + strlen(t1));
rv = nvermicelliExec('B', 1, reinterpret_cast<u8 *>(t1) + i,
reinterpret_cast<u8 *>(t1) + strlen(t1));
ASSERT_EQ((size_t)t1 + 18, (size_t)rv);
}
@ -336,11 +336,11 @@ TEST(NVermicelli, Exec4) {
for (size_t i = 0; i < 31; i++) {
SCOPED_TRACE(i);
t1[48 - i] = 'a';
const u8 *rv = nvermicelliExec('b', 0, (u8 *)t1, (u8 *)t1 + strlen(t1));
const u8 *rv = nvermicelliExec('b', 0, reinterpret_cast<u8 *>(t1), reinterpret_cast<u8 *>(t1) + strlen(t1));
ASSERT_EQ((size_t)&t1[48 - i], (size_t)rv);
rv = nvermicelliExec('B', 1, (u8 *)t1, (u8 *)t1 + strlen(t1));
rv = nvermicelliExec('B', 1, reinterpret_cast<u8 *>(t1), reinterpret_cast<u8 *>(t1) + strlen(t1));
ASSERT_EQ((size_t)&t1[48 - i], (size_t)rv);
}
@ -348,7 +348,7 @@ TEST(NVermicelli, Exec4) {
TEST(DoubleVermicelliMasked, ExecNoMatch1) {
std::string t1("bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb");
const u8 *t1_raw = (const u8 *)t1.c_str();
const u8 *t1_raw = reinterpret_cast<const u8 *>(t1.c_str());
for (size_t i = 0; i < 16; i++) {
for (size_t j = 0; j < 16; j++) {
@ -388,7 +388,7 @@ TEST(DoubleVermicelliMasked, ExecNoMatch1) {
TEST(DoubleVermicelliMasked, Exec1) {
std::string t1("bbbbbbbbbbbbbbbbbbabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbabbbbbbbbbbb");
const u8 *t1_raw = (const u8 *)t1.c_str();
const u8 *t1_raw = reinterpret_cast<const u8 *>(t1.c_str());
for (size_t i = 0; i < 16; i++) {
const u8 *rv = vermicelliDoubleMaskedExec('a', 'b', 0xff, 0xff,
@ -431,7 +431,7 @@ TEST(DoubleVermicelliMasked, Exec1) {
TEST(DoubleVermicelliMasked, Exec2) {
std::string t1("bbbbbbbbbbbbbbbbbaaaaaaaaaaaaaaaaaaaaaaaabbbbbbbaaaaabbbbbbbb");
const u8 *t1_raw = (const u8 *)t1.c_str();
const u8 *t1_raw = reinterpret_cast<const u8 *>(t1.c_str());
for (size_t i = 0; i < 16; i++) {
const u8 *rv = vermicelliDoubleMaskedExec('a', 'a', 0xff, 0xff,
@ -463,7 +463,7 @@ TEST(DoubleVermicelliMasked, Exec2) {
TEST(DoubleVermicelliMasked, Exec3) {
/* 012345678901234567890123 */
std::string t1("bbbbbbbbbbbbbbbbbaAaaAAaaaaaaaaaaaaaaaaaabbbbbbbaaaaabbbbbbbb");
const u8 *t1_raw = (const u8 *)t1.c_str();
const u8 *t1_raw = reinterpret_cast<const u8 *>(t1.c_str());
for (size_t i = 0; i < 16; i++) {
const u8 *rv = vermicelliDoubleMaskedExec('A', 'a', 0xff, 0xff,
@ -506,7 +506,7 @@ TEST(DoubleVermicelliMasked, Exec3) {
TEST(DoubleVermicelliMasked, Exec4) {
std::string t1("bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb");
const u8 *t1_raw = (const u8 *)t1.c_str();
const u8 *t1_raw = reinterpret_cast<const u8 *>(t1.c_str());
for (size_t i = 0; i < 31; i++) {
t1[48 - i] = 'a';
@ -530,7 +530,7 @@ using namespace ue2;
TEST(Vermicelli16, ExecNoMatch1) {
char t1[] = "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb";
const u8 *buf = (const u8 *)t1;
const u8 *buf = reinterpret_cast<const u8 *>(t1);
CharReach chars;
chars.set('a');
@ -550,7 +550,7 @@ TEST(Vermicelli16, ExecNoMatch1) {
TEST(Vermicelli16, Exec1) {
char t1[] = "bbbbbbbbbbbbbbbbbabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbabbbbbbbbbbbb";
const u8 *buf = (const u8 *)t1;
const u8 *buf = reinterpret_cast<const u8 *>(t1);
CharReach chars;
chars.set('a');
@ -567,7 +567,7 @@ TEST(Vermicelli16, Exec1) {
TEST(Vermicelli16, Exec2) {
char t1[] = "bbbbbbbbbbbbbbbbbaaaaaaaaaaaaaaaaaaaaaaabbbbbbbbabbbbbbbbbbbb";
const u8 *buf = (const u8 *)t1;
const u8 *buf = reinterpret_cast<const u8 *>(t1);
CharReach chars;
chars.set('a');
@ -584,7 +584,7 @@ TEST(Vermicelli16, Exec2) {
TEST(Vermicelli16, Exec3) {
char t1[] = "bbbbbbbbbbbbbbbbbAaaaaaaaaaaaaaaaaaaaaaabbbbbbbbabbbbbbbbbbbb";
const u8 *buf = (const u8 *)t1;
const u8 *buf = reinterpret_cast<const u8 *>(t1);
CharReach chars;
chars.set('a');
@ -608,7 +608,7 @@ TEST(Vermicelli16, Exec3) {
TEST(Vermicelli16, Exec4) {
char t1[] = "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb";
const u8 *buf = (const u8 *)t1;
const u8 *buf = reinterpret_cast<const u8 *>(t1);
CharReach chars;
chars.set('a');
@ -633,7 +633,7 @@ TEST(Vermicelli16, Exec4) {
TEST(Vermicelli16, Exec5) {
char t1[] = "qqqqqqqqqqqqqqqqqabcdefghijklmnopqqqqqqqqqqqqqqqqqqqqq";
const u8 *buf = (const u8 *)t1;
const u8 *buf = reinterpret_cast<const u8 *>(t1);
CharReach chars;
m128 matches[16];
@ -655,7 +655,7 @@ TEST(Vermicelli16, Exec5) {
TEST(NVermicelli16, ExecNoMatch1) {
char t1[] = "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb";
const u8 *buf = (const u8 *)t1;
const u8 *buf = reinterpret_cast<const u8 *>(t1);
CharReach chars;
chars.set('b');
@ -675,7 +675,7 @@ TEST(NVermicelli16, ExecNoMatch1) {
TEST(NVermicelli16, Exec1) {
char t1[] = "bbbbbbbbbbbbbbbbbabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbabbbbbbbbbbbb";
const u8 *buf = (const u8 *)t1;
const u8 *buf = reinterpret_cast<const u8 *>(t1);
CharReach chars;
chars.set('b');
@ -692,7 +692,7 @@ TEST(NVermicelli16, Exec1) {
TEST(NVermicelli16, Exec2) {
char t1[] = "bbbbbbbbbbbbbbbbbaaaaaaaaaaaaaaaaaaaaaaabbbbbbbbabbbbbbbbbbbb";
const u8 *buf = (const u8 *)t1;
const u8 *buf = reinterpret_cast<const u8 *>(t1);
CharReach chars;
chars.set('b');
@ -709,7 +709,7 @@ TEST(NVermicelli16, Exec2) {
TEST(NVermicelli16, Exec3) {
char t1[] = "bbbbbbbbbbbbbbbbbAaaaaaaaaaaaaaaaaaaaaaabbbbbbbbabbbbbbbbbbbb";
const u8 *buf = (const u8 *)t1;
const u8 *buf = reinterpret_cast<const u8 *>(t1);
CharReach chars;
chars.set('b');
@ -733,7 +733,7 @@ TEST(NVermicelli16, Exec3) {
TEST(NVermicelli16, Exec4) {
char t1[] = "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb";
const u8 *buf = (const u8 *)t1;
const u8 *buf = reinterpret_cast<const u8 *>(t1);
CharReach chars;
chars.set('b');
@ -758,7 +758,7 @@ TEST(NVermicelli16, Exec4) {
TEST(NVermicelli16, Exec5) {
char t1[] = "aaaaaaaaaaaaaaaaaabcdefghijklmnopqaaaaaaaaaaaaaaaaaaaaa";
const u8 *buf = (const u8 *)t1;
const u8 *buf = reinterpret_cast<const u8 *>(t1);
CharReach chars;
m128 matches[16];
@ -780,7 +780,7 @@ TEST(NVermicelli16, Exec5) {
TEST(DoubleVermicelli16, ExecNoMatch1) {
std::string t1("bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb");
const u8 *t1_raw = (const u8 *)t1.c_str();
const u8 *t1_raw = reinterpret_cast<const u8 *>(t1.c_str());
m128 matches;
u64a firsts;
@ -802,7 +802,7 @@ TEST(DoubleVermicelli16, ExecNoMatch1) {
TEST(DoubleVermicelli16, ExecNoMatch2) {
std::string t1("bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb");
const u8 *t1_raw = (const u8 *)t1.c_str();
const u8 *t1_raw = reinterpret_cast<const u8 *>(t1.c_str());
m128 matches;
u64a firsts;
@ -825,7 +825,7 @@ TEST(DoubleVermicelli16, ExecNoMatch2) {
TEST(DoubleVermicelli16, ExecNoMatch3) {
std::string t1("bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb");
const u8 *t1_raw = (const u8 *)t1.c_str();
const u8 *t1_raw = reinterpret_cast<const u8 *>(t1.c_str());
m128 matches;
u64a firsts;
@ -849,7 +849,7 @@ TEST(DoubleVermicelli16, ExecNoMatch3) {
TEST(DoubleVermicelli16, Exec1) {
std::string t1("bbbbbbbbbbbbbbbbbbabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbabbbbbbbbbbb");
const u8 *t1_raw = (const u8 *)t1.c_str();
const u8 *t1_raw = reinterpret_cast<const u8 *>(t1.c_str());
m128 matches;
u64a firsts;
@ -877,7 +877,7 @@ TEST(DoubleVermicelli16, Exec1) {
TEST(DoubleVermicelli16, Exec2) {
std::string t1("bbbbbbbbbbbbbbbbbaaaaaaaaaaaaaaaaaaaaaaaabbbbbbbaaaaabbbbbbbb");
const u8 *t1_raw = (const u8 *)t1.c_str();
const u8 *t1_raw = reinterpret_cast<const u8 *>(t1.c_str());
m128 matches;
u64a firsts;
@ -895,7 +895,7 @@ TEST(DoubleVermicelli16, Exec2) {
TEST(DoubleVermicelliMasked16, ExecNoMatch1) {
std::string t1("bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb");
const u8 *t1_raw = (const u8 *)t1.c_str();
const u8 *t1_raw = reinterpret_cast<const u8 *>(t1.c_str());
m128 matches1;
bool ret = vermicelliDoubleMasked16Build('a', 'b', 0xff, 0xff, (u8 *)&matches1);
@ -941,7 +941,7 @@ TEST(DoubleVermicelliMasked16, ExecNoMatch1) {
TEST(DoubleVermicelliMasked16, Exec1) {
std::string t1("bbbbbbbbbbbbbbbbbbabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbabbbbbbbbbbb");
const u8 *t1_raw = (const u8 *)t1.c_str();
const u8 *t1_raw = reinterpret_cast<const u8 *>(t1.c_str());
m128 matches1;
bool ret = vermicelliDoubleMasked16Build('a', 'b', 0xff, 0xff, (u8 *)&matches1);
@ -991,7 +991,7 @@ TEST(DoubleVermicelliMasked16, Exec1) {
TEST(DoubleVermicelliMasked16, Exec2) {
std::string t1("bbbbbbbbbbbbbbbbbaaaaaaaaaaaaaaaaaaaaaaaabbbbbbbaaaaabbbbbbbb");
const u8 *t1_raw = (const u8 *)t1.c_str();
const u8 *t1_raw = reinterpret_cast<const u8 *>(t1.c_str());
m128 matches1;
bool ret = vermicelliDoubleMasked16Build('a', 'a', 0xff, 0xff, (u8 *)&matches1);
@ -1028,7 +1028,7 @@ TEST(DoubleVermicelliMasked16, Exec2) {
TEST(DoubleVermicelliMasked16, Exec3) {
/* 012345678901234567890123 */
std::string t1("bbbbbbbbbbbbbbbbbaAaaAAaaaaaaaaaaaaaaaaaabbbbbbbaaaaabbbbbbbb");
const u8 *t1_raw = (const u8 *)t1.c_str();
const u8 *t1_raw = reinterpret_cast<const u8 *>(t1.c_str());
m128 matches1;
bool ret = vermicelliDoubleMasked16Build('A', 'a', 0xff, 0xff, (u8 *)&matches1);
@ -1078,7 +1078,7 @@ TEST(DoubleVermicelliMasked16, Exec3) {
TEST(DoubleVermicelliMasked16, Exec4) {
std::string t1("bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb");
const u8 *t1_raw = (const u8 *)t1.c_str();
const u8 *t1_raw = reinterpret_cast<const u8 *>(t1.c_str());
m128 matches1;
bool ret = vermicelliDoubleMasked16Build('a', 'a', 0xff, 0xff, (u8 *)&matches1);
@ -1102,7 +1102,7 @@ TEST(DoubleVermicelliMasked16, Exec4) {
TEST(DoubleVermicelliMasked16, Exec5) {
std::string t1("bbbbbbbbbbbbbbbbbaCaGaOCaChBfcNgBFGiLbbbbbbbbbbbbbbbbbbbbbbbb");
const u8 *t1_raw = (const u8 *)t1.c_str();
const u8 *t1_raw = reinterpret_cast<const u8 *>(t1.c_str());
m128 matches1;
bool ret = vermicelliDoubleMasked16Build('a', 'B', 0xff, 0xde, (u8 *)&matches1);