Files
WoW-Hybrid-gateway/tests/wine_bundle_paths_test.c
praxisandClaude Fable 5.2 7f2139d8d0 Offline test fixtures
883 files, from working commit b1a079a.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-19 01:32:48 +02:00

54 lines
3.7 KiB
C

#include "wine_bundle_paths.h"
#include <assert.h>
#include <string.h>
#include <wchar.h>
static struct gw_bundle_paths paths;
static wchar_t long_path[GW_BUNDLE_PATH_CAP];
int main(void) {
const wchar_t *exe = L"Z:\\mnt\\Games\\Octo\\runtime\\native-client\\_classic_beta_\\WowB.exe";
assert(gw_bundle_paths_resolve(GW_BUNDLE_WINE, exe, &paths) == 0);
assert(wcscmp(paths.root, L"Z:\\mnt\\Games\\Octo") == 0);
assert(wcscmp(paths.backend, L"Z:\\mnt\\Games\\Octo\\build\\libgateway_wine_wire.so") == 0);
assert(wcscmp(paths.core, L"Z:\\mnt\\Games\\Octo\\build\\libgateway_native.so") == 0);
assert(wcscmp(paths.codec, L"Z:\\mnt\\Games\\Octo\\build\\forever-schema\\libforever_codec.so") == 0);
assert(wcscmp(paths.wine_loader_name, L"\\??\\Z:\\mnt\\Games\\Octo\\build\\libgateway_wine_wire.so") == 0);
assert(gw_bundle_paths_resolve(GW_BUNDLE_NATIVE_WINDOWS,
L"C:/G\u00e5mes/Octo/RUNTIME/NATIVE-CLIENT/_CLASSIC_BETA_/wowb.EXE", &paths) == 0);
assert(wcscmp(paths.backend, L"C:\\G\u00e5mes\\Octo\\RUNTIME\\NATIVE-CLIENT\\_CLASSIC_BETA_\\GWNativeBackend.dll") == 0);
assert(wcscmp(paths.codec, L"C:\\G\u00e5mes\\Octo\\RUNTIME\\NATIVE-CLIENT\\_CLASSIC_BETA_\\forever_codec.dll") == 0);
assert(paths.core[0] == 0 && paths.wine_loader_name[0] == 0);
assert(gw_bundle_paths_resolve(GW_BUNDLE_NATIVE_WINDOWS, L"C:\\WowB.exe", &paths) == 0);
assert(wcscmp(paths.root, L"C:\\") == 0);
assert(wcscmp(paths.backend, L"C:\\GWNativeBackend.dll") == 0);
assert(gw_bundle_paths_resolve(GW_BUNDLE_WINE, L"Z:\\bad\\WowB.exe", &paths) != 0);
assert(paths.root[0] == 0 && paths.backend[0] == 0);
assert(gw_bundle_paths_resolve(GW_BUNDLE_WINE, L"Z:\\a\\..\\runtime\\native-client\\_classic_beta_\\WowB.exe", &paths) != 0);
assert(gw_bundle_paths_resolve(GW_BUNDLE_WINE, L"Z:\\a\\\\runtime\\native-client\\_classic_beta_\\WowB.exe", &paths) != 0);
assert(gw_bundle_paths_resolve(GW_BUNDLE_NATIVE_WINDOWS, L"\\\\server\\share\\Octo\\runtime\\native-client\\_classic_beta_\\WowB.exe", &paths) == 0);
assert(wcscmp(paths.backend, L"\\\\server\\share\\Octo\\runtime\\native-client\\_classic_beta_\\GWNativeBackend.dll") == 0);
assert(gw_bundle_paths_resolve(GW_BUNDLE_WINE, L"\\\\server\\share\\runtime\\native-client\\_classic_beta_\\WowB.exe", &paths) != 0);
assert(gw_bundle_paths_resolve(GW_BUNDLE_NATIVE_WINDOWS, L"D:\\Player Folder\\WowB.exe", &paths) == 0);
assert(wcscmp(paths.root, L"D:\\Player Folder") == 0);
assert(wcscmp(paths.backend, L"D:\\Player Folder\\GWNativeBackend.dll") == 0);
assert(wcscmp(paths.codec, L"D:\\Player Folder\\forever_codec.dll") == 0);
assert(gw_bundle_paths_resolve(GW_BUNDLE_NATIVE_WINDOWS, L"Z:\\games\\Octo\\WowB.exe", &paths) == 0);
assert(wcscmp(paths.backend, L"Z:\\games\\Octo\\GWNativeBackend.dll") == 0);
const wchar_t *rejected[] = {
L"WowB.exe", L"C:WowB.exe", L"C:\\Game\\Other.exe",
L"C:\\Game\\..\\WowB.exe", L"C:\\Game\\.\\WowB.exe",
L"C:\\Game\\\\WowB.exe", L"\\\\server\\WowB.exe",
L"\\\\?\\C:\\Game\\WowB.exe", L"C:\\Game:stream\\WowB.exe"
};
for (size_t i = 0; i < sizeof rejected / sizeof rejected[0]; ++i) {
assert(gw_bundle_paths_resolve(GW_BUNDLE_NATIVE_WINDOWS, rejected[i], &paths) != 0);
assert(paths.root[0] == 0 && paths.backend[0] == 0 && paths.codec[0] == 0);
}
assert(gw_bundle_paths_resolve((enum gw_bundle_platform)3, exe, &paths) != 0);
for (size_t i = 0; i < GW_BUNDLE_PATH_CAP; ++i) long_path[i] = L'a';
assert(gw_bundle_paths_resolve(GW_BUNDLE_WINE, long_path, &paths) != 0);
assert(gw_bundle_paths_resolve(GW_BUNDLE_WINE, 0, &paths) != 0);
assert(gw_bundle_paths_resolve(GW_BUNDLE_WINE, exe, 0) != 0);
return 0;
}