src/lib/x11_gc.o \
src/lib/x11_sel.o
-TEST_BINS = \
- tests/libedit
+TEST_BINS = tests/libedit tests/test_tide
include config.mk
tests/libedit: tests/libedit.o tests/lib/buf.o tests/lib/utf8.o libedit.a
-# define implicit rule for building binaries
+# define implicit rule for building normal binaries
bin/%: src/%.o libedit.a
$(LD) -o $@ $^ $(LDFLAGS)
+# define implicit rule for building tests binaries
+tests/%: tests/%.o libedit.a
+ $(LD) -o $@ $^ $(LDFLAGS)
+
# load generate dependencies
-include src/*.d src/lib/*.d tests/*.d tests/lib/*.d
/* stub some functions for test so we don't interact with the outside world too much */
#ifdef TEST
#define job_start(cmd, data, ndata, dest) \
- ((void)cmd, (void)data, (void)ndata, (void)dest)
-#define job_run(char** cmd)
- ((void)cmd, 0)
-#define x11_sel_get(x, selid, str) \
- ((void)x, (void)selid, (void)str)
+ ((void)(cmd), (void)(data), (void)(ndata), (void)(dest))
+#define job_run(cmd) \
+ ((void)(cmd), 0)
+#define x11_sel_set(x, selid, str) \
+ ((void)(x), (void)(selid), (void)(str))
#define x11_sel_get(x, selid, cbfn) \
- ((void)x, (void)selid, (void)cbfn, (void)1)
+ ((void)(x), (void)(selid), (void)(cbfn), 1)
#endif
/* predeclare some things */
--- /dev/null
+#include <time.h>
+
+#define TEST
+#include "src/tide.c"
+
+typedef struct {
+ void *value;
+ int nelem;
+// QCC_showValue show;
+// QCC_freeValue free;
+} QCValue;
+
+typedef struct {
+ int status, nvals;
+ QCValue** vals;
+} QCResult;
+
+typedef int (*QCProp)(QCValue** vals, int nvals);
+
+typedef QCValue* (*QCGenFn)(void);
+
+
+
+
+void qc_init(int seed) {
+ srand(seed ? seed : time(NULL));
+}
+
+QCResult vforAll(QCProp prop, int nvals, va_list vals) {
+ /* generate the input values */
+ QCValue** values = NULL;
+ if (nvals) {
+ values = malloc(sizeof(QCValue*) * nvals);
+ for (int i = 0; i < nvals; i++)
+ values[i] = (va_arg(vals, QCGenFn))();
+ }
+ /* run the test and get the result */
+ QCResult result = { .status = 0 };
+ result.status = prop(values, nvals);
+ result.nvals = nvals;
+ result.vals = values;
+ return result;
+}
+
+int forAll(int num, QCProp prop, int nvals, ...) {
+ (void)num, (void)prop, (void)nvals;
+ int passed = 0;
+ QCResult result;
+ va_list vals;
+ for (int i = 0; i < num; i++) {
+ va_start(vals, nvals);
+ result = vforAll(prop, nvals, vals);
+ va_end(vals);
+ if (!result.status) break;
+ passed++;
+ }
+ /* show 'em the results */
+ if (passed == num) {
+ printf("%d tests passed\n", passed);
+ } else if (result.status == 0) {
+ printf("Falsifiable after %d tests\n", passed+1);
+ return 0;
+ }
+ return 1;
+}
+
+/************************************************/
+
+void tide_init(void) {
+ if (!ShellCmd[0]) ShellCmd[0] = getenv("SHELL");
+ if (!ShellCmd[0]) ShellCmd[0] = "/bin/sh";
+ win_init(Bindings);
+ view_init(&Regions[TAGS], NULL);
+ view_init(&Regions[EDIT], NULL);
+ view_putstr(win_view(TAGS), TagString);
+ view_resize(win_view(TAGS), 640, 1);
+ buf_logclear(win_buf(TAGS));
+ win_prop_set("TIDE", "", "tide");
+ xupdate(NULL);
+}
+
+
+int main(int argc, char** argv) {
+ (void)argc, (void)argv, (void)usage;
+ puts("running prop tests");
+ return 0;
+}