Skip to content

Commit

Permalink
gitbak
Browse files Browse the repository at this point in the history
  • Loading branch information
PingFloyd committed Feb 26, 2025
1 parent bd3c64c commit 8529d46
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/algorithm/zip.h
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ static inline void zip_u8(uint16_t *__restrict__ out,
}

for (size_t i = 0; i < n; i++) {
const uint16_t t = (uint16_t)(*in1) | (((uint16_t)(*in2)) << 8u);
const uint16_t t = (uint16_t)(in1[i]) | (((uint16_t)(in2[i])) << 8u);
out[i] = t;
}
}
Expand Down
18 changes: 17 additions & 1 deletion tests/algorithm/zip.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,23 @@ using ::testing::TestPartResult;
using ::testing::UnitTest;


TEST(zip, int_) {
TEST(zip, uint8_t_) {
using TypeParam = uint8_t;
using TypeParam2 = uint16_t;
constexpr static size_t s = 1u << 10;
TypeParam d1[s], d2[s];
TypeParam2 out[s];
for (uint32_t i = 0; i < s; i++) {
d1[i] = i; d2[i] = i;
}

zip_u8(out, d1, d2, s);

for (size_t i = 0; i < s; i++) {
const TypeParam2 t = d1[i] | (((TypeParam2)d2[i]) << (sizeof(TypeParam)*8));
EXPECT_EQ(out[i], t);

}
}

int main(int argc, char **argv) {
Expand Down

0 comments on commit 8529d46

Please sign in to comment.