2022-01-29 17:14:15 +01:00
|
|
|
#include <hex/test/tests.hpp>
|
|
|
|
|
|
|
|
#include <hex/helpers/net.hpp>
|
|
|
|
#include <hex/helpers/file.hpp>
|
2022-03-04 11:36:37 +01:00
|
|
|
#include <hex/helpers/fs.hpp>
|
2022-01-29 17:14:15 +01:00
|
|
|
|
|
|
|
using namespace std::literals::string_literals;
|
|
|
|
|
|
|
|
TEST_SEQUENCE("StoreAPI") {
|
|
|
|
hex::Net net;
|
|
|
|
|
|
|
|
auto result = net.getString(ImHexApiURL + "/store"s).get();
|
|
|
|
|
|
|
|
if (result.code != 200)
|
|
|
|
TEST_FAIL();
|
|
|
|
|
|
|
|
if (result.body.empty())
|
|
|
|
TEST_FAIL();
|
|
|
|
|
|
|
|
TEST_SUCCESS();
|
|
|
|
};
|
|
|
|
|
|
|
|
TEST_SEQUENCE("TipsAPI") {
|
|
|
|
hex::Net net;
|
|
|
|
|
|
|
|
auto result = net.getString(ImHexApiURL + "/tip"s).get();
|
|
|
|
|
|
|
|
if (result.code != 200)
|
|
|
|
TEST_FAIL();
|
|
|
|
|
|
|
|
if (result.body.empty())
|
|
|
|
TEST_FAIL();
|
|
|
|
|
|
|
|
TEST_SUCCESS();
|
|
|
|
};
|
|
|
|
|
|
|
|
TEST_SEQUENCE("ContentAPI") {
|
|
|
|
hex::Net net;
|
|
|
|
|
2022-03-04 14:34:37 +01:00
|
|
|
const auto FilePath = std::fs::current_path() / "elf.hexpat";
|
2022-01-29 17:14:15 +01:00
|
|
|
|
|
|
|
auto result = net.downloadFile("https://api.werwolv.net/content/imhex/patterns/elf.hexpat", FilePath).get();
|
|
|
|
|
|
|
|
TEST_ASSERT(result.code == 200);
|
|
|
|
|
2022-03-04 14:34:37 +01:00
|
|
|
hex::fs::File file(FilePath, hex::fs::File::Mode::Read);
|
2022-01-29 17:14:15 +01:00
|
|
|
if (!file.isValid())
|
|
|
|
TEST_FAIL();
|
|
|
|
|
|
|
|
if (file.getSize() == 0)
|
|
|
|
TEST_FAIL();
|
|
|
|
|
|
|
|
TEST_SUCCESS();
|
|
|
|
};
|