refactor tests
This commit is contained in:
parent
8f6595e869
commit
f1e1257f21
@ -31,6 +31,32 @@ constexpr bool x64 = false;
|
|||||||
|
|
||||||
template <typename T> using Array = T[];
|
template <typename T> using Array = T[];
|
||||||
|
|
||||||
|
template <auto F> using Functor = std::integral_constant<std::decay_t<decltype(F)>, F>;
|
||||||
|
|
||||||
|
template <typename V>
|
||||||
|
struct Identity { V operator()(V v) const { return v; } };
|
||||||
|
|
||||||
|
struct PermissivePointer
|
||||||
|
{
|
||||||
|
template <typename T>
|
||||||
|
operator T*() { return (T*)p; }
|
||||||
|
void* p;
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename HandleCloser = Functor<CloseHandle>>
|
||||||
|
class AutoHandle
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
AutoHandle(HANDLE h) : h(h) {}
|
||||||
|
operator HANDLE() { return h.get(); }
|
||||||
|
PHANDLE operator&() { static_assert(sizeof(*this) == sizeof(HANDLE)); assert(!h); return (PHANDLE)this; }
|
||||||
|
operator bool() { return h.get() != NULL && h.get() != INVALID_HANDLE_VALUE; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
struct HandleCleaner { void operator()(void* h) { if (h != INVALID_HANDLE_VALUE) HandleCloser()(PermissivePointer{ h }); } };
|
||||||
|
std::unique_ptr<void, HandleCleaner> h;
|
||||||
|
};
|
||||||
|
|
||||||
template<typename T, typename M = std::mutex>
|
template<typename T, typename M = std::mutex>
|
||||||
class Synchronized
|
class Synchronized
|
||||||
{
|
{
|
||||||
@ -53,23 +79,6 @@ private:
|
|||||||
M m;
|
M m;
|
||||||
};
|
};
|
||||||
|
|
||||||
template <auto F>
|
|
||||||
using Functor = std::integral_constant<std::decay_t<decltype(F)>, F>;
|
|
||||||
|
|
||||||
template <typename HandleCloser = Functor<CloseHandle>>
|
|
||||||
class AutoHandle
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
AutoHandle(HANDLE h) : h(h) {}
|
|
||||||
operator HANDLE() { return h.get(); }
|
|
||||||
PHANDLE operator&() { static_assert(sizeof(*this) == sizeof(HANDLE)); return (PHANDLE)this; }
|
|
||||||
operator bool() { return h.get() != NULL && h.get() != INVALID_HANDLE_VALUE; }
|
|
||||||
|
|
||||||
private:
|
|
||||||
struct HandleCleaner { void operator()(void* h) { if (h != INVALID_HANDLE_VALUE) HandleCloser()(h); } };
|
|
||||||
std::unique_ptr<void, HandleCleaner> h;
|
|
||||||
};
|
|
||||||
|
|
||||||
static struct
|
static struct
|
||||||
{
|
{
|
||||||
BYTE DUMMY[100];
|
BYTE DUMMY[100];
|
||||||
|
@ -13,7 +13,7 @@ int& mode = vars.at(0);
|
|||||||
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE, LPSTR, int _)
|
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE, LPSTR, int _)
|
||||||
{
|
{
|
||||||
QApplication a(_ = 0, DUMMY);
|
QApplication a(_ = 0, DUMMY);
|
||||||
static std::vector<std::unique_ptr<std::remove_pointer_t<HMODULE>, Functor<FreeLibrary>>> extensions;
|
static std::vector<AutoHandle<Functor<FreeLibrary>>> extensions;
|
||||||
for (auto file : std::filesystem::directory_iterator(std::filesystem::current_path()))
|
for (auto file : std::filesystem::directory_iterator(std::filesystem::current_path()))
|
||||||
if (file.path().extension() == L".dll"
|
if (file.path().extension() == L".dll"
|
||||||
&& (std::stringstream() << std::ifstream(file.path(), std::ios::binary).rdbuf()).str().find("OnNewSentence") != std::string::npos)
|
&& (std::stringstream() << std::ifstream(file.path(), std::ios::binary).rdbuf()).str().find("OnNewSentence") != std::string::npos)
|
||||||
|
Loading…
Reference in New Issue
Block a user