Added the UTF-8 tests to the uiWindow test.
This commit is contained in:
parent
9bc2cccb2d
commit
16d2380adc
|
@ -97,8 +97,8 @@ extern const char testUTF8Combined[];
|
||||||
extern const char testUTF8InvalidInput[];
|
extern const char testUTF8InvalidInput[];
|
||||||
extern const char testUTF8InvalidOutput[];
|
extern const char testUTF8InvalidOutput[];
|
||||||
extern bool utf8equal(const char *s, const char *t);
|
extern bool utf8equal(const char *s, const char *t);
|
||||||
extern void utf8diffErrorfFull(const char *file, long line, const char *msg, const char *got, const char *want);
|
extern void utf8diffErrorFull(const char *file, long line, const char *msg, const char *got, const char *want);
|
||||||
#define utf8diffErrorf(msg, got, want) utf8diffErrorfFull(__FILE__, __LINE__, msg, got, want)
|
#define utf8diffError(msg, got, want) utf8diffErrorFull(__FILE__, __LINE__, msg, got, want)
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -83,7 +83,7 @@ static void utf8hexdump(char buf[64], const char *s)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void utf8diffErrorfFull(const char *file, long line, const char *msg, const char *got, const char *want)
|
void utf8diffErrorFull(const char *file, long line, const char *msg, const char *got, const char *want)
|
||||||
{
|
{
|
||||||
char a[64], b[64];
|
char a[64], b[64];
|
||||||
|
|
||||||
|
|
|
@ -26,13 +26,59 @@ Test(InitialWindowTitleIsEmptyString)
|
||||||
|
|
||||||
w = uiNewWindow();
|
w = uiNewWindow();
|
||||||
title = uiWindowTitle(w);
|
title = uiWindowTitle(w);
|
||||||
// TODO have a utf8cmp()
|
if (!utf8equal(title, testUTF8Empty))
|
||||||
if (*title != 0)
|
utf8diffError("brand new uiWindow has wrong title", title, testUTF8Empty);
|
||||||
// TODO have a diffUTF8
|
|
||||||
TestErrorf("brand new uiWindow has wrong title:" diff("%s"),
|
|
||||||
title, "(empty string)");
|
|
||||||
uiControlFree(uiControl(w));
|
uiControlFree(uiControl(w));
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO check that SetTitle works, and also that it sanitizes
|
static void testSetWindowTitleImplFull(const char *file, long line, const char *title, const char *want)
|
||||||
// TODO for all the above, check that the underlying title was also set appropriately
|
{
|
||||||
|
uiWindow *w;
|
||||||
|
const char *got;
|
||||||
|
|
||||||
|
w = uiNewWindow();
|
||||||
|
uiWindowSetTitle(w, title);
|
||||||
|
got = uiWindowTitle(w);
|
||||||
|
if (!utf8equal(got, want))
|
||||||
|
utf8diffErrorFull(file, line, "uiWindowTitle() reported wrong title after uiWindowSetTitle()", got, want);
|
||||||
|
uiControlFree(uiControl(w));
|
||||||
|
}
|
||||||
|
|
||||||
|
#define testSetWindowTitleImpl(title, want) testSetWindowTitleImplFull(__FILE__, __LINE__, title, want)
|
||||||
|
|
||||||
|
Test(SetWindowTitle_Empty)
|
||||||
|
{
|
||||||
|
testSetWindowTitleImpl(testUTF8Empty, testUTF8Empty);
|
||||||
|
}
|
||||||
|
|
||||||
|
Test(SetWindowTitle_ASCIIOnly)
|
||||||
|
{
|
||||||
|
testSetWindowTitleImpl(testUTF8ASCIIOnly, testUTF8ASCIIOnly);
|
||||||
|
}
|
||||||
|
|
||||||
|
Test(SetWindowTitle_WithTwoByte)
|
||||||
|
{
|
||||||
|
testSetWindowTitleImpl(testUTF8WithTwoByte, testUTF8WithTwoByte);
|
||||||
|
}
|
||||||
|
|
||||||
|
Test(SetWindowTitle_WithThreeByte)
|
||||||
|
{
|
||||||
|
testSetWindowTitleImpl(testUTF8WithThreeByte, testUTF8WithThreeByte);
|
||||||
|
}
|
||||||
|
|
||||||
|
Test(SetWindowTitle_WithFourByte)
|
||||||
|
{
|
||||||
|
testSetWindowTitleImpl(testUTF8WithFourByte, testUTF8WithFourByte);
|
||||||
|
}
|
||||||
|
|
||||||
|
Test(SetWindowTitle_Combined)
|
||||||
|
{
|
||||||
|
testSetWindowTitleImpl(testUTF8Combined, testUTF8Combined);
|
||||||
|
}
|
||||||
|
|
||||||
|
Test(SetWindowTitle_Invalid)
|
||||||
|
{
|
||||||
|
testSetWindowTitleImpl(testUTF8InvalidInput, testUTF8InvalidOutput);
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO for all the above, check that the underlying OS-level title was also set appropriately
|
||||||
|
|
Loading…
Reference in New Issue