aboutsummaryrefslogtreecommitdiffstats
path: root/tests/50-constraint-OK.asn1
blob: 62c4fdffbc05fc58e3084b60101d6c4ec8cfe3e5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
-- OK: Everything is fine

-- iso.org.dod.internet.private.enterprise (1.3.6.1.4.1)
-- .spelio.software.asn1c.test (9363.1.5.1)
-- .50 1
-- .50 2

ModuleNestedConstraintsCheck
	{ iso org(3) dod(6) internet (1) private(4) enterprise(1)
		spelio(9363) software(1) asn1c(5) test(1) 50 1 }
	DEFINITIONS ::=
BEGIN
	IMPORTS Identifier FROM IdentifierModule;

	Int1 ::= INTEGER
	Int2 ::= Int1 (0..MAX)		-- X.680-0207::41.4.4
	Int3 ::= Int2 (MIN..ten)	-- Means (0..10)
	Int4 ::= Int3 (5..MAX,...,1..4)	-- Means (1..10,...)
	Int5 ::= Int4 (MIN..5)		-- Means (5)
	-- Int6 ::= INTEGER (Int5) -- -- Not yet supported

	ten Int1 ::= other-ten
	other-ten Int2 ::= 10

	-- G.4.3.4
	ExtensibleExtensions ::= INTEGER ((1..256,...) INTERSECTION (1..256))  

	Str1 ::= IA5String
	Str2 ::= Str1 (SIZE(MIN..20 | 25..30))	
					-- Means (SIZE(0..20 | 25..30))
	Str3 ::= Str2 (SIZE(10..27))(FROM("ABC"|"def"))
					-- (SIZE(10..20,25..27))(FROM("ABCdef"))
	Str4 ::= IA5String ("ABCD"|SIZE(4))
					-- Not PER-visible

	PER-Visible ::= IA5String (FROM("A".."F"))
	PER-Visible-2 ::= PER-Visible (FROM("E".."F"))	-- Means (FROM("EF"))
	-- The following maintain parent permitted alphabet constraint
	Not-PER-Visible-1 ::= PER-Visible (FROM("AB") | SIZE(1..2))
	Not-PER-Visible-2 ::= PER-Visible (FROM("AB",...))
	Not-PER-Visible-3 ::= PER-Visible (FROM("AB"),...)

	SIZE-but-not-FROM ::= PER-Visible (SIZE(1..4) ^ FROM("ABCD",...))
	SIZE-and-FROM ::= PER-Visible (SIZE(1..4) ^ FROM("ABCD"))
	Neither-SIZE-nor-FROM ::= PER-Visible (SIZE(1..4) | FROM("ABCD",...))

	Utf8-4 ::= UTF8String (FROM("A".."Z"))		-- Alphabet
	Utf8-3 ::= Utf8-2 (FROM("A".."Z"|"a".."z"))	-- Alphabet and size
	Utf8-2 ::= Utf8-1 (SIZE(1..2))			-- Size
	Utf8-1 ::= UTF8String

	VisibleIdentifier ::= Identifier

	Sequence ::= SEQUENCE {
		int1-c	Int1	(-2..MAX) DEFAULT 3,
		int4	[2] Int4,
		int4-c	Int4	(MIN..7),
		bool	BOOLEAN	DEFAULT 1,
		enum-c	ENUMERATED { one(1), two(2), ..., three(3) },
		...,
		int5-c	Int5 (5) OPTIONAL,
		...,
		null	NULL OPTIONAL
	}

	SequenceOf ::= SEQUENCE (SIZE(1..2)) OF Sequence

	Enum0	::= ENUMERATED { one, two }
	Enum1	::= ENUMERATED { one, two }	(one)

END


IdentifierModule
	{ iso org(3) dod(6) internet (1) private(4) enterprise(1)
		spelio(9363) software(1) asn1c(5) test(1) 50 2 }
	DEFINITIONS ::=
BEGIN
	EXPORTS Identifier;

	maxIdentifier INTEGER ::= 32

	Identifier ::=
	    VisibleString ( FROM
	   ("A"|"a"|"B"|"b"|"C"|"c"|"D"|"d"|"E"|"e"|"F"|"f"|
	   "G"|"g"|"H"|"h"|"I"|"i"|"J"|"j"|"K"|"k"|"L"|"l"|
	   "M"|"m"|"N"|"n"|"O"|"o"|"P"|"p"|"Q"|"q"|"R"|"r"|
	   "S"|"s"|"T"|"t"|"U"|"u"|"V"|"v"|"W"|"w"|"X"|"x"|
	   "Y"|"y"|"Z"|"z"|"$"|"_"|"0"|"1"|"2"|"3"|"4"|"5"|
	   "6"|"7"|"8"|"9") ) (SIZE(1..maxIdentifier))

END