| 11 | static const char * const TESTNAME = "TestArrayObject"; |
| 12 | |
| 13 | class CIntArray |
| 14 | { |
| 15 | public: |
| 16 | CIntArray() |
| 17 | { |
| 18 | length = 0; |
| 19 | buffer = new int[0]; |
| 20 | } |
| 21 | CIntArray(int l) |
| 22 | { |
| 23 | length=l; |
| 24 | buffer = new int[l]; |
| 25 | } |
| 26 | CIntArray(const CIntArray &other) |
| 27 | { |
| 28 | length = other.length; |
| 29 | buffer = new int[length]; |
| 30 | for( int n = 0; n < length; n++ ) |
| 31 | buffer[n] = other.buffer[n]; |
| 32 | } |
| 33 | ~CIntArray() |
| 34 | { |
| 35 | delete[] buffer; |
| 36 | } |
| 37 | |
| 38 | CIntArray &operator=(const CIntArray &other) |
| 39 | { |
| 40 | delete[] buffer; |
| 41 | length = other.length; |
| 42 | buffer = new int[length]; |
| 43 | memcpy(buffer, other.buffer, length*4); |
| 44 | return *this; |
| 45 | } |
| 46 | |
| 47 | int size() {return length;} |
| 48 | void push_back(int &v) |
| 49 | { |
| 50 | int *b = new int[length+1]; |
| 51 | memcpy(b, buffer, length*4); |
| 52 | delete[] buffer; |
| 53 | buffer = b; |
| 54 | b[length++] = v; |
| 55 | } |
| 56 | int pop_back() |
| 57 | { |
| 58 | return buffer[--length]; |
| 59 | } |
| 60 | int &operator[](int i) |
| 61 | { |
| 62 | return buffer[i]; |
| 63 | } |
| 64 | |
| 65 | int length; |
| 66 | int *buffer; |
| 67 | }; |
| 68 | |
| 69 | void ConstructIntArray(CIntArray *a) |
| 70 | { |
nothing calls this directly
no outgoing calls
no test coverage detected