Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
E
excit
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
argo
excit
Commits
dd20ee78
Commit
dd20ee78
authored
Jan 10, 2019
by
Nicolas Denoyelle
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
checkpatch
parent
6d4b1ebd
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
39 additions
and
25 deletions
+39
-25
tests/excit_tleaf.c
tests/excit_tleaf.c
+39
-25
No files found.
tests/excit_tleaf.c
View file @
dd20ee78
...
...
@@ -12,87 +12,101 @@ static excit_t create_test_tleaf(const ssize_t depth,
const
ssize_t
*
user_policy
)
{
int
err
=
EXCIT_SUCCESS
;
excit_t
it
;
excit_t
it
;
it
=
excit_alloc_test
(
EXCIT_TLEAF
);
assert
(
it
!=
NULL
);
err
=
excit_tleaf_init
(
it
,
depth
+
1
,
arities
,
policy
,
user_policy
);
err
=
excit_tleaf_init
(
it
,
depth
+
1
,
arities
,
policy
,
user_policy
);
assert
(
err
==
EXCIT_SUCCESS
);
ssize_t
i
,
size
=
1
,
it_size
;
for
(
i
=
0
;
i
<
depth
;
i
++
)
for
(
i
=
0
;
i
<
depth
;
i
++
)
size
*=
arities
[
i
];
assert
(
excit_size
(
it
,
&
it_size
)
==
EXCIT_SUCCESS
);
assert
(
it_size
==
size
);
return
it
;
}
static
void
tleaf_test_round_robin_policy
(
excit_t
tleaf
){
static
void
tleaf_test_round_robin_policy
(
excit_t
tleaf
)
{
ssize_t
i
,
value
,
size
;
assert
(
excit_size
(
tleaf
,
&
size
)
==
EXCIT_SUCCESS
);
assert
(
excit_rewind
(
tleaf
)
==
EXCIT_SUCCESS
);
for
(
i
=
0
;
i
<
size
;
i
++
)
{
for
(
i
=
0
;
i
<
size
;
i
++
)
{
assert
(
excit_next
(
tleaf
,
&
value
)
==
EXCIT_SUCCESS
);
assert
(
value
==
i
);
}
assert
(
excit_next
(
tleaf
,
&
value
)
==
EXCIT_STOPIT
);
}
static
void
tleaf_test_scatter_policy_no_split
(
excit_t
tleaf
,
const
ssize_t
depth
,
const
ssize_t
*
arities
){
static
void
tleaf_test_scatter_policy_no_split
(
excit_t
tleaf
,
const
ssize_t
depth
,
const
ssize_t
*
arities
)
{
ssize_t
i
,
j
,
r
,
n
,
c
,
value
,
val
,
size
;
assert
(
excit_size
(
tleaf
,
&
size
)
==
EXCIT_SUCCESS
);
assert
(
excit_rewind
(
tleaf
)
==
EXCIT_SUCCESS
);
for
(
i
=
0
;
i
<
size
;
i
++
)
{
assert
(
excit_rewind
(
tleaf
)
==
EXCIT_SUCCESS
);
for
(
i
=
0
;
i
<
size
;
i
++
)
{
c
=
i
;
n
=
size
;
val
=
0
;
assert
(
excit_next
(
tleaf
,
&
value
)
==
EXCIT_SUCCESS
);
for
(
j
=
0
;
j
<
depth
;
j
++
)
{
for
(
j
=
0
;
j
<
depth
;
j
++
)
{
r
=
c
%
arities
[
j
];
n
=
n
/
arities
[
j
];
c
=
c
/
arities
[
j
];
val
+=
n
*
r
;
val
+=
n
*
r
;
}
assert
(
value
==
val
);
}
assert
(
excit_next
(
tleaf
,
&
value
)
==
EXCIT_STOPIT
);
}
void
run_tests
(
const
ssize_t
depth
,
const
ssize_t
*
arities
){
excit_t
rrobin
=
create_test_tleaf
(
depth
,
arities
,
TLEAF_POLICY_ROUND_ROBIN
,
NULL
);
void
run_tests
(
const
ssize_t
depth
,
const
ssize_t
*
arities
)
{
excit_t
rrobin
=
create_test_tleaf
(
depth
,
arities
,
TLEAF_POLICY_ROUND_ROBIN
,
NULL
);
assert
(
rrobin
!=
NULL
);
tleaf_test_round_robin_policy
(
rrobin
);
excit_free
(
rrobin
);
excit_t
scatter
=
create_test_tleaf
(
depth
,
arities
,
TLEAF_POLICY_SCATTER
,
NULL
);
excit_t
scatter
=
create_test_tleaf
(
depth
,
arities
,
TLEAF_POLICY_SCATTER
,
NULL
);
assert
(
scatter
!=
NULL
);
tleaf_test_scatter_policy_no_split
(
scatter
,
depth
,
arities
);
excit_free
(
scatter
);
int
i
=
0
;
while
(
synthetic_tests
[
i
])
{
excit_t
it
=
create_test_tleaf
(
depth
,
arities
,
TLEAF_POLICY_ROUND_ROBIN
,
NULL
);
excit_t
it
=
create_test_tleaf
(
depth
,
arities
,
TLEAF_POLICY_ROUND_ROBIN
,
NULL
);
synthetic_tests
[
i
](
it
);
synthetic_tests
[
i
]
(
it
);
excit_free
(
it
);
i
++
;
}
}
}
int
main
(
int
argc
,
char
*
argv
[])
{
const
ssize_t
depth
=
4
;
const
ssize_t
arities
[
4
]
=
{
4
,
8
,
2
,
4
};
ssize_t
depth
=
4
;
const
ssize_t
arities_0
[
4
]
=
{
4
,
8
,
2
,
4
};
run_tests
(
depth
,
arities_0
);
depth
=
8
;
const
ssize_t
arities_1
[
8
]
=
{
4
,
6
,
2
,
4
,
3
,
6
,
2
,
9
};
run_tests
(
depth
,
arities_1
);
run_tests
(
depth
,
arities
);
return
0
;
}
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