diff options
author | David Robillard <d@drobilla.net> | 2021-01-02 21:09:27 +0100 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2021-01-02 21:09:27 +0100 |
commit | 1c365945ed2ebd5b9f54eb0c8c5c1c6d97cad712 (patch) | |
tree | 4b77266a9ce3e2a11b59bbd2754869c6ee1d172b /test/test_clipboard.c | |
parent | a92a194b4fc64e0cfa4a88a59e261f236414d61c (diff) | |
download | pugl-1c365945ed2ebd5b9f54eb0c8c5c1c6d97cad712.tar.gz pugl-1c365945ed2ebd5b9f54eb0c8c5c1c6d97cad712.tar.bz2 pugl-1c365945ed2ebd5b9f54eb0c8c5c1c6d97cad712.zip |
Simplify clang-format configuration and format all code
Diffstat (limited to 'test/test_clipboard.c')
-rw-r--r-- | test/test_clipboard.c | 116 |
1 files changed, 58 insertions, 58 deletions
diff --git a/test/test_clipboard.c b/test/test_clipboard.c index c1180b0..5749b65 100644 --- a/test/test_clipboard.c +++ b/test/test_clipboard.c @@ -30,75 +30,75 @@ #include <stddef.h> typedef struct { - PuglWorld* world; - PuglView* views[2]; - PuglTestOptions opts; - bool exposed; + PuglWorld* world; + PuglView* views[2]; + PuglTestOptions opts; + bool exposed; } PuglTest; static PuglStatus onEvent(PuglView* view, const PuglEvent* event) { - PuglTest* test = (PuglTest*)puglGetHandle(view); + PuglTest* test = (PuglTest*)puglGetHandle(view); - if (event->type == PUGL_EXPOSE) { - test->exposed = true; - } + if (event->type == PUGL_EXPOSE) { + test->exposed = true; + } - if (test->opts.verbose) { - printEvent(event, "Event: ", true); - } + if (test->opts.verbose) { + printEvent(event, "Event: ", true); + } - return PUGL_SUCCESS; + return PUGL_SUCCESS; } int main(int argc, char** argv) { - PuglTest test = {puglNewWorld(PUGL_PROGRAM, 0), - {NULL, NULL}, - puglParseTestOptions(&argc, &argv), - false}; - - puglSetClassName(test.world, "Pugl Test"); - - // Set up views - for (unsigned i = 0u; i < 2; ++i) { - test.views[i] = puglNewView(test.world); - puglSetBackend(test.views[i], puglStubBackend()); - puglSetHandle(test.views[i], &test); - puglSetEventFunc(test.views[i], onEvent); - puglSetDefaultSize(test.views[i], 512, 512); - - assert(!puglShow(test.views[i])); - } - - // Update until view is exposed - while (!test.exposed) { - assert(!puglUpdate(test.world, 0.0)); - } - - // Set clipboard text via the first view - puglSetClipboard(test.views[0], NULL, "Text", 5); - - // Get clipboard contents via the second view - const char* type = NULL; - size_t len = 0; - const void* const contents = puglGetClipboard(test.views[1], &type, &len); - - // Check that the data made it over - assert(!strcmp(type, "text/plain")); - assert(len == 5); - assert(contents); - assert(!strcmp((const char*)contents, "Text")); - - // Try setting the clipboard to an unsupported type - assert(puglSetClipboard(test.views[0], "text/csv", "a,b,c", 6)); - - // Tear down - puglFreeView(test.views[0]); - puglFreeView(test.views[1]); - puglFreeWorld(test.world); - - return 0; + PuglTest test = {puglNewWorld(PUGL_PROGRAM, 0), + {NULL, NULL}, + puglParseTestOptions(&argc, &argv), + false}; + + puglSetClassName(test.world, "Pugl Test"); + + // Set up views + for (unsigned i = 0u; i < 2; ++i) { + test.views[i] = puglNewView(test.world); + puglSetBackend(test.views[i], puglStubBackend()); + puglSetHandle(test.views[i], &test); + puglSetEventFunc(test.views[i], onEvent); + puglSetDefaultSize(test.views[i], 512, 512); + + assert(!puglShow(test.views[i])); + } + + // Update until view is exposed + while (!test.exposed) { + assert(!puglUpdate(test.world, 0.0)); + } + + // Set clipboard text via the first view + puglSetClipboard(test.views[0], NULL, "Text", 5); + + // Get clipboard contents via the second view + const char* type = NULL; + size_t len = 0; + const void* const contents = puglGetClipboard(test.views[1], &type, &len); + + // Check that the data made it over + assert(!strcmp(type, "text/plain")); + assert(len == 5); + assert(contents); + assert(!strcmp((const char*)contents, "Text")); + + // Try setting the clipboard to an unsupported type + assert(puglSetClipboard(test.views[0], "text/csv", "a,b,c", 6)); + + // Tear down + puglFreeView(test.views[0]); + puglFreeView(test.views[1]); + puglFreeWorld(test.world); + + return 0; } |