diff options
| author | Garrett D'Amore <garrett@damore.org> | 2019-12-21 10:20:55 -0800 |
|---|---|---|
| committer | Garrett D'Amore <garrett@damore.org> | 2019-12-24 00:34:29 -0800 |
| commit | 3f7561417bec08226bcfeb107d94be0dbf71b09e (patch) | |
| tree | 409901d7929df5eeb7295ab971b34c2e1040f507 /tests/base64.c | |
| parent | 9e7a4aff25139703bbc375b6dda263d6d42341a8 (diff) | |
| download | nng-3f7561417bec08226bcfeb107d94be0dbf71b09e.tar.gz nng-3f7561417bec08226bcfeb107d94be0dbf71b09e.tar.bz2 nng-3f7561417bec08226bcfeb107d94be0dbf71b09e.zip | |
fixes #1032 Figure out Darwin bustedness
fixes #1035 Convey is awkward -- consider acutest.h
This represents a rather large effort towards cleaning up our
testing and optional configuration infrastructure.
A separate test library is built by default, which is static, and
includes some useful utilities design to make it easier to write
shorter and more robust (not timing dependent) tests. This also means
that we can cover pretty nearly all the tests (protocols etc.) in
every case, even if the shipped image will be minimized.
Subsystems which are optional can now use a few new macros to configure
what they need see nng_sources_if, nng_headers_if, and nng_defines_if.
This goes a long way to making the distributed CMakefiles a lot simpler.
Additionally, tests for different parts of the tree can now be located
outside of the tests/ tree, so that they can be placed next to the code
that they are testing.
Beyond the enabling work, the work has only begun, but these changes
have resolved the most often failing tests for Darwin in the cloud.
Diffstat (limited to 'tests/base64.c')
| -rw-r--r-- | tests/base64.c | 84 |
1 files changed, 0 insertions, 84 deletions
diff --git a/tests/base64.c b/tests/base64.c deleted file mode 100644 index 1781c5ef..00000000 --- a/tests/base64.c +++ /dev/null @@ -1,84 +0,0 @@ -// -// Copyright 2018 Staysail Systems, Inc. <info@staysail.tech> -// Copyright 2018 Capitar IT Group BV <info@capitar.com> -// -// This software is supplied under the terms of the MIT License, a -// copy of which should be located in the distribution where this -// file was obtained (LICENSE.txt). A copy of the license may also be -// found online at https://opensource.org/licenses/MIT. -// - -#include <string.h> -#include <nng/nng.h> - -#include "convey.h" -#include "supplemental/base64/base64.h" - -typedef struct testcase { - char *decoded; - char *encoded; -} testcase; - -static struct testcase cases[] = { - // clang-format off - { "", "" }, - { "f", "Zg==" }, - { "fo", "Zm8=" }, - { "foo", "Zm9v" }, - { "foob", "Zm9vYg==" }, - { "fooba", "Zm9vYmE=" }, - { "foobar", "Zm9vYmFy" }, - { NULL, NULL } - // clang-format on -}; - -TestMain("Base64 Verification", { - - Convey("Encode Works", { - int rv; - char buf[1024]; - int i; - void *dec; - - for (i = 0; (dec = cases[i].decoded) != NULL; i++) { - rv = nni_base64_encode(dec, strlen(dec), buf, 1024); - So(rv >= 0); - So(rv == (int) strlen(cases[i].encoded)); - buf[rv] = 0; - So(strcmp(buf, cases[i].encoded) == 0); - } - }); - - Convey("Decode Works", { - int rv; - char buf[1024]; - int i; - void *enc; - - for (i = 0; (enc = cases[i].encoded) != NULL; i++) { - rv = nni_base64_decode( - enc, strlen(enc), (void *) buf, 1024); - So(rv >= 0); - So(rv == (int) strlen(cases[i].decoded)); - buf[rv] = 0; - So(strcmp(buf, cases[i].decoded) == 0); - } - }); - - Convey("Overflow Works", { - char tmp[1024]; - for (int i = 1; cases[i].decoded != NULL; i++) { - void *enc = cases[i].encoded; - void *dec = cases[i].decoded; - void *buf = tmp; - - So(nni_base64_encode( - dec, strlen(dec), buf, strlen(enc) - 1) == -1); - So(nni_base64_encode(dec, strlen(dec), buf, 0) == -1); - - So(nni_base64_decode( - enc, strlen(enc), buf, strlen(dec) - 1) == -1); - So(nni_base64_encode(enc, strlen(enc), buf, 0) == -1); - } - }) -}) |
