25 lines
1.4 KiB
C
25 lines
1.4 KiB
C
#include "../native/nohelper/startup_locale_text.h"
|
|
#include <assert.h>
|
|
#include <stdio.h>
|
|
static void check(const char *input,const char *expected) {
|
|
char output[2048],again[2048];size_t n=0,m=0;
|
|
assert(gw_locale_text(input,strlen(input),output,sizeof(output),&n));
|
|
assert(n==strlen(expected)&&!memcmp(output,expected,n));
|
|
assert(gw_locale_text(output,n,again,sizeof(again),&m));
|
|
assert(m==n&&!memcmp(again,output,n));
|
|
assert(!gw_locale_text(input,strlen(input),output,n-1,&m));
|
|
}
|
|
int main(void){
|
|
const char *en="SET textLocale \"enUS\"\r\nSET audioLocale \"enUS\"\r\n";
|
|
char out[128];size_t n;
|
|
check("",en);
|
|
check("SET textLocale \"deDE\"\r\nSET audioLocale \"ruRU\"\r\n",en);
|
|
check("set TEXTLOCALE \"frFR\"\n\tSeT\taudioLocale\t\"koKR\"\nSET textLocale \"zhCN\"\n",en);
|
|
check("SET portal \"play\"\nSET gxApi \"D3D11\"","SET portal \"play\"\nSET gxApi \"D3D11\"\r\nSET textLocale \"enUS\"\r\nSET audioLocale \"enUS\"\r\n");
|
|
check("# textLocale is a comment\nSET textLocaleExtra \"keep\"\n","# textLocale is a comment\nSET textLocaleExtra \"keep\"\nSET textLocale \"enUS\"\r\nSET audioLocale \"enUS\"\r\n");
|
|
check("\xef\xbb\xbfSET textLocale \"deDE\"\r\n","\xef\xbb\xbfSET textLocale \"enUS\"\r\nSET audioLocale \"enUS\"\r\n");
|
|
assert(!gw_locale_text("x\0y",3,out,sizeof(out),&n));
|
|
puts("PASS startup enUS configuration: defaults, duplicates, preservation, BOM, bounds, idempotence");
|
|
return 0;
|
|
}
|