Overview
Comment: | Added -data for OFArray & one new test. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
61fc89489a354b40d7a003c09369308e |
User & Date: | js on 2008-11-02 02:09:31 |
Other Links: | manifest | tags |
Context
2008-11-05
| ||
16:11 | OFOverflowException -> OFOutOfRangeException. check-in: 3577c0d81c user: js tags: trunk | |
2008-11-02
| ||
02:09 | Added -data for OFArray & one new test. check-in: 61fc89489a user: js tags: trunk | |
00:42 | Implementation for OFArray. check-in: a1e066138c user: js tags: trunk | |
Changes
Modified src/OFArray.h from [cfdd21c800] to [73c8baf0bd].
︙ | |||
19 20 21 22 23 24 25 26 27 28 29 30 31 32 | 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | + | size_t itemsize; size_t items; } + newWithItemSize: (size_t)is; - initWithItemSize: (size_t)is; - (size_t)items; - (void*)data; - (void*)item: (size_t)item; - (void*)last; - add: (void*)item; - addNItems: (size_t)nitems fromCArray: (void*)carray; - removeNItems: (size_t)nitems; @end |
︙ |
Modified src/OFArray.m from [c20f86a7ff] to [95cb756c66].
︙ | |||
39 40 41 42 43 44 45 46 47 48 49 50 51 52 | 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 | + + + + + | return items; } - (size_t)itemsize { return itemsize; } - (void*)data { return data; } - (void*)item: (size_t)item { if (item >= items) /* FIXME: Maybe OFOutOfRangeException would be better? */ [[OFOverflowException newWithObject: self] raise]; |
︙ |
Modified tests/OFArray/OFArray.m from [83725e7e15] to [086a701808].
︙ | |||
27 28 29 30 31 32 33 34 35 36 37 38 39 40 | 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | + + | puts("Resuming..."); \ } \ if (!caught) { \ puts("NOT CAUGHT!"); \ return 1; \ } const char *str = "Hallo!"; int main() { BOOL caught; OFArray *a; void *p, *q; size_t i; |
︙ | |||
94 95 96 97 98 99 100 101 102 | 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 | + + + + + + + + + + + + + + + + + | puts("Trying to remove more data than we added..."); CATCH_EXCEPTION([a removeNItems: [a items] + 1], OFOverflowException); puts("Trying to access an index that does not exist..."); CATCH_EXCEPTION([a item: [a items]], OFOverflowException); [a free]; puts("Creating new array and using it to build a string..."); a = [OFArray newWithItemSize: 1]; for (i = 0; i < strlen(str); i++) [a add: (void*)(str + i)]; [a add: ""]; if (!strcmp([a data], str)) puts("Built string matches!"); else { puts("Built string does not match!"); abort(); } [a free]; return 0; } |