1-module(testDefaultOctetString). 2 3-export([dos/1]). 4 5-include_lib("common_test/include/ct.hrl"). 6 7-record('Dos', { 8 opt = asn1_NOVALUE, 9 def = asn1_DEFAULT 10}). 11 12-define(def_DEFAULT, <<5>>). 13 14dos(Rules) -> 15 %% test roundtrip default 16 E1 = roundtrip(#'Dos'{}, #'Dos'{def = ?def_DEFAULT}), 17 %% test the value dos defined in the .asn file 18 E2 = roundtrip('DefaultOctetString':dos()), 19 %% sanity test a fully specified SEQUENCE 20 E3 = roundtrip(#'Dos'{opt = <<1,2,3>>, def = <<6>>}), 21 %% test def is/isn't encoded according to the value 22 if Rules == ber -> 23 <<48, 0>> = E1, 24 <<48, 4, 16#82, 2, 16#12, 16#34>> = E2, 25 <<48, 8, 16#82, 3, 1, 2, 3, 16#8A, 1, 6>> = E3; 26 true -> 27 ignore 28 end, 29 ok. 30 31roundtrip(Value) -> 32 roundtrip(Value, Value). 33roundtrip(Value, Exp) -> 34 asn1_test_lib:roundtrip('DefaultOctetString', 'Dos', Value, Exp). 35