Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
argo
excit
Commits
352171e8
Commit
352171e8
authored
Jan 10, 2019
by
Brice Videau
Browse files
Indentation and checkpatch.
parent
a13a9339
Changes
8
Hide whitespace changes
Inline
Side-by-side
tests/excit_cons.c
View file @
352171e8
...
...
@@ -39,6 +39,7 @@ void test_alloc_init_cons(int window, excit_t sit)
excit_t
create_test_cons
(
int
window
,
excit_t
sit
)
{
excit_t
it
;
it
=
excit_alloc_test
(
EXCIT_CONS
);
assert
(
excit_cons_init
(
it
,
excit_dup
(
sit
),
window
)
==
ES
);
return
it
;
...
...
@@ -54,19 +55,20 @@ void test_next_cons(int window, excit_t sit)
for
(
int
i
=
0
;
i
<
window
;
i
++
)
{
new_sit
[
i
]
=
excit_dup
(
sit
);
assert
(
new_sit
[
i
]
!=
NULL
);
for
(
int
j
=
0
;
j
<
i
;
j
++
)
{
for
(
int
j
=
0
;
j
<
i
;
j
++
)
assert
(
excit_skip
(
new_sit
[
i
])
==
ES
);
}
}
assert
(
excit_dimension
(
it
,
&
dim
)
==
ES
);
assert
(
excit_dimension
(
sit
,
&
sdim
)
==
ES
);
indexes1
=
(
ssize_t
*
)
malloc
(
dim
*
sizeof
(
ssize_t
));
indexes2
=
(
ssize_t
*
)
malloc
(
dim
*
sizeof
(
ssize_t
));
indexes1
=
(
ssize_t
*
)
malloc
(
dim
*
sizeof
(
ssize_t
));
indexes2
=
(
ssize_t
*
)
malloc
(
dim
*
sizeof
(
ssize_t
));
while
(
excit_next
(
new_sit
[
window
-
1
],
indexes2
+
(
window
-
1
)
*
sdim
)
==
ES
)
{
while
(
excit_next
(
new_sit
[
window
-
1
],
indexes2
+
(
window
-
1
)
*
sdim
)
==
ES
)
{
for
(
int
i
=
0
;
i
<
window
-
1
;
i
++
)
{
assert
(
excit_next
(
new_sit
[
i
],
indexes2
+
i
*
sdim
)
==
ES
);
assert
(
excit_next
(
new_sit
[
i
],
indexes2
+
i
*
sdim
)
==
ES
);
}
assert
(
excit_next
(
it
,
indexes1
)
==
ES
);
assert
(
memcmp
(
indexes1
,
indexes2
,
dim
*
sizeof
(
ssize_t
))
==
0
);
...
...
@@ -88,10 +90,11 @@ void test_cons_iterator(int window, excit_t sit)
test_next_cons
(
window
,
sit
);
int
i
=
0
;
while
(
synthetic_tests
[
i
])
{
excit_t
it
=
create_test_cons
(
window
,
sit
);
synthetic_tests
[
i
](
it
);
synthetic_tests
[
i
]
(
it
);
excit_free
(
it
);
i
++
;
}
...
...
@@ -114,6 +117,6 @@ int main(int argc, char *argv[])
excit_free
(
it1
);
excit_free
(
it2
);
excit_free
(
it3
);
return
0
;
}
tests/excit_hilbert2d.c
View file @
352171e8
...
...
@@ -62,6 +62,7 @@ void test_alloc_init_hilbert2d(int order)
excit_t
create_test_hilbert2d
(
int
order
)
{
excit_t
it
;
it
=
excit_alloc_test
(
EXCIT_HILBERT2D
);
assert
(
excit_hilbert2d_init
(
it
,
order
)
==
ES
);
return
it
;
...
...
@@ -74,7 +75,7 @@ void test_next_hilbert2d(int order)
for
(
int
i
=
0
;
i
<
(
1
<<
order
)
*
(
1
<<
order
);
i
++
)
{
assert
(
excit_next
(
it
,
indexes1
)
==
ES
);
d2xy
(
1
<<
order
,
i
,
indexes2
,
indexes2
+
1
);
d2xy
(
1
<<
order
,
i
,
indexes2
,
indexes2
+
1
);
assert
(
indexes1
[
0
]
==
indexes2
[
0
]);
assert
(
indexes1
[
1
]
==
indexes2
[
1
]);
}
...
...
@@ -88,14 +89,15 @@ void test_hilbert2d_iterator(int order)
test_next_hilbert2d
(
order
);
int
i
=
0
;
while
(
synthetic_tests
[
i
])
{
excit_t
it
=
create_test_hilbert2d
(
order
);
synthetic_tests
[
i
](
it
);
synthetic_tests
[
i
]
(
it
);
excit_free
(
it
);
i
++
;
}
}
int
main
(
int
argc
,
char
*
argv
[])
...
...
tests/excit_product.c
View file @
352171e8
...
...
@@ -37,7 +37,7 @@ void test_alloc_init_prod(int count, excit_t *its)
expected_size
*=
size
;
assert
(
excit_product_add_copy
(
it
,
its
[
i
])
==
ES
);
assert
(
excit_product_count
(
it
,
&
c
)
==
ES
);
assert
(
c
==
i
+
1
);
assert
(
c
==
i
+
1
);
assert
(
excit_dimension
(
it
,
&
dim
)
==
ES
);
assert
(
expected_dim
==
dim
);
assert
(
excit_size
(
it
,
&
size
)
==
ES
);
...
...
@@ -49,10 +49,10 @@ void test_alloc_init_prod(int count, excit_t *its)
excit_t
create_test_product
(
int
count
,
excit_t
*
its
)
{
excit_t
it
;
it
=
excit_alloc_test
(
EXCIT_PRODUCT
);
for
(
int
i
=
0
;
i
<
count
;
i
++
)
{
for
(
int
i
=
0
;
i
<
count
;
i
++
)
assert
(
excit_product_add_copy
(
it
,
its
[
i
])
==
ES
);
}
return
it
;
}
...
...
@@ -62,7 +62,9 @@ void test_next_product_helper(int count, excit_t it, excit_t *its,
{
if
(
count
==
0
)
{
assert
(
excit_next
(
it
,
indexes1
)
==
ES
);
assert
(
memcmp
(
indexes1
,
indexes2
,
(
intptr_t
)
cindexes2
-
(
intptr_t
)
indexes2
)
==
0
);
assert
(
memcmp
(
indexes1
,
indexes2
,
(
intptr_t
)
cindexes2
-
(
intptr_t
)
indexes2
)
==
0
);
}
else
{
excit_t
cit
;
ssize_t
dim
;
...
...
@@ -70,8 +72,8 @@ void test_next_product_helper(int count, excit_t it, excit_t *its,
cit
=
excit_dup
(
*
its
);
assert
(
cit
!=
NULL
);
assert
(
excit_dimension
(
cit
,
&
dim
)
==
ES
);
while
(
excit_next
(
cit
,
cindexes2
)
==
ES
)
{
assert
(
excit_dimension
(
cit
,
&
dim
)
==
ES
);
while
(
excit_next
(
cit
,
cindexes2
)
==
ES
)
{
test_next_product_helper
(
count
-
1
,
it
,
its
+
1
,
indexes1
,
indexes2
,
cindexes2
+
dim
);
...
...
@@ -89,8 +91,8 @@ void test_next_product(int count, excit_t *its)
it
=
create_test_product
(
count
,
its
);
assert
(
excit_dimension
(
it
,
&
dim
)
==
ES
);
indexes1
=
(
ssize_t
*
)
malloc
(
dim
*
sizeof
(
ssize_t
));
indexes2
=
(
ssize_t
*
)
malloc
(
dim
*
sizeof
(
ssize_t
));
indexes1
=
(
ssize_t
*
)
malloc
(
dim
*
sizeof
(
ssize_t
));
indexes2
=
(
ssize_t
*
)
malloc
(
dim
*
sizeof
(
ssize_t
));
test_next_product_helper
(
count
,
it
,
its
,
indexes1
,
indexes2
,
indexes2
);
assert
(
excit_next
(
it
,
NULL
)
==
EXCIT_STOPIT
);
...
...
@@ -108,10 +110,11 @@ void test_product_iterator(int count, excit_t *its)
test_next_product
(
count
,
its
);
int
i
=
0
;
while
(
synthetic_tests
[
i
])
{
excit_t
it
=
create_test_product
(
count
,
its
);
synthetic_tests
[
i
](
it
);
synthetic_tests
[
i
]
(
it
);
excit_free
(
it
);
i
++
;
}
...
...
@@ -123,7 +126,7 @@ void test_product_split_dim(void)
excit_t
its
[
3
];
excit_t
new_its
[
3
];
ssize_t
indexes
[
3
];
its
[
0
]
=
create_test_range
(
0
,
3
,
1
);
its
[
1
]
=
create_test_range
(
1
,
-
1
,
-
1
);
its
[
2
]
=
create_test_range
(
-
5
,
5
,
1
);
...
...
@@ -213,13 +216,14 @@ void test_product_split_dim(void)
excit_free
(
its
[
0
]);
excit_free
(
its
[
1
]);
excit_free
(
its
[
2
]);
excit_free
(
it
);
}
int
main
(
int
argc
,
char
*
argv
[])
{
excit_t
its
[
4
];
its
[
0
]
=
create_test_range
(
0
,
3
,
1
);
test_product_iterator
(
1
,
its
);
its
[
1
]
=
create_test_range
(
1
,
-
1
,
-
1
);
...
...
tests/excit_range.c
View file @
352171e8
...
...
@@ -4,7 +4,8 @@
#include
"excit.h"
#include
"excit_test.h"
void
test_alloc_init_range
(
ssize_t
start
,
ssize_t
stop
,
ssize_t
step
)
{
void
test_alloc_init_range
(
ssize_t
start
,
ssize_t
stop
,
ssize_t
step
)
{
excit_t
it
;
ssize_t
dim
;
...
...
@@ -18,7 +19,8 @@ void test_alloc_init_range(ssize_t start, ssize_t stop, ssize_t step) {
excit_free
(
it
);
}
excit_t
create_test_range
(
ssize_t
start
,
ssize_t
stop
,
ssize_t
step
)
{
excit_t
create_test_range
(
ssize_t
start
,
ssize_t
stop
,
ssize_t
step
)
{
excit_t
it
;
it
=
excit_alloc_test
(
EXCIT_RANGE
);
...
...
@@ -39,8 +41,7 @@ void test_next_range(ssize_t start, ssize_t stop, ssize_t step)
for
(
int
i
=
start
;
i
>=
stop
;
i
+=
step
)
{
assert
(
excit_next
(
it
,
indexes
)
==
ES
);
assert
(
indexes
[
0
]
==
i
);
}
else
}
else
for
(
int
i
=
start
;
i
<=
stop
;
i
+=
step
)
{
assert
(
excit_next
(
it
,
indexes
)
==
ES
);
assert
(
indexes
[
0
]
==
i
);
...
...
@@ -49,7 +50,6 @@ void test_next_range(ssize_t start, ssize_t stop, ssize_t step)
excit_free
(
it
);
}
void
test_range_iterator
(
ssize_t
start
,
ssize_t
stop
,
ssize_t
step
)
{
test_alloc_init_range
(
start
,
stop
,
step
);
...
...
@@ -57,10 +57,11 @@ void test_range_iterator(ssize_t start, ssize_t stop, ssize_t step)
test_next_range
(
start
,
stop
,
step
);
int
i
=
0
;
while
(
synthetic_tests
[
i
])
{
excit_t
it
=
create_test_range
(
start
,
stop
,
step
);
synthetic_tests
[
i
](
it
);
synthetic_tests
[
i
]
(
it
);
excit_free
(
it
);
i
++
;
}
...
...
tests/excit_repeat.c
View file @
352171e8
...
...
@@ -38,6 +38,7 @@ void test_alloc_init_repeat(int repeat, excit_t sit)
excit_t
create_test_repeat
(
int
repeat
,
excit_t
sit
)
{
excit_t
it
;
it
=
excit_alloc_test
(
EXCIT_REPEAT
);
assert
(
excit_repeat_init
(
it
,
excit_dup
(
sit
),
repeat
)
==
ES
);
return
it
;
...
...
@@ -53,14 +54,15 @@ void test_next_repeat(int repeat, excit_t sit)
new_sit
=
excit_dup
(
sit
);
assert
(
excit_dimension
(
it
,
&
dim
)
==
ES
);
indexes1
=
(
ssize_t
*
)
malloc
(
dim
*
sizeof
(
ssize_t
));
indexes2
=
(
ssize_t
*
)
malloc
(
dim
*
sizeof
(
ssize_t
));
indexes1
=
(
ssize_t
*
)
malloc
(
dim
*
sizeof
(
ssize_t
));
indexes2
=
(
ssize_t
*
)
malloc
(
dim
*
sizeof
(
ssize_t
));
while
(
excit_next
(
new_sit
,
indexes1
)
==
ES
)
for
(
int
i
=
0
;
i
<
repeat
;
i
++
)
{
assert
(
excit_next
(
it
,
indexes2
)
==
ES
);
assert
(
memcmp
(
indexes1
,
indexes2
,
dim
*
sizeof
(
ssize_t
))
==
0
);
assert
(
memcmp
(
indexes1
,
indexes2
,
dim
*
sizeof
(
ssize_t
))
==
0
);
}
assert
(
excit_next
(
it
,
indexes2
)
==
EXCIT_STOPIT
);
...
...
@@ -79,16 +81,18 @@ void test_repeat_split(int repeat, excit_t sit)
ssize_t
dim
;
assert
(
excit_dimension
(
it
,
&
dim
)
==
ES
);
indexes1
=
(
ssize_t
*
)
malloc
(
dim
*
sizeof
(
ssize_t
));
indexes2
=
(
ssize_t
*
)
malloc
(
dim
*
sizeof
(
ssize_t
));
indexes1
=
(
ssize_t
*
)
malloc
(
dim
*
sizeof
(
ssize_t
));
indexes2
=
(
ssize_t
*
)
malloc
(
dim
*
sizeof
(
ssize_t
));
assert
(
excit_split
(
sit
,
3
,
new_sits
)
==
ES
);
assert
(
excit_repeat_split
(
it
,
3
,
new_its
)
==
ES
);
assert
(
excit_split
(
sit
,
3
,
new_sits
)
==
ES
);
assert
(
excit_repeat_split
(
it
,
3
,
new_its
)
==
ES
);
for
(
int
i
=
0
;
i
<
3
;
i
++
)
{
while
(
excit_next
(
new_sits
[
i
],
indexes1
)
==
ES
)
{
for
(
int
j
=
0
;
j
<
repeat
;
j
++
)
{
assert
(
excit_next
(
new_its
[
i
],
indexes2
)
==
ES
);
assert
(
memcmp
(
indexes1
,
indexes2
,
dim
*
sizeof
(
ssize_t
))
==
0
);
assert
(
memcmp
(
indexes1
,
indexes2
,
dim
*
sizeof
(
ssize_t
))
==
0
);
}
}
assert
(
excit_next
(
new_its
[
i
],
indexes2
)
==
EXCIT_STOPIT
);
...
...
@@ -111,10 +115,11 @@ void test_repeat_iterator(int repeat, excit_t sit)
test_repeat_split
(
repeat
,
sit
);
int
i
=
0
;
while
(
synthetic_tests
[
i
])
{
excit_t
it
=
create_test_repeat
(
repeat
,
sit
);
synthetic_tests
[
i
](
it
);
synthetic_tests
[
i
]
(
it
);
excit_free
(
it
);
i
++
;
}
...
...
tests/excit_slice.c
View file @
352171e8
...
...
@@ -24,7 +24,8 @@ void test_alloc_init_slice(excit_t source, excit_t indexer)
assert
(
excit_dimension
(
it
,
&
dim
)
==
ES
);
assert
(
dim
==
0
);
assert
(
excit_slice_init
(
it
,
excit_dup
(
source
),
excit_dup
(
indexer
))
==
ES
);
assert
(
excit_slice_init
(
it
,
excit_dup
(
source
),
excit_dup
(
indexer
))
==
ES
);
assert
(
excit_dimension
(
it
,
&
dim
)
==
ES
);
assert
(
excit_dimension
(
source
,
&
expected_dim
)
==
ES
);
assert
(
dim
==
expected_dim
);
...
...
@@ -40,7 +41,8 @@ excit_t create_test_slice(excit_t source, excit_t indexer)
excit_t
it
;
it
=
excit_alloc_test
(
EXCIT_SLICE
);
assert
(
excit_slice_init
(
it
,
excit_dup
(
source
),
excit_dup
(
indexer
))
==
ES
);
assert
(
excit_slice_init
(
it
,
excit_dup
(
source
),
excit_dup
(
indexer
))
==
ES
);
return
it
;
}
...
...
@@ -53,9 +55,10 @@ void test_next_slice(excit_t source, excit_t indexer)
ssize_t
*
indexes1
,
*
indexes2
;
ssize_t
index
;
ssize_t
dim
;
assert
(
excit_dimension
(
source
,
&
dim
)
==
ES
);
indexes1
=
(
ssize_t
*
)
malloc
(
dim
*
sizeof
(
ssize_t
));
indexes2
=
(
ssize_t
*
)
malloc
(
dim
*
sizeof
(
ssize_t
));
indexes1
=
(
ssize_t
*
)
malloc
(
dim
*
sizeof
(
ssize_t
));
indexes2
=
(
ssize_t
*
)
malloc
(
dim
*
sizeof
(
ssize_t
));
while
(
excit_next
(
iit
,
&
index
)
==
ES
)
{
assert
(
excit_nth
(
source
,
index
,
indexes2
)
==
ES
);
...
...
@@ -77,10 +80,11 @@ void test_slice_iterator(excit_t source, excit_t indexer)
test_next_slice
(
source
,
indexer
);
int
i
=
0
;
while
(
synthetic_tests
[
i
])
{
excit_t
it
=
create_test_slice
(
source
,
indexer
);
synthetic_tests
[
i
](
it
);
synthetic_tests
[
i
]
(
it
);
excit_free
(
it
);
i
++
;
}
...
...
tests/excit_test.c
View file @
352171e8
...
...
@@ -5,7 +5,8 @@
#include
<string.h>
#include
<stdio.h>
excit_t
excit_alloc_test
(
enum
excit_type_e
type
)
{
excit_t
excit_alloc_test
(
enum
excit_type_e
type
)
{
excit_t
it
;
enum
excit_type_e
newtype
;
...
...
@@ -16,23 +17,29 @@ excit_t excit_alloc_test(enum excit_type_e type) {
return
it
;
}
static
inline
excit_t
excit_dup_test
(
const
excit_t
it
)
{
static
inline
excit_t
excit_dup_test
(
const
excit_t
it
)
{
excit_t
newit
=
excit_dup
(
it
);
assert
(
newit
!=
NULL
);
return
newit
;
}
static
inline
void
excit_dimension_test
(
excit_t
it
,
ssize_t
*
dim
)
{
assert
(
excit_dimension
(
it
,
dim
)
==
ES
);
static
inline
void
excit_dimension_test
(
excit_t
it
,
ssize_t
*
dim
)
{
assert
(
excit_dimension
(
it
,
dim
)
==
ES
);
}
static
inline
void
deplete_iterator
(
excit_t
it
)
{
while
(
excit_next
(
it
,
NULL
)
==
ES
)
static
inline
void
deplete_iterator
(
excit_t
it
)
{
while
(
excit_next
(
it
,
NULL
)
==
ES
)
;
}
static
void
test_iterator_result_equal
(
excit_t
it1
,
excit_t
it2
)
{
static
void
test_iterator_result_equal
(
excit_t
it1
,
excit_t
it2
)
{
ssize_t
dim1
,
dim2
;
excit_dimension_test
(
it1
,
&
dim1
);
excit_dimension_test
(
it2
,
&
dim2
);
assert
(
dim1
==
dim2
);
...
...
@@ -40,40 +47,42 @@ static void test_iterator_result_equal(excit_t it1, excit_t it2) {
ssize_t
*
indexes1
,
*
indexes2
;
ssize_t
buff_dim
=
dim1
*
sizeof
(
ssize_t
);
indexes1
=
(
ssize_t
*
)
malloc
(
buff_dim
);
indexes2
=
(
ssize_t
*
)
malloc
(
buff_dim
);
indexes1
=
(
ssize_t
*
)
malloc
(
buff_dim
);
indexes2
=
(
ssize_t
*
)
malloc
(
buff_dim
);
while
(
excit_next
(
it1
,
indexes1
)
==
ES
)
{
assert
(
excit_next
(
it2
,
indexes2
)
==
ES
);
assert
(
memcmp
(
indexes1
,
indexes2
,
buff_dim
)
==
0
);
}
assert
(
excit_next
(
it2
,
indexes2
)
==
EXCIT_STOPIT
);
assert
(
excit_next
(
it2
,
indexes2
)
==
EXCIT_STOPIT
);
free
(
indexes1
);
free
(
indexes2
);
}
void
test_dup
(
excit_t
it1
)
{
void
test_dup
(
excit_t
it1
)
{
excit_t
it2
,
it3
;
it2
=
excit_dup_test
(
it1
);
it2
=
excit_dup_test
(
it1
);
it3
=
excit_dup_test
(
it1
);
test_iterator_result_equal
(
it1
,
it2
);
excit_free
(
it2
);
excit_free
(
it2
);
/* Check that the state is correctly copied */
assert
(
excit_next
(
it3
,
NULL
)
==
ES
);
/* Check that the state is correctly copied */
assert
(
excit_next
(
it3
,
NULL
)
==
ES
);
it2
=
excit_dup
(
it3
);
test_iterator_result_equal
(
it3
,
it2
);
excit_free
(
it2
);
excit_free
(
it3
);
}
void
test_rewind
(
excit_t
it1
)
{
void
test_rewind
(
excit_t
it1
)
{
excit_t
it2
,
it3
;
it2
=
excit_dup_test
(
it1
);
it2
=
excit_dup_test
(
it1
);
it3
=
excit_dup_test
(
it1
);
assert
(
excit_next
(
it1
,
NULL
)
==
ES
);
...
...
@@ -88,18 +97,21 @@ void test_rewind(excit_t it1) {
excit_free
(
it3
);
}
void
test_peek
(
excit_t
it1
)
{
void
test_peek
(
excit_t
it1
)
{
excit_t
it2
;
it2
=
excit_dup_test
(
it1
);
ssize_t
dim1
;
excit_dimension_test
(
it1
,
&
dim1
);
ssize_t
*
indexes1
,
*
indexes2
;
ssize_t
buff_dim
=
dim1
*
sizeof
(
ssize_t
);
indexes1
=
(
ssize_t
*
)
malloc
(
buff_dim
);
indexes2
=
(
ssize_t
*
)
malloc
(
buff_dim
);
indexes1
=
(
ssize_t
*
)
malloc
(
buff_dim
);
indexes2
=
(
ssize_t
*
)
malloc
(
buff_dim
);
while
(
excit_next
(
it1
,
indexes1
)
==
ES
)
{
assert
(
excit_peek
(
it2
,
indexes2
)
==
ES
);
...
...
@@ -108,14 +120,15 @@ void test_peek(excit_t it1) {
assert
(
memcmp
(
indexes1
,
indexes2
,
buff_dim
)
==
0
);
}
assert
(
excit_peek
(
it2
,
indexes2
)
==
EXCIT_STOPIT
);
assert
(
excit_next
(
it2
,
indexes2
)
==
EXCIT_STOPIT
);
assert
(
excit_next
(
it2
,
indexes2
)
==
EXCIT_STOPIT
);
free
(
indexes1
);
free
(
indexes2
);
excit_free
(
it2
);
}
void
test_size
(
excit_t
it
)
{
void
test_size
(
excit_t
it
)
{
ssize_t
size
;
ssize_t
count
=
0
;
int
err
;
...
...
@@ -125,27 +138,28 @@ void test_size(excit_t it) {
return
;
assert
(
err
==
ES
);
while
(
excit_next
(
it
,
NULL
)
==
ES
)
{
while
(
excit_next
(
it
,
NULL
)
==
ES
)
count
++
;
}
assert
(
size
==
count
);
assert
(
size
==
count
);
}
void
test_cyclic_next
(
excit_t
it1
)
{
void
test_cyclic_next
(
excit_t
it1
)
{
excit_t
it2
,
it3
;
int
looped
=
0
;
it2
=
excit_dup_test
(
it1
);
it2
=
excit_dup_test
(
it1
);
it3
=
excit_dup_test
(
it1
);
ssize_t
dim1
;
excit_dimension_test
(
it1
,
&
dim1
);
ssize_t
*
indexes1
,
*
indexes2
;
ssize_t
buff_dim
=
dim1
*
sizeof
(
ssize_t
);
indexes1
=
(
ssize_t
*
)
malloc
(
buff_dim
);
indexes2
=
(
ssize_t
*
)
malloc
(
buff_dim
);
indexes1
=
(
ssize_t
*
)
malloc
(
buff_dim
);
indexes2
=
(
ssize_t
*
)
malloc
(
buff_dim
);
while
(
excit_next
(
it1
,
indexes1
)
==
ES
)
{
assert
(
looped
==
0
);
...
...
@@ -162,20 +176,21 @@ void test_cyclic_next(excit_t it1) {
excit_free
(
it3
);
}
void
test_skip
(
excit_t
it1
)
{
void
test_skip
(
excit_t
it1
)
{
excit_t
it2
;
it2
=
excit_dup_test
(
it1
);
it2
=
excit_dup_test
(
it1
);
while
(
excit_next
(
it1
,
NULL
)
==
ES
)
{
assert
(
excit_skip
(
it2
)
==
ES
);
}
assert
(
excit_skip
(
it2
)
==
EXCIT_STOPIT
);
while
(
excit_next
(
it1
,
NULL
)
==
ES
)
assert
(
excit_skip
(
it2
)
==
ES
);
assert
(
excit_skip
(
it2
)
==
EXCIT_STOPIT
);
excit_free
(
it2
);
}
void
test_pos
(
excit_t
it
)
{
void
test_pos
(
excit_t
it
)
{
ssize_t
rank
,
expected_rank
;
if
(
excit_pos
(
it
,
&
rank
)
==
-
EXCIT_ENOTSUP
)
...
...
@@ -191,22 +206,24 @@ void test_pos(excit_t it) {
assert
(
excit_pos
(
it
,
&
rank
)
==
EXCIT_STOPIT
);
}
void
test_nth
(
excit_t
it1
)
{
void
test_nth
(
excit_t
it1
)
{
excit_t
it2
;
ssize_t
rank
=
-
1
;
if
(
excit_nth
(
it1
,
0
,
NULL
)
==
-
EXCIT_ENOTSUP
)
return
;
it2
=
excit_dup_test
(
it1
);
it2
=
excit_dup_test
(
it1
);
ssize_t
dim1
;
excit_dimension_test
(
it1
,
&
dim1
);
ssize_t
*
indexes1
,
*
indexes2
;
ssize_t
buff_dim
=
dim1
*
sizeof
(
ssize_t
);
indexes1
=
(
ssize_t
*
)
malloc
(
buff_dim
);
indexes2
=
(
ssize_t
*
)
malloc
(
buff_dim
);
indexes1
=
(
ssize_t
*
)
malloc
(
buff_dim
);
indexes2
=
(
ssize_t
*
)
malloc
(
buff_dim
);
assert
(
excit_nth
(
it2
,
rank
,
indexes2
)
==
-
EXCIT_EDOM
);
rank
++
;
...
...
@@ -223,43 +240,45 @@ void test_nth(excit_t it1) {
excit_free
(
it2
);
}
void
test_rank
(
excit_t
it1
)
{
void
test_rank
(
excit_t
it1
)
{
excit_t
it2
;
ssize_t
rank
,
expected_rank
;
it2
=
excit_dup_test
(
it1
);
it2
=
excit_dup_test
(
it1
);
ssize_t
dim1
;
excit_dimension_test
(
it1
,
&
dim1
);
ssize_t
*
indexes1
;
ssize_t
buff_dim
=
dim1
*
sizeof
(
ssize_t
);
indexes1
=
(
ssize_t
*
)
malloc
(
buff_dim
);
indexes1
=
(
ssize_t
*
)
malloc
(
buff_dim
);
assert
(
excit_peek
(
it1
,
indexes1
)
==
ES
);
if
(
excit_rank
(
it2
,
indexes1
,
&
rank
)
==
-
EXCIT_ENOTSUP
)
goto
error
;
expected_rank
=
0
;
while
(
excit_next
(
it1
,
indexes1
)
==
ES
)
{
while
(
excit_next
(
it1
,
indexes1
)
==
ES
)
{
assert
(
excit_rank
(
it2
,
indexes1
,
&
rank
)
==
ES
);
assert
(
expected_rank
==
rank
);
expected_rank
++
;
}
for
(
int
i
=
0
;
i
<
dim1
;
i
++
)
{
for
(
int
i
=
0
;
i
<
dim1
;
i
++
)
indexes1
[
i
]
=
0xDEADBEEFDEADBEEF
;
}
assert
(
excit_rank
(
it2
,
indexes1
,
&
rank
)
==
-
EXCIT_EINVAL
);
error:
free
(
indexes1
);
excit_free
(
it2
);
}
void
test_split
(
excit_t
it
)
{