mirror of
https://github.com/boykopovar/AnyPS5.git
synced 2026-10-22 16:43:05 -05:00
68 lines
2.4 KiB
C++
68 lines
2.4 KiB
C++
#include "SceTypes.hpp"
|
|
#include "prx/libc/include/general/VabiMacros.hpp"
|
|
|
|
#include <cstdio>
|
|
#include <cstdlib>
|
|
#include <stdexcept>
|
|
|
|
extern "C" {
|
|
int APS5_VABI sceNpGameIntentInitParamInit(NpGameIntentInitParam* param);
|
|
int APS5_VABI sceNpGameIntentInfoInit(NpGameIntentInfo* info);
|
|
int APS5_VABI sceNpGameIntentInitialize(const void* initParam);
|
|
int APS5_VABI sceNpGameIntentReceiveIntent(NpGameIntentInfo* intentInfo);
|
|
int APS5_VABI sceNpGameIntentGetPropertyValueString(const NpGameIntentData* intentData, const char* key, char* valueBuf, size_t bufSize);
|
|
int APS5_VABI sceNpGameIntentVshInitialize(void);
|
|
int APS5_VABI sceNpGameIntentVshTerminate(void);
|
|
int APS5_VABI sceNpGameIntentTerminate(void);
|
|
}
|
|
|
|
static void Require(bool value, const char* what) {
|
|
if (value) return;
|
|
std::printf("NpGameIntent: %s\n", what);
|
|
std::abort();
|
|
}
|
|
|
|
template <typename TError, typename TCall>
|
|
static bool Throws(TCall call) {
|
|
try {
|
|
call();
|
|
} catch (const TError&) {
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
int main() {
|
|
constexpr int kIntentNotFound = -2141898746;
|
|
constexpr int kValueNotFound = -2141898745;
|
|
|
|
Require(Throws<std::invalid_argument>([] { sceNpGameIntentInitParamInit(nullptr); }),
|
|
"null param init did not throw");
|
|
|
|
NpGameIntentInitParam initParam{};
|
|
Require(sceNpGameIntentInitParamInit(&initParam) == 0, "param init failed");
|
|
Require(initParam.size == sizeof(NpGameIntentInitParam), "param size mismatch");
|
|
|
|
Require(Throws<std::invalid_argument>([] { sceNpGameIntentInfoInit(nullptr); }),
|
|
"null info init did not throw");
|
|
|
|
NpGameIntentInfo info{};
|
|
Require(sceNpGameIntentInfoInit(&info) == 0, "info init failed");
|
|
Require(info.size == sizeof(NpGameIntentInfo), "info size mismatch");
|
|
Require(info.user_id == -1, "info user_id mismatch");
|
|
|
|
Require(sceNpGameIntentInitialize(&initParam) == 0, "initialization failed");
|
|
Require(sceNpGameIntentReceiveIntent(&info) == kIntentNotFound, "receive intent mismatch");
|
|
|
|
char buf[64]{};
|
|
Require(sceNpGameIntentGetPropertyValueString(&info.intent_data, "key", buf, sizeof(buf)) == kValueNotFound,
|
|
"get property value mismatch");
|
|
|
|
Require(sceNpGameIntentVshInitialize() == 0, "vsh init failed");
|
|
Require(sceNpGameIntentVshTerminate() == 0, "vsh terminate failed");
|
|
Require(sceNpGameIntentTerminate() == 0, "terminate failed");
|
|
|
|
std::puts("NpGameIntent tests passed");
|
|
return 0;
|
|
}
|