Files
WoW-Hybrid-gateway/tests/client_update_state_test.cpp

21 lines
1.0 KiB
C++

#include "../native/client_update_policy.hpp"
#include <cassert>
#include <sstream>
using namespace gateway::client_update;
int main() {
assert(compare_signatures(true, "signature", true, "signature") == State::current);
assert(compare_signatures(true, "new", true, "old") == State::pending);
assert(compare_signatures(true, "new", false, "") == State::unknown);
assert(compare_signatures(false, "", true, "old") == State::unknown);
assert(compare_signatures(true, "", true, "") == State::unknown);
std::istringstream defaults(""); auto c = read_config(defaults);
assert(manifest_url(c) == "https://dl.hybridgateway.eu/octo/manifest.txt.sig");
std::istringstream custom("#url=bad\r\nurl=https://example.invalid/updates\r\nchannel=test\r\nlaunch=0\r\n");
c = read_config(custom);
assert(manifest_url(c) == "https://example.invalid/updates/test/manifest.txt.sig");
assert(c.at("launch") == "0");
assert(!should_launch(c, false, false));
assert(should_launch(c, true, false));
assert(!should_launch(c, true, true));
}