d5bef9b695f84e555a308d4d3e94cf21ae20c805
[erlang-x-plane-data.git] / test / x_plane_data_SUITE.erl
1 -module(x_plane_data_SUITE).
2
3 %% CT callbacks
4 -export(
5 [ all/0
6 , groups/0
7 ]).
8
9 %% Test cases
10 -export(
11 [ t_basic_sanity_check/1
12 ]).
13
14 -define(GROUP, x_plane_data).
15
16 %% ============================================================================
17 %% CT callbacks
18 %% ============================================================================
19
20 all() ->
21 [ {group, ?GROUP}
22 ].
23
24 groups() ->
25 Tests =
26 [ t_basic_sanity_check
27 ],
28 Properties = [parallel],
29 [ {?GROUP, Properties, Tests}
30 ].
31
32
33 %% =============================================================================
34 %% Test cases
35 %% =============================================================================
36
37 t_basic_sanity_check(_Cfg) ->
38 Test =
39 fun (PacketBase64) ->
40 Packet = base64:decode(PacketBase64),
41 {error, packet_bad_header} =
42 x_plane_data_raw:of_bin(<<"bad-header", Packet/binary>>),
43 {error, packet_bad_length} =
44 x_plane_data_raw:of_bin(<<Packet/binary, "extra-stuff">>),
45 {ok, {_, Groups}} =
46 x_plane_data_raw:of_bin(<<Packet/binary>>),
47 {some, {_, _, _, _, _, _, _, _}} = kv_list_find(Groups, 3),
48 {some, {_, _, _, _, _, _, _, _}} = kv_list_find(Groups, 17),
49 {some, {_, _, _, _, _, _, _, _}} = kv_list_find(Groups, 20),
50 ok
51 end,
52 lists:foreach(Test, sample_packets_base64_encoded()).
53
54 %% =============================================================================
55 %% Sample data
56 %% =============================================================================
57
58 sample_packets_base64_encoded() ->
59 [ <<"REFUQUADAAAAbcpGQLt81EBfZNlATnUoNwDAecSow2RAnCv6QLrbQTcRAAAA3i8VQFL3ZT6dPfFCx4IFQwDAecQAwHnEAMB5xADAecQUAAAA1ZciQg6ik8JGBv9AdDxoPgAAgD9G/o3CAAAgQgAAlsI=">>
60 ].
61
62
63 %% =============================================================================
64 %% Helpers
65 %% =============================================================================
66
67 kv_list_find(KVL, K) ->
68 case lists:keyfind(K, 1, KVL)
69 of false -> none
70 ; {K, V} -> {some, V}
71 end.
This page took 0.050023 seconds and 3 git commands to generate.