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
46076771
Commit
46076771
authored
Jan 10, 2019
by
Brice Videau
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added test for cons iterator.
parent
8d70786e
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
121 additions
and
2 deletions
+121
-2
tests/Makefile.am
tests/Makefile.am
+2
-1
tests/excit_cons.c
tests/excit_cons.c
+119
-0
tests/excit_repeat.c
tests/excit_repeat.c
+0
-1
No files found.
tests/Makefile.am
View file @
46076771
...
...
@@ -9,8 +9,9 @@ LIBCSOURCES = excit_test.c
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
UNIT_TESTS
=
excit_range excit_product excit_repeat
UNIT_TESTS
=
excit_range excit_product excit_repeat
excit_cons
# all tests
check_PROGRAMS
=
$(UNIT_TESTS)
...
...
tests/excit_cons.c
0 → 100644
View file @
46076771
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "excit.h"
#include "excit_test.h"
excit_t
create_test_range
(
ssize_t
start
,
ssize_t
stop
,
ssize_t
step
)
{
excit_t
it
;
it
=
excit_alloc_test
(
EXCIT_RANGE
);
assert
(
excit_range_init
(
it
,
start
,
stop
,
step
)
==
ES
);
return
it
;
}
void
test_alloc_init_cons
(
int
window
,
excit_t
sit
)
{
excit_t
it
;
ssize_t
dim
,
expected_dim
,
size
,
expected_size
;
it
=
excit_alloc_test
(
EXCIT_CONS
);
assert
(
excit_dimension
(
it
,
&
dim
)
==
ES
);
assert
(
dim
==
0
);
assert
(
excit_cons_init
(
it
,
excit_dup
(
sit
),
window
)
==
ES
);
assert
(
excit_dimension
(
it
,
&
dim
)
==
ES
);
assert
(
excit_dimension
(
sit
,
&
expected_dim
)
==
ES
);
expected_dim
*=
window
;
assert
(
dim
==
expected_dim
);
assert
(
excit_size
(
sit
,
&
expected_size
)
==
ES
);
expected_size
-=
(
window
-
1
);
assert
(
excit_size
(
it
,
&
size
)
==
ES
);
assert
(
size
==
expected_size
);
excit_free
(
it
);
}
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
;
}
void
test_next_cons
(
int
window
,
excit_t
sit
)
{
excit_t
it
,
new_sit
[
window
];
ssize_t
*
indexes1
,
*
indexes2
;
ssize_t
dim
,
sdim
;
it
=
create_test_cons
(
window
,
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
++
)
{
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
));
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
(
it
,
indexes1
)
==
ES
);
assert
(
memcmp
(
indexes1
,
indexes2
,
dim
*
sizeof
(
ssize_t
))
==
0
);
}
assert
(
excit_next
(
it
,
indexes1
)
==
EXCIT_STOPIT
);
free
(
indexes1
);
free
(
indexes2
);
excit_free
(
it
);
for
(
int
i
=
0
;
i
<
window
;
i
++
)
excit_free
(
new_sit
[
i
]);
}
void
test_cons_iterator
(
int
window
,
excit_t
sit
)
{
test_alloc_init_cons
(
window
,
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
);
excit_free
(
it
);
i
++
;
}
}
int
main
(
int
argc
,
char
*
argv
[])
{
excit_t
it1
,
it2
,
it3
;
it1
=
create_test_range
(
0
,
9
,
1
);
test_cons_iterator
(
3
,
it1
);
it2
=
create_test_range
(
-
15
,
14
,
2
);
test_cons_iterator
(
3
,
it2
);
it3
=
excit_alloc_test
(
EXCIT_PRODUCT
);
assert
(
excit_product_add_copy
(
it3
,
it1
)
==
ES
);
assert
(
excit_product_add_copy
(
it3
,
it2
)
==
ES
);
test_cons_iterator
(
4
,
it3
);
excit_free
(
it1
);
excit_free
(
it2
);
excit_free
(
it3
);
return
0
;
}
tests/excit_repeat.c
View file @
46076771
...
...
@@ -118,7 +118,6 @@ void test_repeat_iterator(int repeat, excit_t sit)
excit_free
(
it
);
i
++
;
}
}
int
main
(
int
argc
,
char
*
argv
[])
...
...
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