Skip to content

Commit

Permalink
Merge pull request #1861 from aarongreig/aaron/addSetDataToMockHandle
Browse files Browse the repository at this point in the history
Add getData/setData to mock dummy handle
  • Loading branch information
kbenzie committed Jul 23, 2024
2 parents fa6bf97 + 65b4431 commit 9b20964
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions source/mock/ur_mock_helpers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include "ur_api.h"

#include <atomic>
#include <cassert>
#include <cstddef>
#include <string>
#include <unordered_map>
Expand All @@ -36,6 +37,16 @@ struct dummy_handle_t_ {
std::vector<unsigned char> MStorage;
unsigned char *MData = nullptr;
size_t MSize;

template <typename T> T getDataAs() {
assert(MStorage.size() >= sizeof(T));
return *reinterpret_cast<T *>(MStorage.data());
}

template <typename T> T setDataAs(T Val) {
assert(MStorage.size() >= sizeof(T));
return *reinterpret_cast<T *>(MStorage.data()) = Val;
}
};

using dummy_handle_t = dummy_handle_t_ *;
Expand Down

0 comments on commit 9b20964

Please sign in to comment.