summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Silverstone <dsilvers@netsurf-browser.org>2009-02-14 11:39:30 +0000
committerDaniel Silverstone <dsilvers@netsurf-browser.org>2009-02-14 11:39:30 +0000
commite4b569a69ce897c80ab260376bbfb510d3bc79ce (patch)
treec1caf8c0442ca4f109725609125f5dac9141121e
parentdfef7828d57e6e4988f2dac90ecf40293f7a8209 (diff)
downloadlibcss-e4b569a69ce897c80ab260376bbfb510d3bc79ce.tar.gz
libcss-e4b569a69ce897c80ab260376bbfb510d3bc79ce.tar.bz2
Move css_error_from_string into test utilities
svn path=/trunk/libcss/; revision=6480
-rw-r--r--include/libcss/errors.h2
-rw-r--r--src/utils/errors.c30
-rw-r--r--test/number.c2
-rw-r--r--test/testutils.h33
4 files changed, 35 insertions, 32 deletions
diff --git a/include/libcss/errors.h b/include/libcss/errors.h
index 55bd379..8e321ce 100644
--- a/include/libcss/errors.h
+++ b/include/libcss/errors.h
@@ -24,8 +24,6 @@ typedef enum css_error {
/* Convert a libcss error value to a string */
const char *css_error_to_string(css_error error);
-/* Convert a string to a libcss error value */
-css_error css_error_from_string(const char *str, size_t len);
#endif
diff --git a/src/utils/errors.c b/src/utils/errors.c
index ac7dd42..b5b4792 100644
--- a/src/utils/errors.c
+++ b/src/utils/errors.c
@@ -48,33 +48,3 @@ const char *css_error_to_string(css_error error)
return result;
}
-
-/**
- * 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)
-{
- 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;
-}
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