summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDave Beckett <dave@dajobe.org>2003-03-30 20:43:08 +0000
committerDave Beckett <dave@dajobe.org>2003-03-30 20:43:08 +0000
commit1b4b381432d833761b1a355ce7e067900446bdff (patch)
treeddbcce9aaea6923eea6a2ea6417e7a0d6a0d6408
parent5ceab31d2d057ae397a0f91bbc6ef4c688d52e75 (diff)
downloadraptor-1b4b381432d833761b1a355ce7e067900446bdff.tar.gz
(main) Moved raptor_validate_xml_ID, raptor_xml_escape_string test
code to raptor_xml.c
-rw-r--r--src/raptor_general.c112
1 files changed, 0 insertions, 112 deletions
diff --git a/src/raptor_general.c b/src/raptor_general.c
index 5736dc79..e18daf9f 100644
--- a/src/raptor_general.c
+++ b/src/raptor_general.c
@@ -1252,115 +1252,3 @@ raptor_stats_print(raptor_parser *rdf_parser, FILE *stream)
}
}
#endif
-
-
-
-
-
-#ifdef STANDALONE
-
-/* static prototypes */
-void raptor_bad_string_print(const unsigned char *input, FILE *stream);
-int main(int argc, char *argv[]);
-
-void
-raptor_bad_string_print(const unsigned char *input, FILE *stream)
-{
- while(*input) {
- char c=*input;
- if(isprint(c))
- fputc(c, stream);
- else
- fprintf(stream, "\\x%02X", (c & 0xff));
- input++;
- }
-}
-
-
-int
-main(int argc, char *argv[])
-{
- char *program=argv[0];
- struct tv {
- const unsigned char *string;
- const char quote;
- const unsigned char *result;
- };
- struct tv *t;
- struct tv test_values[]={
- {"&", 0, "&amp;"},
- {"<", 0, "&lt;"},
- {">", 0, "&gt;"},
-
- {"'&'", '\'', "&apos;&amp;&apos;"},
- {"'<'", '\'', "&apos;&lt;&apos;"},
- {"'>'", '\'', "&apos;&gt;&apos;"},
-
- {"\"&\"", '\"', "&quot;&amp;&quot;"},
- {"\"<\"", '\"', "&quot;&lt;&quot;"},
- {"\">\"", '\"', "&quot;&gt;&quot;"},
-
- {"&amp;", 0, "&amp;amp;"},
- {"<foo>", 0, "&lt;foo&gt;"},
-
- {"\x1f", 0, "&#x1F;"},
- {"\xc2\x80", 0, "&#x80;"},
- {"\xe0\xa0\x80", 0, "&#x0800;"},
- {"\xf0\x90\x80\x80", 0, "&#x10000;"},
-
- {"\x7f", 0, "&#x7F;"},
- {"\xdf\xbf", 0, "&#x07FF;"},
- {"\xef\xbf\xbd", 0, "&#xFFFD;"},
- {"\xf4\x8f\xbf\xbf", 0, "&#x10FFFF;"},
-
- {"\xc3\xbf", 0, "&#xFF;"},
- {"\xf0\x8f\xbf\xbf", 0, "&#xFFFF;"},
-
- {NULL, 0, 0}
- };
- int i;
- int failures=0;
-
- for(i=0; (t=&test_values[i]) && t->string; i++) {
- const unsigned char *utf8_string=t->string;
- int quote=t->quote;
- size_t utf8_string_len=strlen(utf8_string);
- unsigned char *xml_string;
- int xml_string_len=0;
-
- xml_string_len=raptor_xml_escape_string(NULL, utf8_string, utf8_string_len,
- NULL, 0, quote);
- xml_string=(char*)RAPTOR_MALLOC(cstring, xml_string_len+1);
-
- xml_string_len=raptor_xml_escape_string(NULL, utf8_string, utf8_string_len,
- xml_string, xml_string_len, quote);
- if(!xml_string) {
- fprintf(stderr, "%s: raptor_xml_escape_string FAILED to escape string '",
- program);
- raptor_bad_string_print(utf8_string, stderr);
- fputs("'\n", stderr);
- failures++;
- continue;
- }
- if(strcmp(xml_string, t->result)) {
- fprintf(stderr, "%s: raptor_xml_escape_string FAILED to escape string '",
- program);
- raptor_bad_string_print(utf8_string, stderr);
- fprintf(stderr, "', expected '%s', result was '%s'\n",
- t->result, xml_string);
- failures++;
- continue;
- }
-
- fprintf(stderr, "%s: raptor_xml_escape_string escaped string to '%s' ok\n",
- program, xml_string);
- RAPTOR_FREE(cstring, xml_string);
- }
-
- if(!failures)
- fprintf(stderr, "%s: raptor_xml_escape_string all tests OK\n", program);
-
- return failures;
-}
-
-#endif