#include "prx/libSceProprietaryVoiceChatHelperPrx/include/Api.hpp" #include "prx/libc/include/general/VabiMacros.hpp" #include #include #include #include static void Require(bool value, const char* what) { if (value) return; std::printf("ProprietaryVoiceChatHelper: %s\n", what); std::abort(); } template static bool Throws(TCall call) { try { call(); } catch (const TError&) { return true; } return false; } template static bool ThrowsMessage(TCall call, const char* message) { try { call(); } catch (const TError& error) { return std::string(error.what()).find(message) != std::string::npos; } return false; } int main() { Require(Throws([] { sceProprietaryVoiceChatHelperSetVoiceChatState(); }), "setting the state before initialization did not throw"); Require(Throws([] { sceProprietaryVoiceChatHelperGetVoiceChatUsageState(); }), "reading the usage state before initialization did not throw"); Require(Throws([] { sceProprietaryVoiceChatHelperGetVoiceChat(); }), "getting voice chat before initialization did not throw"); Require(Throws([] { sceProprietaryVoiceChatHelperTerminate(); }), "terminating before initialization did not throw"); Require(sceProprietaryVoiceChatHelperInitialize() == 0, "initialization failed"); Require(Throws([] { sceProprietaryVoiceChatHelperInitialize(); }), "initializing twice did not throw"); Require(sceProprietaryVoiceChatHelperSetVoiceChatState() == 0, "setting the state failed"); Require(Throws([] { sceProprietaryVoiceChatHelperGetVoiceChatUsageState(); }), "reading the unknown usage state did not throw"); Require(Throws([] { sceProprietaryVoiceChatHelperGetVoiceChat(); }), "calling unknown voice chat export did not throw"); Require(sceProprietaryVoiceChatHelperTerminate() == 0, "termination failed"); Require(ThrowsMessage([] { sceProprietaryVoiceChatHelperSetVoiceChatState(); }, "library not initialized"), "setting the state after termination did not throw"); Require(ThrowsMessage([] { sceProprietaryVoiceChatHelperGetVoiceChat(); }, "library not initialized"), "getting voice chat after termination did not throw"); Require(ThrowsMessage([] { sceProprietaryVoiceChatHelperGetVoiceChatUsageState(); }, "library not initialized"), "reading the usage state after termination did not throw"); Require(Throws([] { sceProprietaryVoiceChatHelperTerminate(); }), "terminating a second time did not throw"); Require(sceProprietaryVoiceChatHelperInitialize() == 0, "initialization after termination failed"); Require(sceProprietaryVoiceChatHelperTerminate() == 0, "termination after reinitialization failed"); Require(Throws([] { sceProprietaryVoiceChatHelperTerminate(); }), "terminating a second time did not throw"); std::puts("ProprietaryVoiceChatHelper tests passed"); return 0; }