| 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, {Index, Groups}} = |
| 46 | x_plane_data_raw:of_bin(<<Packet/binary>>), |
| 47 | ct:log("Index: ~p", [Index]), |
| 48 | ct:log("Groups: ~p", [Groups]), |
| 49 | {some, Group3 } = kv_list_find(Groups, 3), |
| 50 | {some, Group17} = kv_list_find(Groups, 17), |
| 51 | {some, Group20} = kv_list_find(Groups, 20), |
| 52 | { 3.106105089187622 |
| 53 | , 6.640225887298584 |
| 54 | , 6.793502330780029 |
| 55 | , 1.0040892448159866e-5 |
| 56 | , -999.0 |
| 57 | , 3.574441909790039 |
| 58 | , 7.81782341003418 |
| 59 | , 1.1554855518625118e-5 |
| 60 | } = Group3, |
| 61 | { 2.3310465812683105 |
| 62 | , 0.22457626461982727 |
| 63 | , 120.6203384399414 |
| 64 | , 133.51084899902344 |
| 65 | , -999.0 |
| 66 | , -999.0 |
| 67 | , -999.0 |
| 68 | , -999.0 |
| 69 | } = Group17, |
| 70 | { 40.64827346801758 |
| 71 | , -73.81651306152344 |
| 72 | , 7.969515800476074 |
| 73 | , 0.226793110370636 |
| 74 | , 1.0 |
| 75 | , -70.99662780761719 |
| 76 | , 40.0 |
| 77 | , -75.0 |
| 78 | } = Group20, |
| 79 | ok |
| 80 | end, |
| 81 | lists:foreach(Test, sample_packets_base64_encoded()). |
| 82 | |
| 83 | %% ============================================================================= |
| 84 | %% Sample data |
| 85 | %% ============================================================================= |
| 86 | |
| 87 | sample_packets_base64_encoded() -> |
| 88 | [ <<"REFUQUADAAAAbcpGQLt81EBfZNlATnUoNwDAecSow2RAnCv6QLrbQTcRAAAA3i8VQFL3ZT6dPfFCx4IFQwDAecQAwHnEAMB5xADAecQUAAAA1ZciQg6ik8JGBv9AdDxoPgAAgD9G/o3CAAAgQgAAlsI=">> |
| 89 | ]. |
| 90 | |
| 91 | |
| 92 | %% ============================================================================= |
| 93 | %% Helpers |
| 94 | %% ============================================================================= |
| 95 | |
| 96 | kv_list_find(KVL, K) -> |
| 97 | case lists:keyfind(K, 1, KVL) |
| 98 | of false -> none |
| 99 | ; {K, V} -> {some, V} |
| 100 | end. |