2018-02-28 00:21:10 -06:00
|
|
|
// 27 february 2018
|
2018-02-27 22:44:50 -06:00
|
|
|
#ifndef TODO_TEST
|
|
|
|
#error TODO this is where libui itself goes
|
|
|
|
#endif
|
2018-02-28 18:43:29 -06:00
|
|
|
#include <inttypes.h>
|
2018-02-28 21:07:06 -06:00
|
|
|
#include "testing.h"
|
2018-02-27 22:44:50 -06:00
|
|
|
|
2018-02-28 18:43:29 -06:00
|
|
|
#include <stddef.h>
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
typedef struct uiOpenTypeFeatures uiOpenTypeFeatures;
|
|
|
|
typedef int uiForEach;
|
|
|
|
enum { uiForEachContinue, uiForEachStop };
|
|
|
|
typedef uiForEach (*uiOpenTypeFeaturesForEachFunc)(const uiOpenTypeFeatures *otf, char a, char b, char c, char d, uint32_t value, void *data);
|
|
|
|
#define uiprivNew(x) ((x *) malloc(sizeof (x)))
|
|
|
|
#define uiprivAlloc(x,y) malloc(x)
|
|
|
|
#define uiprivRealloc(x,y,z) realloc(x,y)
|
|
|
|
#define uiprivFree free
|
|
|
|
#include "opentype.c"
|
|
|
|
|
2018-03-03 15:24:10 -06:00
|
|
|
static void freeOpenType(void *otf)
|
|
|
|
{
|
|
|
|
uiFreeOpenTypeFeatures((uiOpenTypeFeatures *) otf);
|
|
|
|
}
|
|
|
|
|
2018-02-28 18:43:29 -06:00
|
|
|
testingTest(OpenTypeFeaturesAddGet)
|
2018-02-27 22:44:50 -06:00
|
|
|
{
|
2018-02-28 18:43:29 -06:00
|
|
|
uiOpenTypeFeatures *otf;
|
|
|
|
uint32_t value;
|
|
|
|
|
|
|
|
otf = uiNewOpenTypeFeatures();
|
2018-03-03 15:24:10 -06:00
|
|
|
testingTDefer(t, freeOpenType, otf);
|
2018-02-28 18:43:29 -06:00
|
|
|
uiOpenTypeFeaturesAdd(otf, 'a', 'b', 'c', 'd', 12345);
|
2018-03-03 15:24:10 -06:00
|
|
|
if (!uiOpenTypeFeaturesGet(otf, 'a', 'b', 'c', 'd', &value))
|
|
|
|
testingTFatalf(t, "uiOpenTypeFeaturesGet() failed to get feature we added");
|
|
|
|
if (value != 12345)
|
|
|
|
testingTFatalf(t, "feature abcd: got %" PRIu32 ", want 12345", value);
|
2018-02-27 22:44:50 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
int main(void)
|
|
|
|
{
|
|
|
|
return testingMain();
|
|
|
|
}
|