commit - 475205fa0f2737475a17dd692b71611523b898a0
commit + 617ae38546228225f95507573ab21a4b5a7e9a40
blob - c6725b52741ac8604f0402272107b25157a022db
blob + a3f68954a4acab50213c270a6259dcd258c37bff
--- regress/iri_test.c
+++ regress/iri_test.c
#include <string.h>
#include "../gmid.h"
+
+#define ENCTEST(buf, len, raw, exp) \
+ if (encode_path(buf, len, raw) == -1) { \
+ fprintf(stderr, "%s:%d: failed to encode: %s\n", \
+ __FILE__, __LINE__, raw); \
+ exit(1); \
+ } \
+ if (strcmp(buf, exp) != 0) { \
+ fprintf(stderr, "%s:%d: error: " \
+ "unexpected encoding: got %s, want %s\n", \
+ __FILE__, __LINE__, buf, exp); \
+ exit(1); \
+ }
#define TEST(iri, fail, exp, descr) \
if (!run_test(iri, fail, exp)) { \
int
main(void)
{
+ char buf[32];
struct iri empty = IRI("", "", "", "", "", "");
+ ENCTEST(buf, sizeof(buf), "hello world", "hello%20world");
+ ENCTEST(buf, sizeof(buf), "hello\nworld", "hello%0Aworld");
+ ENCTEST(buf, sizeof(buf), "hello\r\nworld", "hello%0D%0Aworld");
+
TEST("http://omarpolo.com",
PASS,
IRI("http", "omarpolo.com", "", "", "", ""),