Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Synchronet
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Main
Synchronet
Commits
8e2a91e7
Commit
8e2a91e7
authored
4 months ago
by
Deucе
Browse files
Options
Downloads
Patches
Plain Diff
Simple test for LZH encode/decode
So I can poke it and break things.
parent
d7de4b88
No related branches found
No related tags found
1 merge request
!488
Overhaul LZH code
Pipeline
#7559
passed
4 months ago
Stage: build
Stage: test
Stage: cleanup
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/encode/GNUmakefile
+3
-0
3 additions, 0 deletions
src/encode/GNUmakefile
src/encode/lzh.c
+56
-0
56 additions, 0 deletions
src/encode/lzh.c
with
59 additions
and
0 deletions
src/encode/GNUmakefile
+
3
−
0
View file @
8e2a91e7
...
@@ -18,3 +18,6 @@ endif
...
@@ -18,3 +18,6 @@ endif
$(
QUIET
)$(
AR
)
rc
$@
$(
OBJS
)
$(
QUIET
)$(
AR
)
rc
$@
$(
OBJS
)
$(
QUIET
)$(
RANLIB
)
$@
$(
QUIET
)$(
RANLIB
)
$@
# Test build
lzh${EXEFILE}
:
lzh.c
$(
QUIET
)$(
CC
)
-std
=
c11
$(
CFLAGS
)
-DLZH_TEST
$(
CCFLAGS
)
-o
$@
$<
This diff is collapsed.
Click to expand it.
src/encode/lzh.c
+
56
−
0
View file @
8e2a91e7
...
@@ -763,4 +763,60 @@ int32_t lzh_decode(uint8_t *inbuf, int32_t inlen, uint8_t *outbuf)
...
@@ -763,4 +763,60 @@ int32_t lzh_decode(uint8_t *inbuf, int32_t inlen, uint8_t *outbuf)
return
(
count
);
return
(
count
);
}
}
#ifdef LZH_TEST
const
char
plaintext
[]
=
"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmodi "
"tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim "
"veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea "
"commodo consequat. Duis aute irure dolor in reprehenderit in voluptate "
"velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint "
"occaecat cupidatat non proident, sunt in culpa qui officia deserunt "
"mollit anim id est laborum."
;
const
char
compressed
[]
=
{
0xbe
,
0x01
,
0x00
,
0x00
,
0xec
,
0x7e
,
0xff
,
0xdf
,
0x1f
,
0xce
,
0xb3
,
0xeb
,
0xfc
,
0xff
,
0x80
,
0xe0
,
0xe0
,
0x7c
,
0x31
,
0x3f
,
0x16
,
0xb0
,
0xed
,
0x5e
,
0xdf
,
0x80
,
0x5b
,
0xf6
,
0xd6
,
0xc2
,
0xb5
,
0xdc
,
0x53
,
0xef
,
0xb9
,
0xfa
,
0xa3
,
0x56
,
0xc2
,
0xa5
,
0x6a
,
0xb7
,
0x95
,
0x29
,
0xb4
,
0xbb
,
0xa3
,
0x7d
,
0x46
,
0xbc
,
0xf8
,
0x67
,
0xfe
,
0x74
,
0x43
,
0x75
,
0x2d
,
0xc0
,
0x39
,
0x04
,
0x71
,
0xa2
,
0x46
,
0x14
,
0x4b
,
0x2c
,
0x68
,
0x6c
,
0xc1
,
0x3a
,
0x56
,
0xbf
,
0x33
,
0xb0
,
0xdd
,
0x8f
,
0x59
,
0x12
,
0x93
,
0x18
,
0x73
,
0x72
,
0x63
,
0x3e
,
0xc5
,
0xa0
,
0x63
,
0x75
,
0xbe
,
0xe8
,
0xe4
,
0xfb
,
0x13
,
0x15
,
0xcc
,
0x9b
,
0x4b
,
0x97
,
0x85
,
0x3c
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xe6
,
0x2b
,
0x7d
,
0x77
,
0xf8
,
0x25
,
0x72
,
0x8b
,
0x6e
,
0x17
,
0xed
,
0xa7
,
0xae
,
0xee
,
0xfa
,
0x56
,
0x37
,
0x25
,
0x53
,
0x93
,
0x17
,
0x8a
,
0x5d
,
0x84
,
0xfe
,
0xa6
,
0xf1
,
0xa8
,
0xf5
,
0xaf
,
0xba
,
0xf5
,
0x66
,
0xfe
,
0x6b
,
0xcd
,
0x6c
,
0x0e
,
0xe3
,
0xbd
,
0xd6
,
0x18
,
0xd5
,
0xb5
,
0x50
,
0x7b
,
0x2a
,
0x3b
,
0x67
,
0xd2
,
0xd7
,
0xa6
,
0x9f
,
0x20
};
int
main
(
void
)
{
int32_t
lzh_len
;
char
tmp
[
sizeof
(
plaintext
)];
lzh_len
=
lzh_encode
(
plaintext
,
strlen
(
plaintext
),
tmp
);
printf
(
"Compressed Len: %"
PRId32
"
\n
"
,
lzh_len
);
if
(
lzh_len
!=
sizeof
(
compressed
))
printf
(
" Expected Len: %zu
\n
"
,
sizeof
(
compressed
));
else
if
(
memcmp
(
tmp
,
compressed
,
lzh_len
))
printf
(
" Bytes different
\n
"
);
lzh_len
=
lzh_decode
(
compressed
,
sizeof
(
compressed
),
tmp
);
printf
(
"Uncompressed Size: %"
PRId32
"
\n
"
,
lzh_len
);
if
(
lzh_len
!=
strlen
(
plaintext
))
printf
(
" Expected Len: %zu
\n
"
,
strlen
(
plaintext
));
else
if
(
memcmp
(
tmp
,
plaintext
,
lzh_len
))
printf
(
" Bytes different
\n
"
);
}
#endif
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