Branch data Line data Source code
1 : : // Copyright 2021-2022 David Robillard <d@drobilla.net> 2 : : // SPDX-License-Identifier: ISC 3 : : 4 : : #undef NDEBUG 5 : : 6 : : #include <zix/status.h> 7 : : 8 : : #include <assert.h> 9 : : #include <stdio.h> 10 : : #include <string.h> 11 : : 12 : : static void 13 : 1 : test_strerror(void) 14 : : { 15 : 1 : const char* msg = zix_strerror(ZIX_STATUS_SUCCESS); 16 [ - + ]: 1 : assert(!strcmp(msg, "Success")); 17 : : 18 [ + + ]: 14 : for (int i = ZIX_STATUS_ERROR; i <= ZIX_STATUS_MAX_LINKS; ++i) { 19 : 13 : msg = zix_strerror((ZixStatus)i); 20 [ - + ]: 13 : assert(strcmp(msg, "Success")); 21 : : } 22 : : 23 : 1 : msg = zix_strerror((ZixStatus)-1); 24 [ - + ]: 1 : assert(!strcmp(msg, "Unknown error")); 25 : : 26 : 1 : msg = zix_strerror((ZixStatus)1000000); 27 [ - + ]: 1 : assert(!strcmp(msg, "Unknown error")); 28 : : 29 : 1 : fprintf(stderr, "Success\n"); 30 : 1 : } 31 : : 32 : : int 33 : 1 : main(void) 34 : : { 35 : 1 : test_strerror(); 36 : 1 : return 0; 37 : : }