diff options
author | Daniel Silverstone <dsilvers@netsurf-browser.org> | 2009-02-14 11:39:30 +0000 |
---|---|---|
committer | Daniel Silverstone <dsilvers@netsurf-browser.org> | 2009-02-14 11:39:30 +0000 |
commit | e4b569a69ce897c80ab260376bbfb510d3bc79ce (patch) | |
tree | c1caf8c0442ca4f109725609125f5dac9141121e /test | |
parent | dfef7828d57e6e4988f2dac90ecf40293f7a8209 (diff) | |
download | libcss-e4b569a69ce897c80ab260376bbfb510d3bc79ce.tar.gz libcss-e4b569a69ce897c80ab260376bbfb510d3bc79ce.tar.bz2 |
Move css_error_from_string into test utilities
svn path=/trunk/libcss/; revision=6480
Diffstat (limited to 'test')
-rw-r--r-- | test/number.c | 2 | ||||
-rw-r--r-- | test/testutils.h | 33 |
2 files changed, 35 insertions, 0 deletions
diff --git a/test/number.c b/test/number.c index dd44730..bc5ea52 100644 --- a/test/number.c +++ b/test/number.c @@ -2,6 +2,8 @@ #include <stdlib.h> #include <string.h> +#include "libcss/libcss.h" + #include "utils/utils.h" #include "testutils.h" diff --git a/test/testutils.h b/test/testutils.h index 3e23c07..5471fed 100644 --- a/test/testutils.h +++ b/test/testutils.h @@ -4,6 +4,8 @@ #include <stdbool.h> #include <stdio.h> #include <stdlib.h> +#include <string.h> +#include <sys/types.h> #ifndef UNUSED #define UNUSED(x) ((x) = (x)) @@ -147,4 +149,35 @@ size_t parse_filesize(const char *filename) } +/** + * Convert a string representation of an error name to a LibCSS error code + * + * \param str String containing error name + * \param len Length of string (bytes) + * \return LibCSS error code, or CSS_OK if unknown + */ +css_error css_error_from_string(const char *str, size_t len); +css_error css_error_from_string(const char *str, size_t len) +{ + if (strncmp(str, "CSS_OK", len) == 0) { + return CSS_OK; + } else if (strncmp(str, "CSS_NOMEM", len) == 0) { + return CSS_NOMEM; + } else if (strncmp(str, "CSS_BADPARM", len) == 0) { + return CSS_BADPARM; + } else if (strncmp(str, "CSS_INVALID", len) == 0) { + return CSS_INVALID; + } else if (strncmp(str, "CSS_FILENOTFOUND", len) == 0) { + return CSS_FILENOTFOUND; + } else if (strncmp(str, "CSS_NEEDDATA", len) == 0) { + return CSS_NEEDDATA; + } else if (strncmp(str, "CSS_BADCHARSET", len) == 0) { + return CSS_BADCHARSET; + } else if (strncmp(str, "CSS_EOF", len) == 0) { + return CSS_EOF; + } + + return CSS_OK; +} + #endif |