From c552065e80c92ad150d33a23513ea0f8f2bfea6f Mon Sep 17 00:00:00 2001 From: Garrett D'Amore Date: Thu, 10 Aug 2017 23:33:06 -0700 Subject: Verify errno handling works; use table driven approach. --- tests/errors.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 tests/errors.c (limited to 'tests/errors.c') diff --git a/tests/errors.c b/tests/errors.c new file mode 100644 index 00000000..f5e857e2 --- /dev/null +++ b/tests/errors.c @@ -0,0 +1,33 @@ +// +// Copyright 2016 Garrett D'Amore +// +// 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 "convey.h" +#include "nng.c" +#include +#include + +TestMain("Error messages work", { + + Convey("Known errors work", { + So(strcmp(nng_strerror(NNG_ECLOSED), "Object closed") == 0); + So(strcmp(nng_strerror(NNG_ETIMEDOUT), "Timed out") == 0); + }); + Convey("We always get a valid error", { + for (unsigned i = 1; i < 0x1000000; i = i * 2 + 100) { + So(nng_strerror(i) != NULL); + } + }); + Convey("System errors work", { + So(strcmp(nng_strerror(NNG_ESYSERR + ENOENT), + strerror(ENOENT)) == 0); + So(strcmp(nng_strerror(NNG_ESYSERR + EINVAL), + strerror(EINVAL)) == 0); + + }); +}) -- cgit v1.2.3-70-g09d2