#include #include #include #include #include #include using namespace hex; using namespace hex::plugin::builtin; TEST_SEQUENCE("Providers/ReadWrite") { INIT_PLUGIN("Built-in"); auto &pr = *ImHexApi::Provider::createProvider("hex.builtin.provider.mem_file", true); TEST_ASSERT(pr.getSize() == 0); TEST_ASSERT(!pr.isDirty()); pr.resize(50); TEST_ASSERT(pr.getSize() == 50); TEST_ASSERT(pr.isDirty()); char buf[] = "\x99\x99"; // temporary value that should be overwriten pr.read(0, buf, 2); TEST_ASSERT(std::equal(buf, buf+2, "\x00\x00")); pr.write(0, "\xFF\xFF", 2); char buf2[] = "\x99\x99"; // temporary value that should be overwriten pr.read(0, buf2, 2); TEST_ASSERT(std::equal(buf2, buf2+2, "\xFF\xFF")); TEST_SUCCESS(); }; TEST_SEQUENCE("Providers/InvalidResize") { INIT_PLUGIN("Built-in"); auto &pr = *ImHexApi::Provider::createProvider("hex.builtin.provider.mem_file", true); TEST_ASSERT(!pr.resize(-1)); TEST_SUCCESS(); };