Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
E
excit
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
1
Issues
1
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
argo
excit
Commits
a2b3c3be
Commit
a2b3c3be
authored
Jan 23, 2019
by
Nicolas Denoyelle
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add indexer to tree levels
parent
4b54d0f5
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
56 additions
and
36 deletions
+56
-36
excit_tleaf.c
tests/excit_tleaf.c
+56
-36
No files found.
tests/excit_tleaf.c
View file @
a2b3c3be
...
...
@@ -18,17 +18,18 @@ static excit_t create_test_tleaf(const ssize_t depth,
it
=
excit_alloc_test
(
EXCIT_TLEAF
);
assert
(
it
!=
NULL
);
err
=
excit_tleaf_init
(
it
,
depth
+
1
,
arities
,
indexes
,
policy
,
user_policy
);
err
=
excit_tleaf_init
(
it
,
depth
+
1
,
arities
,
indexes
,
policy
,
user_policy
);
assert
(
err
==
EXCIT_SUCCESS
);
ssize_t
i
,
size
=
1
,
it_size
,
arity
;
for
(
i
=
0
;
i
<
depth
;
i
++
){
if
(
indexes
&&
indexes
[
i
]){
for
(
i
=
0
;
i
<
depth
;
i
++
)
{
if
(
indexes
&&
indexes
[
i
])
assert
(
excit_size
(
indexes
[
i
],
&
arity
)
==
EXCIT_SUCCESS
);
}
else
{
else
arity
=
arities
[
i
];
}
size
*=
arity
;
}
assert
(
excit_size
(
it
,
&
it_size
)
==
EXCIT_SUCCESS
);
...
...
@@ -50,50 +51,59 @@ static void tleaf_test_round_robin_policy(excit_t tleaf)
assert
(
excit_next
(
tleaf
,
&
value
)
==
EXCIT_STOPIT
);
}
static
void
tleaf_test_indexed_round_robin_policy
(
excit_t
tleaf
,
const
ssize_t
depth
,
const
ssize_t
*
arities
,
excit_t
*
_indexes
)
static
void
tleaf_test_indexed_round_robin_policy
(
excit_t
tleaf
,
const
ssize_t
depth
,
const
ssize_t
*
arities
,
excit_t
*
_indexes
)
{
ssize_t
i
,
j
,
value
,
indexed_value
,
indexed_mul
,
size
,
arity
;
ssize_t
*
values
=
malloc
(
depth
*
sizeof
(
*
values
));
ssize_t
*
values
=
malloc
(
depth
*
sizeof
(
*
values
));
excit_t
check
=
excit_alloc
(
EXCIT_PRODUCT
);
assert
(
values
!=
NULL
);
assert
(
check
!=
NULL
);
for
(
i
=
0
;
i
<
depth
;
i
++
)
{
for
(
i
=
0
;
i
<
depth
;
i
++
)
{
excit_t
range
=
excit_alloc
(
EXCIT_RANGE
);
assert
(
range
!=
NULL
);
assert
(
excit_range_init
(
range
,
0
,
arities
[
i
]
-
1
,
1
)
==
EXCIT_SUCCESS
);
if
(
_indexes
[
i
]
!=
NULL
){
assert
(
excit_range_init
(
range
,
0
,
arities
[
i
]
-
1
,
1
)
==
EXCIT_SUCCESS
);
if
(
_indexes
[
i
]
!=
NULL
)
{
excit_t
comp
=
excit_alloc
(
EXCIT_COMPOSITION
);
assert
(
comp
!=
NULL
);
excit_t
index
=
excit_dup
(
_indexes
[
i
]);
assert
(
index
!=
NULL
);
assert
(
excit_rewind
(
index
)
==
EXCIT_SUCCESS
);
assert
(
excit_composition_init
(
comp
,
range
,
index
)
==
EXCIT_SUCCESS
);
assert
(
excit_product_add
(
check
,
comp
)
==
EXCIT_SUCCESS
);
assert
(
excit_composition_init
(
comp
,
range
,
index
)
==
EXCIT_SUCCESS
);
assert
(
excit_product_add
(
check
,
comp
)
==
EXCIT_SUCCESS
);
}
else
{
assert
(
excit_product_add
(
check
,
range
)
==
EXCIT_SUCCESS
);
assert
(
excit_product_add
(
check
,
range
)
==
EXCIT_SUCCESS
);
}
}
assert
(
excit_size
(
tleaf
,
&
size
)
==
EXCIT_SUCCESS
);
assert
(
excit_rewind
(
tleaf
)
==
EXCIT_SUCCESS
);
assert
(
excit_rewind
(
check
)
==
EXCIT_SUCCESS
);
for
(
i
=
0
;
i
<
size
;
i
++
)
{
assert
(
excit_next
(
tleaf
,
&
value
)
==
EXCIT_SUCCESS
);
assert
(
excit_next
(
check
,
values
)
==
EXCIT_SUCCESS
);
indexed_value
=
0
;
indexed_mul
=
1
;
for
(
j
=
0
;
j
<
depth
;
j
++
)
{
arity
=
arities
[
depth
-
j
-
1
];
indexed_value
+=
indexed_mul
*
values
[
depth
-
j
-
1
];
indexed_mul
*=
arity
;
indexed_mul
=
1
;
for
(
j
=
0
;
j
<
depth
;
j
++
)
{
arity
=
arities
[
depth
-
j
-
1
];
indexed_value
+=
indexed_mul
*
values
[
depth
-
j
-
1
];
indexed_mul
*=
arity
;
}
assert
(
value
==
indexed_value
);
}
excit_free
(
check
);
free
(
values
);
}
...
...
@@ -150,7 +160,7 @@ static void tleaf_test_round_robin_split(excit_t tleaf,
}
for
(
i
=
0
;
i
<
size
;
i
++
)
{
excit_t
it
=
split
[
i
*
ncut
/
size
];
excit_t
it
=
split
[
i
*
ncut
/
size
];
assert
(
excit_next
(
it
,
&
value
)
==
EXCIT_SUCCESS
);
assert
(
value
==
i
);
...
...
@@ -166,42 +176,51 @@ void run_tests(const ssize_t depth, const ssize_t *arities)
{
/* Test of round robin policy */
excit_t
rrobin
=
create_test_tleaf
(
depth
,
arities
,
NULL
,
TLEAF_POLICY_ROUND_ROBIN
,
NULL
);
create_test_tleaf
(
depth
,
arities
,
NULL
,
TLEAF_POLICY_ROUND_ROBIN
,
NULL
);
assert
(
rrobin
!=
NULL
);
tleaf_test_round_robin_policy
(
rrobin
);
assert
(
excit_rewind
(
rrobin
)
==
EXCIT_SUCCESS
);
/* Test of split operation on round robin policy */
tleaf_test_round_robin_split
(
rrobin
,
depth
,
arities
);
excit_free
(
rrobin
);
/* Test of indexing on a round robin policy */
ssize_t
i
;
excit_t
*
indexes
=
malloc
(
depth
*
sizeof
(
*
indexes
));
assert
(
indexes
!=
NULL
);
for
(
i
=
0
;
i
<
depth
;
i
++
)
{
if
(
arities
[
i
]
>
2
)
{
for
(
i
=
0
;
i
<
depth
;
i
++
)
{
if
(
arities
[
i
]
>
2
)
{
indexes
[
i
]
=
excit_alloc
(
EXCIT_RANGE
);
assert
(
indexes
[
i
]
!=
NULL
);
assert
(
excit_range_init
(
indexes
[
i
],
0
,
arities
[
i
]
/
2
-
1
,
1
)
==
EXCIT_SUCCESS
);
assert
(
indexes
[
i
]
!=
NULL
);
assert
(
excit_range_init
(
indexes
[
i
],
0
,
arities
[
i
]
/
2
-
1
,
1
)
==
EXCIT_SUCCESS
);
}
else
{
indexes
[
i
]
=
NULL
;
}
}
excit_t
indexed_rrobin
=
create_test_tleaf
(
depth
,
arities
,
indexes
,
TLEAF_POLICY_ROUND_ROBIN
,
NULL
);
assert
(
indexed_rrobin
!=
NULL
);
tleaf_test_indexed_round_robin_policy
(
indexed_rrobin
,
depth
,
arities
,
indexes
);
create_test_tleaf
(
depth
,
arities
,
indexes
,
TLEAF_POLICY_ROUND_ROBIN
,
NULL
);
assert
(
indexed_rrobin
!=
NULL
);
tleaf_test_indexed_round_robin_policy
(
indexed_rrobin
,
depth
,
arities
,
indexes
);
excit_free
(
indexed_rrobin
);
for
(
i
=
0
;
i
<
depth
;
i
++
)
for
(
i
=
0
;
i
<
depth
;
i
++
)
excit_free
(
indexes
[
i
]);
free
(
indexes
);
/* Test of scatter policy */
excit_t
scatter
=
create_test_tleaf
(
depth
,
arities
,
NULL
,
TLEAF_POLICY_SCATTER
,
NULL
);
create_test_tleaf
(
depth
,
arities
,
NULL
,
TLEAF_POLICY_SCATTER
,
NULL
);
assert
(
scatter
!=
NULL
);
tleaf_test_scatter_policy_no_split
(
scatter
,
depth
,
arities
);
...
...
@@ -211,8 +230,9 @@ void run_tests(const ssize_t depth, const ssize_t *arities)
i
=
0
;
while
(
synthetic_tests
[
i
])
{
excit_t
it
=
create_test_tleaf
(
depth
,
arities
,
NULL
,
TLEAF_POLICY_ROUND_ROBIN
,
NULL
);
create_test_tleaf
(
depth
,
arities
,
NULL
,
TLEAF_POLICY_ROUND_ROBIN
,
NULL
);
synthetic_tests
[
i
]
(
it
);
excit_free
(
it
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment