mirror of
https://github.com/wiiu-env/libnotifications.git
synced 2026-08-30 20:54:20 -05:00
Properly implement NotificationModule_SetDefaultValue typechecks for C and C++
This commit is contained in:
68
tests/parameter_checker/src_cpp/main.cpp
Normal file
68
tests/parameter_checker/src_cpp/main.cpp
Normal 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;
|
||||
}
|
||||
Reference in New Issue
Block a user