Overview
Comment: | Actually test OFXMLFactory. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
58e11df8912ca94df4e5b3ee9763372d |
User & Date: | js on 2008-10-26 12:05:17 |
Other Links: | manifest | tags |
Context
2008-10-26
| ||
17:48 | OFMD5Hash improvements. check-in: 165c2c0b9d user: js tags: trunk | |
12:05 | Actually test OFXMLFactory. check-in: 58e11df891 user: js tags: trunk | |
02:49 | Fix missing include. check-in: 0b49311db1 user: js tags: trunk | |
Changes
Modified src/OFExceptions.m from [2ecf3b040e] to [b3c8864639].
︙ | ︙ | |||
20 21 22 23 24 25 26 27 28 29 30 31 32 33 | #import "OFExceptions.h" #if defined HAVE_SEL_GET_NAME #define SEL_NAME(x) sel_get_name(x) #elif defined HAVE_SEL_GETNAME #define SEL_NAME(x) sel_getName(x) #endif @implementation OFException + newWithObject: (id)obj { return [[OFException alloc] initWithObject: obj]; } | > > | 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | #import "OFExceptions.h" #if defined HAVE_SEL_GET_NAME #define SEL_NAME(x) sel_get_name(x) #elif defined HAVE_SEL_GETNAME #define SEL_NAME(x) sel_getName(x) #else #error "You need either sel_get_name() or sel_getName!" #endif @implementation OFException + newWithObject: (id)obj { return [[OFException alloc] initWithObject: obj]; } |
︙ | ︙ |
Modified tests/OFXMLFactory/OFXMLFactory.m from [12fd48a9aa] to [ef338cc4f6].
︙ | ︙ | |||
11 12 13 14 15 16 17 | #import <stdio.h> #import <stdlib.h> #import <string.h> #import "OFXMLFactory.h" | > > > > > > > > > | > | > | | | | < | < | < < | | | | | < | | | | | | < < | | | | | < < | | | | | < < | | | | | | < < | | | | | | < < | | | | | | | < < | | | | | | | | < < | < | < < | < < | < > | > | > > | 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 | #import <stdio.h> #import <stdlib.h> #import <string.h> #import "OFXMLFactory.h" inline void check_result(char *result, const char *should) { if (!strcmp(result, should)) printf("%s is expected result\n", result); else { printf("%s is NOT expected result!", result); exit(1); } free(result); } inline void test_concat() { const char *c1 = "<foo>", *c2 = "bar", *c3 = "<test/>"; char *s1, *s2, *s3; char *strs[4]; if ((s1 = malloc(strlen(c1) + 1)) == NULL || (s2 = malloc(strlen(c2) + 1)) == NULL || (s3 = malloc(strlen(c3) + 1)) == NULL) exit(1); strncpy(s1, c1, strlen(c1) + 1); strncpy(s2, c2, strlen(c2) + 1); strncpy(s3, c3, strlen(c3) + 1); strs[0] = s1; strs[1] = s2; strs[2] = s3; strs[3] = NULL; check_result([OFXMLFactory concatAndFreeCStrings: strs], "<foo>bar<test/>"); } inline void test_create_stanza() { check_result([OFXMLFactory createStanza: "foo" withCloseTag: NO andCData: NULL, NULL], "<foo>"); check_result([OFXMLFactory createStanza: "foo" withCloseTag: NO andCData: NULL, "bar", "baz", "blub", "asd", NULL], "<foo bar='baz' blub='asd'>"); check_result([OFXMLFactory createStanza: "foo" withCloseTag: YES andCData: NULL, NULL], "<foo/>"); check_result([OFXMLFactory createStanza: "foo" withCloseTag: YES andCData: "bar", NULL], "<foo>bar</foo>"); check_result([OFXMLFactory createStanza: "foo" withCloseTag: YES andCData: NULL, "bar", "b&az", NULL], "<foo bar='b&az'/>"); check_result([OFXMLFactory createStanza: "foo" withCloseTag: YES andCData: "bar", "bar", "b'az", NULL], "<foo bar='b'az'>bar</foo>"); check_result([OFXMLFactory createStanza: "foo" withCloseTag: YES andCData: NULL, "bar", "b&az", "x", "asd\"", NULL], "<foo bar='b&az' x='asd"'/>"); check_result([OFXMLFactory createStanza: "foo" withCloseTag: YES andCData: "bar", "bar", "b'az", "x", "y", "a", "b", NULL], "<foo bar='b'az' x='y' a='b'>bar</foo>"); } inline void test_escape() { check_result([OFXMLFactory escapeCString: "<hallo> &welt'\"!&"], "<hallo> &welt'"!&"); } int main() { test_escape(); test_create_stanza(); test_concat(); return 0; } |