Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
asn1c
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
Libraries
asn1c
Commits
af4dfaa1
Commit
af4dfaa1
authored
Jul 25, 2017
by
Lev Walkin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
OER string test
parent
2d10756d
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
78 additions
and
0 deletions
+78
-0
asn1c/tests/check-src/check-137.-gen-OER.c
asn1c/tests/check-src/check-137.-gen-OER.c
+51
-0
tests/137-oer-string-OK.asn1
tests/137-oer-string-OK.asn1
+27
-0
No files found.
asn1c/tests/check-src/check-137.-gen-OER.c
0 → 100644
View file @
af4dfaa1
/*
* Verify OER with constrained and unconstrained strings.
*/
#undef NDEBUG
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <string.h>
#include <assert.h>
#include <ctype.h>
#include <errno.h>
#include <T.h>
int
main
()
{
uint8_t
tmpbuf
[
128
];
T_t
source
;
T_t
*
decoded
=
0
;
/* "= 0" is important */
memset
(
&
source
,
0
,
sizeof
(
source
));
OCTET_STRING_fromBuf
(
&
source
.
unconstrained
.
ia5
,
"foo"
,
3
);
OCTET_STRING_fromBuf
(
&
source
.
unconstrained
.
utf8
,
"bar"
,
3
);
OCTET_STRING_fromBuf
(
&
source
.
unconstrained
.
universal
,
"
\0\0\0
b
\0\0\0
a
\0\0\0
z"
,
12
);
OCTET_STRING_fromBuf
(
&
source
.
constrained
.
ia5
,
"ab"
,
2
);
OCTET_STRING_fromBuf
(
&
source
.
constrained
.
utf8
,
"cd"
,
2
);
OCTET_STRING_fromBuf
(
&
source
.
unconstrained
.
universal
,
"
\0\0\0
e
\0\0\0
f"
,
8
);
asn_enc_rval_t
er
=
oer_encode_to_buffer
(
&
asn_DEF_T
,
0
,
&
source
,
tmpbuf
,
sizeof
(
tmpbuf
));
assert
(
er
.
encoded
!=
-
1
);
asn_dec_rval_t
dr
=
oer_decode
(
0
,
&
asn_DEF_T
,
(
void
**
)
&
decoded
,
tmpbuf
,
er
.
encoded
);
assert
(
dr
.
code
==
RC_OK
);
if
(
dr
.
consumed
!=
er
.
encoded
)
{
ASN_DEBUG
(
"Consumed %zu, expected %zu"
,
dr
.
consumed
,
er
.
encoded
);
assert
(
dr
.
consumed
==
er
.
encoded
);
}
fprintf
(
stderr
,
"Original:
\n
"
);
xer_fprint
(
stderr
,
&
asn_DEF_T
,
&
source
);
fprintf
(
stderr
,
"Decoded:
\n
"
);
xer_fprint
(
stderr
,
&
asn_DEF_T
,
decoded
);
return
0
;
}
tests/137-oer-string-OK.asn1
0 → 100644
View file @
af4dfaa1
-- OK: Everything is fine
-- iso.org.dod.internet.private.enterprise (1.3.6.1.4.1)
-- .spelio.software.asn1c.test (9363.1.5.1)
-- .137
ModuleOERString
{ iso org(3) dod(6) internet (1) private(4) enterprise(1)
spelio(9363) software(1) asn1c(5) test(1) 137 }
DEFINITIONS IMPLICIT TAGS ::=
BEGIN
T ::= SEQUENCE {
unconstrained SEQUENCE {
ia5 IA5String,
utf8 UTF8String,
universal UniversalString
},
constrained SEQUENCE {
ia5 IA5String (SIZE(2..2)),
utf8 UTF8String (SIZE(2)),
universal UniversalString (SIZE(2 | 2))
}
}
END
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