Properly implement NotificationModule_SetDefaultValue typechecks for C and C++

This commit is contained in:
Maschell
2026-01-15 19:47:44 +01:00
parent 8caeeaa8a8
commit 3792c97d68
14 changed files with 858 additions and 19 deletions

View File

@@ -0,0 +1,68 @@
#include <coreinit/thread.h>
#include <notifications/notifications.h>
// Dummy callback for testing
void my_callback(NotificationModuleHandle h, void* ctx) {
(void)h;
(void)ctx;
}
int main(int argc, char **argv) {
(void)argc;
(void)argv;
// 1. Initialize the library
NotificationModule_InitLibrary();
// 2. Test Type Checks (Valid Cases)
// These should compile successfully. If the type checks are broken,
// -Werror will cause the build to fail here.
NMColor color = {255, 255, 255, 255};
float duration = 5.0f;
bool keep = true;
int ctx_data = 1;
// Background Color
NotificationModule_SetDefaultValue(
NOTIFICATION_MODULE_NOTIFICATION_TYPE_INFO,
NOTIFICATION_MODULE_DEFAULT_OPTION_BACKGROUND_COLOR,
color
);
// Duration
NotificationModule_SetDefaultValue(
NOTIFICATION_MODULE_NOTIFICATION_TYPE_INFO,
NOTIFICATION_MODULE_DEFAULT_OPTION_DURATION_BEFORE_FADE_OUT,
duration
);
// Callback
NotificationModule_SetDefaultValue(
NOTIFICATION_MODULE_NOTIFICATION_TYPE_INFO,
NOTIFICATION_MODULE_DEFAULT_OPTION_FINISH_FUNCTION,
my_callback
);
// Context
NotificationModule_SetDefaultValue(
NOTIFICATION_MODULE_NOTIFICATION_TYPE_INFO,
NOTIFICATION_MODULE_DEFAULT_OPTION_FINISH_FUNCTION_CONTEXT,
(void*)&ctx_data
);
// Keep
NotificationModule_SetDefaultValue(
NOTIFICATION_MODULE_NOTIFICATION_TYPE_INFO,
NOTIFICATION_MODULE_DEFAULT_OPTION_KEEP_UNTIL_SHOWN,
keep
);
// 3. Test API usage
NotificationModule_AddInfoNotification("CI Test: Build Successful!");
// Deinit
NotificationModule_DeInitLibrary();
return 0;
}