Skip to content

Commit 61725fb

Browse files
committed
fix: MinGW compatibility for mock HID interface tests
- Use manual copy loop instead of std::copy_n in getInputReport mock to work around potential MinGW std::span/copy_n interaction issues - Cast ASSERT_EQ values to int for proper printing of uint8_t values (prevents null byte characters from showing as empty)
1 parent 983d55e commit 61725fb

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

tests/test_hid_interface.cpp

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -47,15 +47,16 @@ class TestFailure : public std::runtime_error {
4747
} \
4848
} while (0)
4949

50-
#define ASSERT_EQ(expected, actual, msg) \
51-
do { \
52-
if ((expected) != (actual)) { \
53-
std::ostringstream oss; \
54-
oss << "ASSERT_EQ failed: " << (msg) << "\n" \
55-
<< " Expected: " << (expected) << "\n" \
56-
<< " Actual: " << (actual); \
57-
throw TestFailure(oss.str()); \
58-
} \
50+
#define ASSERT_EQ(expected, actual, msg) \
51+
do { \
52+
if ((expected) != (actual)) { \
53+
std::ostringstream oss; \
54+
oss << "ASSERT_EQ failed: " << (msg) << "\n" \
55+
<< " Expected: " << static_cast<int>(expected) \
56+
<< "\n" \
57+
<< " Actual: " << static_cast<int>(actual); \
58+
throw TestFailure(oss.str()); \
59+
} \
5960
} while (0)
6061

6162
// ============================================================================
@@ -202,7 +203,10 @@ class MockHIDInterface : public HIDInterface {
202203
}
203204

204205
size_t copy_size = std::min(read_response.size(), data.size());
205-
std::copy_n(read_response.begin(), copy_size, data.begin());
206+
// Use manual copy for cross-platform compatibility (MinGW workaround)
207+
for (size_t i = 0; i < copy_size; ++i) {
208+
data[i] = read_response[i];
209+
}
206210

207211
return copy_size;
208212
}

0 commit comments

Comments
 (0)