]> git.ipfire.org Git - thirdparty/zstd.git/commitdiff
Fix ZSTD_getErrorString and add tests 538/head
authorSean Purcell <me@seanp.xyz>
Wed, 8 Feb 2017 23:31:47 +0000 (15:31 -0800)
committerSean Purcell <me@seanp.xyz>
Thu, 9 Feb 2017 01:28:49 +0000 (17:28 -0800)
lib/common/zstd_common.c
tests/fuzzer.c

index 749b2870c3d2d0534abc5f1c627050b7698c7041..8408a589ae8d92ad26e983c138080ca98160160d 100644 (file)
@@ -41,7 +41,7 @@ ZSTD_ErrorCode ZSTD_getErrorCode(size_t code) { return ERR_getErrorCode(code); }
 
 /*! ZSTD_getErrorString() :
 *   provides error code string from enum */
-const char* ZSTD_getErrorString(ZSTD_ErrorCode code) { return ERR_getErrorName(code); }
+const char* ZSTD_getErrorString(ZSTD_ErrorCode code) { return ERR_getErrorString(code); }
 
 
 /*=**************************************************************
index 60546c07a7d18912b1e2c6f27a2046c5000cbc92..84d2c0237b81010aa95599ec05789c1216b46dab 100644 (file)
@@ -505,6 +505,16 @@ static int basicUnitTests(U32 seed, double compressibility)
       if (r != _3BYTESTESTLENGTH) goto _output_error; }
     DISPLAYLEVEL(4, "OK \n");
 
+    /* error string tests */
+    DISPLAYLEVEL(4, "test%3i : testing ZSTD error code strings : ", testNb++);
+    if (strcmp("No error detected", ZSTD_getErrorName((ZSTD_ErrorCode)(0-ZSTD_error_no_error))) != 0) goto _output_error;
+    if (strcmp("No error detected", ZSTD_getErrorString(ZSTD_error_no_error)) != 0) goto _output_error;
+    if (strcmp("Unspecified error code", ZSTD_getErrorString((ZSTD_ErrorCode)(0-ZSTD_error_GENERIC))) != 0) goto _output_error;
+    if (strcmp("Error (generic)", ZSTD_getErrorName((size_t)0-ZSTD_error_GENERIC)) != 0) goto _output_error;
+    if (strcmp("Error (generic)", ZSTD_getErrorString(ZSTD_error_GENERIC)) != 0) goto _output_error;
+    if (strcmp("No error detected", ZSTD_getErrorName(ZSTD_error_GENERIC)) != 0) goto _output_error;
+    DISPLAYLEVEL(4, "OK \n");
+
 _end:
     free(CNBuffer);
     free(compressedBuffer);