main
test-branch
| Rev | Line | |
|---|
| [9870917] | 1 | #include <pointer.cvh>
|
|---|
| 2 | #include <stdlib.h>
|
|---|
| 3 |
|
|---|
| 4 | typedef struct INT_DOUBLE {
|
|---|
| 5 | int head;
|
|---|
| 6 | double tail;
|
|---|
| 7 | }INT_DOUBLE;
|
|---|
| 8 |
|
|---|
| 9 | int main() {
|
|---|
| 10 | INT_DOUBLE * array, * single;
|
|---|
| 11 |
|
|---|
| 12 | array = (INT_DOUBLE*)malloc(2 * sizeof(INT_DOUBLE));
|
|---|
| 13 | array[0].head = 1;
|
|---|
| 14 | array[0].tail = 2.3;
|
|---|
| 15 | array[1].head = 1;
|
|---|
| 16 | array[1].tail = 2.3;
|
|---|
| 17 | $assert_equals(&array[0], &array[1], "Two pointers to two objects have same values are not equal");
|
|---|
| 18 | single = &array[1];
|
|---|
| 19 | $assert_equals(&array[0], single, "Two pointers to two objects have same values are not equal");
|
|---|
| 20 | single = &array[0];
|
|---|
| 21 | $assert_equals(&array[0], single, "Two pointers to the same object are not equal");
|
|---|
| 22 | $assert_equals(array, &array[0], "At least one pointers are not pointing to the first element of the array");
|
|---|
| 23 | free(array);
|
|---|
| 24 | return 0;
|
|---|
| 25 | }
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.