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
b98f68c0
Commit
b98f68c0
authored
Jan 10, 2019
by
Nicolas Denoyelle
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add tests for tleaf
parent
18ea7f17
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
94 additions
and
1 deletion
+94
-1
tests/Makefile.am
tests/Makefile.am
+2
-1
tests/excit_tleaf.c
tests/excit_tleaf.c
+92
-0
No files found.
tests/Makefile.am
View file @
b98f68c0
...
...
@@ -10,8 +10,9 @@ excit_range_SOURCES = $(LIBHSOURCES) $(LIBCSOURCES) excit_range.c
excit_product_SOURCES
=
$(LIBHSOURCES)
$(LIBCSOURCES)
excit_product.c
excit_repeat_SOURCES
=
$(LIBHSOURCES)
$(LIBCSOURCES)
excit_repeat.c
excit_cons_SOURCES
=
$(LIBHSOURCES)
$(LIBCSOURCES)
excit_cons.c
excit_tleaf_SOURCES
=
$(LIBHSOURCES)
$(LIBCSOURCES)
excit_tleaf.c
UNIT_TESTS
=
excit_range excit_product excit_repeat excit_cons
UNIT_TESTS
=
excit_range excit_product excit_repeat excit_cons
excit_tleaf
# all tests
check_PROGRAMS
=
$(UNIT_TESTS)
...
...
tests/excit_tleaf.c
0 → 100644
View file @
b98f68c0
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <stdint.h>
#include <string.h>
#include "excit.h"
#include "excit_test.h"
static
const
ssize_t
depth
=
4
;
static
const
ssize_t
arities
[
4
]
=
{
4
,
8
,
2
,
4
};
static
excit_t
create_test_tleaf
(
const
enum
tleaf_it_policy_e
policy
,
const
ssize_t
*
user_policy
)
{
int
err
=
EXCIT_SUCCESS
;
excit_t
it
;
it
=
excit_alloc_test
(
EXCIT_RANGE
);
assert
(
it
!=
NULL
);
err
=
excit_tleaf_init
(
it
,
depth
,
arities
,
policy
,
user_policy
);
assert
(
err
==
EXCIT_SUCCESS
);
return
it
;
}
static
inline
ssize_t
tleaf_size
()
{
ssize_t
i
,
size
=
1
;
for
(
i
=
0
;
i
<
depth
;
i
++
)
size
*=
arities
[
i
];
return
size
;
}
static
ssize_t
tleaf_test_size
(
excit_t
tleaf
){
ssize_t
i
,
it_size
,
size
=
tlesf_size
();;
assert
(
excit_size
(
tleaf
,
&
it_size
)
==
EXCIT_SUCCESS
);
assert
(
it_size
==
size
);
}
static
void
tleaf_test_round_robin_policy
(
excit_t
tleaf
){
ssize_t
i
,
size
,
value
;
assert
(
excit_rewind
(
tleaf
)
==
EXCIT_SUCCESS
);
for
(
i
=
0
;
i
<
tleaf_size
();
i
++
){
assert
(
excit_next
(
tleaf
,
&
value
)
==
EXCIT_SUCCESS
);
assert
(
value
==
i
);
}
assert
(
excit_next
(
tleaf
,
&
value
)
==
EXCIT_STOPIT
);
}
void
tleaf_test_scatter_policy_no_split
(
excit_t
tleaf
){
ssize_t
i
,
j
,
r
,
n
,
c
,
value
,
val
,
size
=
tleaf_size
();
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
++
){
r
=
c
%
arities
[
j
];
n
=
n
/
arities
[
j
];
c
=
c
/
arities
[
j
];
val
+=
n
*
r
;
}
assert
(
value
==
val
);
}
assert
(
excit_next
(
tleaf
,
&
value
)
==
EXCIT_STOPIT
);
}
int
main
(
int
argc
,
char
*
argv
[])
{
excit_t
rrobin
=
create_test_tleaf
(
TLEAF_POLICY_ROUND_ROBIN
,
NULL
);
assert
(
rrobin
!=
NULL
);
tleaf_test_size
(
rrobin
);
tleaf_test_round_robin_policy
(
rrobin
);
excit_free
(
rrobin
);
excit_t
scatter
=
create_test_tleaf
(
TLEAF_POLICY_ROUND_ROBIN
,
NULL
);
assert
(
scatter
!=
NULL
);
tleaf_test_scatter_policy_no_split
(
scatter
);
excit_free
(
scatter
);
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