Skip to content

Commit

Permalink
Merge pull request #170 from ska-sa/faster-unittest
Browse files Browse the repository at this point in the history
Speed up the common_memcpy unit test
  • Loading branch information
bmerry committed Nov 3, 2021
2 parents d7423bf + 637afad commit 17fdfc0
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/unittest_memcpy.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright 2016 National Research Foundation (SARAO)
/* Copyright 2016, 2021 National Research Foundation (SARAO)
*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
Expand Down Expand Up @@ -44,6 +44,7 @@ BOOST_AUTO_TEST_CASE(memcpy_nontemporal_alignments)

std::uint8_t src_buffer[buffer_size];
std::uint8_t dest_buffer[buffer_size];
std::uint8_t expected[buffer_size];
for (int i = 0; i < align_range; i++)
for (int j = 0; j < align_range; j++)
for (int len = 0; len <= max_len; len++)
Expand All @@ -53,12 +54,11 @@ BOOST_AUTO_TEST_CASE(memcpy_nontemporal_alignments)
src_buffer[k] = k % 255;
spead2::memcpy_nontemporal(dest_buffer + head_pad + i,
src_buffer + head_pad + j, len);
for (int k = 0; k < head_pad + i; k++)
BOOST_CHECK_EQUAL(255, dest_buffer[k]);

std::memset(expected, 255, sizeof(expected));
for (int k = 0; k < len; k++)
BOOST_CHECK_EQUAL(src_buffer[head_pad + j + k], dest_buffer[head_pad + i + k]);
for (int k = head_pad + i + len; k < buffer_size; k++)
BOOST_CHECK_EQUAL(255, dest_buffer[k]);
expected[head_pad + i + k] = src_buffer[head_pad + j + k];
BOOST_TEST(dest_buffer == expected);
}
}

Expand Down

0 comments on commit 17fdfc0

Please sign in to comment.