Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
cmp_tool
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Dominik Loidolt
cmp_tool
Commits
0fe75fc2
Commit
0fe75fc2
authored
Oct 3, 2022
by
Dominik Loidolt
Browse files
Options
Downloads
Patches
Plain Diff
add tests for more coverage
parent
48853e73
No related branches found
No related tags found
1 merge request
!12
increase code coverage, general code refactoring
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
test/cmp_icu/test_cmp_icu.c
+51
-2
51 additions, 2 deletions
test/cmp_icu/test_cmp_icu.c
with
51 additions
and
2 deletions
test/cmp_icu/test_cmp_icu.c
+
51
−
2
View file @
0fe75fc2
...
@@ -412,6 +412,27 @@ void test_cmp_cfg_icu_buffers(void)
...
@@ -412,6 +412,27 @@ void test_cmp_cfg_icu_buffers(void)
TEST_ASSERT_EQUAL
(
cmp_data
,
cfg
.
icu_output_buf
);
TEST_ASSERT_EQUAL
(
cmp_data
,
cfg
.
icu_output_buf
);
TEST_ASSERT_EQUAL_INT
(
4
,
cfg
.
buffer_length
);
TEST_ASSERT_EQUAL_INT
(
4
,
cfg
.
buffer_length
);
/* error case: compressed data buffer bigger than max compression entity
* data size */
cfg
=
cmp_cfg_icu_create
(
DATA_TYPE_IMAGETTE
,
CMP_MODE_DIFF_ZERO
,
16
,
CMP_LOSSLESS
);
s
=
cmp_cfg_icu_buffers
(
&
cfg
,
data_to_compress
,
data_samples
,
model_of_data
,
updated_model
,
compressed_data
,
0x7FFFED
+
1
);
TEST_ASSERT_EQUAL_size_t
(
0
,
s
);
cfg
=
cmp_cfg_icu_create
(
DATA_TYPE_IMAGETTE
,
CMP_MODE_DIFF_ZERO
,
16
,
CMP_LOSSLESS
);
s
=
cmp_cfg_icu_buffers
(
&
cfg
,
data_to_compress
,
data_samples
,
model_of_data
,
updated_model
,
compressed_data
,
0x7FFFFFFF
);
TEST_ASSERT_EQUAL_size_t
(
0
,
s
);
/* this should also now work */
cfg
=
cmp_cfg_icu_create
(
DATA_TYPE_IMAGETTE
,
CMP_MODE_DIFF_ZERO
,
16
,
CMP_LOSSLESS
);
s
=
cmp_cfg_icu_buffers
(
&
cfg
,
data_to_compress
,
data_samples
,
model_of_data
,
updated_model
,
compressed_data
,
0x7FFFED
);
TEST_ASSERT_EQUAL_size_t
(
0xFFFFDA
,
s
);
/* error case: cfg = NULL */
/* error case: cfg = NULL */
s
=
cmp_cfg_icu_buffers
(
NULL
,
data_to_compress
,
data_samples
,
s
=
cmp_cfg_icu_buffers
(
NULL
,
data_to_compress
,
data_samples
,
model_of_data
,
updated_model
,
compressed_data
,
model_of_data
,
updated_model
,
compressed_data
,
...
@@ -2360,15 +2381,25 @@ void test_configure_encoder_setup(void)
...
@@ -2360,15 +2381,25 @@ void test_configure_encoder_setup(void)
TEST_ASSERT_TRUE
(
error
);
TEST_ASSERT_TRUE
(
error
);
memset
(
&
setup
,
0
,
sizeof
(
setup
));
memset
(
&
setup
,
0
,
sizeof
(
setup
));
/*
cfg = NULL
test */
/*
error case: cmp_mode = CMP_MODE_RAW
test */
cmp_par
=
42
;
cmp_par
=
42
;
spillover
=
23
;
spillover
=
23
;
lossy_par
=
0
;
lossy_par
=
0
;
max_data_bits
=
15
;
max_data_bits
=
15
;
cfg
.
data_type
=
DATA_TYPE_IMAGETTE
;
cfg
.
data_type
=
DATA_TYPE_IMAGETTE
;
cfg
.
cmp_mode
=
CMP_MODE_
MODEL_ZERO
;
cfg
.
cmp_mode
=
CMP_MODE_
RAW
;
cfg
.
icu_output_buf
=
(
void
*
)
123
;
cfg
.
icu_output_buf
=
(
void
*
)
123
;
cfg
.
buffer_length
=
2
;
cfg
.
buffer_length
=
2
;
error
=
configure_encoder_setup
(
&
setup
,
cmp_par
,
spillover
,
lossy_par
,
max_data_bits
,
&
cfg
);
TEST_ASSERT_TRUE
(
error
);
memset
(
&
setup
,
0
,
sizeof
(
setup
));
/* cfg = NULL test */
cmp_par
=
42
;
spillover
=
23
;
lossy_par
=
0
;
max_data_bits
=
15
;
error
=
configure_encoder_setup
(
&
setup
,
cmp_par
,
spillover
,
lossy_par
,
error
=
configure_encoder_setup
(
&
setup
,
cmp_par
,
spillover
,
lossy_par
,
max_data_bits
,
NULL
);
max_data_bits
,
NULL
);
TEST_ASSERT_TRUE
(
error
);
TEST_ASSERT_TRUE
(
error
);
...
@@ -2401,6 +2432,11 @@ void test_compress_imagette_diff(void)
...
@@ -2401,6 +2432,11 @@ void test_compress_imagette_diff(void)
TEST_ASSERT_EQUAL_HEX
(
0xDF6002AB
,
be32_to_cpu
(
output_buf
[
0
]));
TEST_ASSERT_EQUAL_HEX
(
0xDF6002AB
,
be32_to_cpu
(
output_buf
[
0
]));
TEST_ASSERT_EQUAL_HEX
(
0xFEB70000
,
be32_to_cpu
(
output_buf
[
1
]));
TEST_ASSERT_EQUAL_HEX
(
0xFEB70000
,
be32_to_cpu
(
output_buf
[
1
]));
TEST_ASSERT_EQUAL_HEX
(
0x00000000
,
be32_to_cpu
(
output_buf
[
2
]));
TEST_ASSERT_EQUAL_HEX
(
0x00000000
,
be32_to_cpu
(
output_buf
[
2
]));
/* test: icu_output_buf = NULL */
cfg
.
icu_output_buf
=
NULL
;
cmp_size
=
icu_compress_data
(
&
cfg
);
TEST_ASSERT_EQUAL_INT
(
66
,
cmp_size
);
}
}
...
@@ -2591,6 +2627,19 @@ void test_compress_imagette_error_cases(void)
...
@@ -2591,6 +2627,19 @@ void test_compress_imagette_error_cases(void)
cmp_size
=
icu_compress_data
(
&
cfg
);
cmp_size
=
icu_compress_data
(
&
cfg
);
TEST_ASSERT_EQUAL_INT
(
CMP_ERROR_SMALL_BUF
,
cmp_size
);
TEST_ASSERT_EQUAL_INT
(
CMP_ERROR_SMALL_BUF
,
cmp_size
);
/* compressed data buffer to small test part 2 */
cfg
.
data_type
=
DATA_TYPE_IMAGETTE
;
cfg
.
data_type
=
DATA_TYPE_IMAGETTE
;
cfg
.
cmp_mode
=
CMP_MODE_DIFF_ZERO
;
cfg
.
input_buf
=
data
;
cfg
.
samples
=
7
;
cfg
.
golomb_par
=
1
;
cfg
.
spill
=
8
;
cfg
.
icu_output_buf
=
(
uint32_t
*
)
output_buf
;
cfg
.
buffer_length
=
1
;
cmp_size
=
icu_compress_data
(
&
cfg
);
TEST_ASSERT_EQUAL_INT
(
CMP_ERROR_SMALL_BUF
,
cmp_size
);
/* error in setup */
/* error in setup */
struct
cmp_max_used_bits
max_used_bits
=
cmp_get_max_used_bits
();
struct
cmp_max_used_bits
max_used_bits
=
cmp_get_max_used_bits
();
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment