~aleteoryx/muditaos

ref: 9541d8082ff01d9b0740c72674b2eb52b2e3a6c5 muditaos/module-cellular/test/unittest_parse_result.cpp -rw-r--r-- 23.3 KiB
9541d808 — Lefucjusz [BH-2092] Change onboarding auto power off time 1 year, 1 month ago
                                                                                
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
// Copyright (c) 2017-2024, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/blob/master/LICENSE.md

#include <string>
#include <catch2/catch.hpp>

#include <at/cmd/CLCC.hpp>
#include <at/cmd/CSCA.hpp>
#include <at/cmd/QECCNUM.hpp>
#include <at/cmd/CFUN.hpp>
#include <at/cmd/CPBR.hpp>
#include <at/cmd/QNWINFO.hpp>
#include <at/cmd/QSIMSTAT.hpp>
#include <at/cmd/QCFGUsbnet.hpp>
#include <at/cmd/CSQ.hpp>
#include "mock/AtCommon_channel.hpp"
#include "PhoneNumber.hpp"
#include "Result.hpp"

namespace at::cmd
{
    struct CLCCStub : public CLCC
    {
        [[nodiscard]] static auto toBool(const std::string &text) -> bool
        {
            return CLCC::toBool(text);
        }
        [[nodiscard]] static auto toUInt(const std::string &text) -> std::uint8_t
        {
            return CLCC::toUInt(text);
        }

        template <typename T>
        [[nodiscard]] static auto toEnum(const std::string &text) -> std::optional<T>
        {
            return CLCC::toEnum<T>(text);
        }
    };
} // namespace at::cmd

TEST_CASE("CSCA parser test")
{
    SECTION("empty failed data")
    {
        at::cmd::CSCA cmd;
        at::Result base_result; // normally returned from cmux->exec(), TODO getter for dumb result ala exe
        auto result = cmd.parseCSCA(base_result);
        REQUIRE(!result);
        REQUIRE(result.smsCenterAddress.empty());
        REQUIRE(result.smsTypeOfAddress.empty());
    }

    SECTION("failing channel")
    {
        at::cmd::CSCA cmd;
        at::CSCS_badChannel channel;
        auto base = channel.cmd(cmd);
        auto resp = cmd.parseCSCA(base);
        REQUIRE(!resp);
        REQUIRE(resp.code == at::Result::Code::ERROR);
    }

    SECTION("bad data")
    {
        at::cmd::CSCA cmd(at::cmd::Modifier::Get);
        at::CSCA_emptyData channel;
        auto base = channel.cmd(cmd);
        auto resp = cmd.parseCSCA(base);
        REQUIRE(!resp);
        REQUIRE(resp.code == at::Result::Code::PARSING_ERROR);
    }

    SECTION("proper data")
    {
        at::cmd::CSCA cmd;
        at::CSCS_successChannel channel;
        auto base = channel.cmd(cmd);
        auto resp = cmd.parseCSCA(base);
        REQUIRE(resp);
        REQUIRE(resp.smsCenterAddress == channel.smsCenterAddress);
        REQUIRE(resp.smsTypeOfAddress == channel.smsTypeOfAddress);
    }

    SECTION("failing data")
    {}
}

TEST_CASE("CSCA set data")
{
    SECTION("set proper data")
    {
        const std::string play_sms_center = "+48 790 998 250";
        const int example_type_of_address = 145;
        utils::PhoneNumber nr(play_sms_center);

        const std::string expected_result =
            "AT+CSCA=\"" + nr.getView().getE164() + "\"," + std::to_string(example_type_of_address);

        at::cmd::CSCA cmd;
        cmd.set(nr.getView(), example_type_of_address);
        SECTION("We fail - `NONE` modifier set")
        {
            REQUIRE(cmd.getCmd() != expected_result);
        }

        cmd.setModifier(at::cmd::Modifier::Set);

        SECTION("Success: proper modifier and data set")
        {
            REQUIRE(cmd.getCmd() == expected_result);
        }
    }
}

TEST_CASE("QECCNUM parser")
{
    SECTION("empty data")
    {
        at::cmd::QECCNUM cmd;
        at::Result base_result;
        auto resp = cmd.parseQECCNUM(base_result);
        REQUIRE(!resp);
    }

    SECTION("no numbers")
    {
        at::cmd::QECCNUM cmd;
        at::GenericChannel channel(at::Result::Code::OK, {"+QECCNUM: 1", "+QECCNUM: 2"});
        auto base = channel.cmd(cmd);
        auto resp = cmd.parseQECCNUM(base);
        REQUIRE(!resp);
    }

    SECTION("only no sim numbers")
    {
        at::cmd::QECCNUM cmd;
        at::GenericChannel channel(at::Result::Code::OK, {"+QECCNUM: 0,112,999", "+QECCNUM: 1"});
        auto base = channel.cmd(cmd);
        auto resp = cmd.parseQECCNUM(base);
        REQUIRE(resp);
        REQUIRE(resp.eccNumbersNoSim == std::vector<std::string>({"112", "999"}));
        REQUIRE(resp.eccNumbersSim.empty());
    }

    SECTION("only sim numbers")
    {
        at::cmd::QECCNUM cmd;
        at::GenericChannel channel(at::Result::Code::OK, {"+QECCNUM: 1,112,998"});
        auto base = channel.cmd(cmd);
        auto resp = cmd.parseQECCNUM(base);
        REQUIRE(resp);
        REQUIRE(resp.eccNumbersNoSim.empty());
        REQUIRE(resp.eccNumbersSim == std::vector<std::string>({"112", "998"}));
    }

    SECTION("sim and no sim numbers")
    {
        at::cmd::QECCNUM cmd;
        at::GenericChannel channel(at::Result::Code::OK, {"+QECCNUM: 0,112,999", "+QECCNUM: 1,4564,25435,325454"});
        auto base = channel.cmd(cmd);
        auto resp = cmd.parseQECCNUM(base);
        REQUIRE(resp);
        REQUIRE(resp.eccNumbersNoSim == std::vector<std::string>({"112", "999"}));
        REQUIRE(resp.eccNumbersSim == std::vector<std::string>({"4564", "25435", "325454"}));
    }

    SECTION("add number")
    {
        at::cmd::QECCNUM cmdAddNoSim(
            at::cmd::QECCNUM::Mode::Add, at::cmd::QECCNUM::NumberType::WithoutSim, {"600800900", "200300500"});
        REQUIRE(cmdAddNoSim.getCmd() == "AT+QECCNUM=1,1,\"600800900\",\"200300500\"");
        at::cmd::QECCNUM cmdAddSim(
            at::cmd::QECCNUM::Mode::Add, at::cmd::QECCNUM::NumberType::WithSim, {"600800900", "112"});
        REQUIRE(cmdAddSim.getCmd() == "AT+QECCNUM=1,0,\"600800900\",\"112\"");
    }
}

TEST_CASE("CLCC parser")
{
    using namespace std::string_literals;
    SECTION("Empty data")
    {
        at::cmd::CLCC cmd;
        at::Result result;
        auto response = cmd.parseCLCC(result);
        REQUIRE(!response);
    }
    SECTION("Failing channel")
    {
        at::cmd::CLCC cmd;
        at::FailingChannel channel;
        auto base     = channel.cmd(cmd);
        auto response = cmd.parseCLCC(base);
        REQUIRE(!response);
        REQUIRE(response.code == at::Result::Code::ERROR);
    }
    SECTION("Success - one call")
    {
        at::cmd::CLCC cmd;
        at::CLCC_successChannel_oneCall channel;
        auto base     = channel.cmd(cmd);
        auto response = cmd.parseCLCC(base);
        REQUIRE(response);
        auto [idx, dir, stateOfCall, mode, multiparty, number, type, alpha, tokens] = response.getData()[0];
        REQUIRE(idx == 1);
        REQUIRE(dir == ModemCall::CallDir::MO);
        REQUIRE(stateOfCall == ModemCall::CallState::Active);
        REQUIRE(mode == ModemCall::CallMode::Voice);
        REQUIRE(multiparty == true);
        REQUIRE(number == utils::PhoneNumber(channel.number).getView());
        REQUIRE(type == "129"s);
        REQUIRE(alpha == "");
    }

    SECTION("Success - two calls")
    {
        at::cmd::CLCC cmd;
        at::CLCC_successChannel_twoCalls channel;
        auto base     = channel.cmd(cmd);
        auto response = cmd.parseCLCC(base);
        REQUIRE(response);
        SECTION("First entry")
        {
            auto [idx, dir, stateOfCall, mode, multiparty, number, type, alpha, tokens] = response.getData()[0];
            REQUIRE(idx == 1);
            REQUIRE(dir == ModemCall::CallDir::MO);
            REQUIRE(stateOfCall == ModemCall::CallState::Active);
            REQUIRE(mode == ModemCall::CallMode::Data);
            REQUIRE(multiparty == false);
            REQUIRE(number == utils::PhoneNumber(channel.number1).getView());
            REQUIRE(type == "129"s);
            REQUIRE(alpha == "");
        }

        SECTION("Second entry")
        {
            auto [idx, dir, stateOfCall, mode, multiparty, number, type, alpha, tokens] = response.getData()[1];
            REQUIRE(idx == 2);
            REQUIRE(dir == ModemCall::CallDir::MO);
            REQUIRE(stateOfCall == ModemCall::CallState::Active);
            REQUIRE(mode == ModemCall::CallMode::Voice);
            REQUIRE(multiparty == false);
            REQUIRE(number == utils::PhoneNumber(channel.number2).getView());
            REQUIRE(type == "129"s);
            REQUIRE(alpha == "");
        }
    }

    SECTION("Failed - bad channel result")
    {
        at::cmd::CLCC cmd;
        at::CSCS_badChannel channel;
        auto base = channel.cmd(cmd);
        auto resp = cmd.parseCLCC(base);
        REQUIRE(!resp);
        REQUIRE(resp.code == at::Result::Code::ERROR);
    }

    SECTION("Success - only OK data")
    {
        at::cmd::CLCC cmd;
        at::OK_Channel channel;
        auto base     = channel.cmd(cmd);
        auto response = cmd.parseCLCC(base);
        REQUIRE(response);
    }

    SECTION("Failed - only OG data")
    {
        at::cmd::CLCC cmd;
        at::OG_Channel channel;
        auto base     = channel.cmd(cmd);
        auto response = cmd.parseCLCC(base);
        REQUIRE(!response);
        REQUIRE(response.code == at::Result::Code::ERROR);
    }
}

TEST_CASE("CLCC set data")
{
    using namespace std::literals;
    at::cmd::CLCC cmd;
    SECTION("None modifier set")
    {
        constexpr auto expectedResult = "AT+CLCC"sv;
        REQUIRE(cmd.getCmd() == expectedResult);
    }

    SECTION("Get modifier set")
    {
        constexpr auto expectedResult = "AT+CLCC?"sv;
        cmd.setModifier(at::cmd::Modifier::Get);
        REQUIRE(cmd.getCmd() == expectedResult);
    }
}

TEST_CASE("CLCC conversion methods")
{
    SECTION("String to bool")
    {
        SECTION("Proper data - true")
        {
            REQUIRE(at::cmd::CLCCStub::toBool("1") == true);
        }
        SECTION("Proper data - true")
        {
            REQUIRE(at::cmd::CLCCStub::toBool("0") == false);
        }
        SECTION("Invaild data")
        {
            REQUIRE_THROWS(at::cmd::CLCCStub::toBool("-1") == false);
        }
    }
    SECTION("String to uint32")
    {
        REQUIRE(at::cmd::CLCCStub::toUInt("1") == 1);
        REQUIRE(at::cmd::CLCCStub::toUInt("32") == 32);
        REQUIRE(at::cmd::CLCCStub::toUInt("255") == std::numeric_limits<std::uint8_t>::max());
        REQUIRE_THROWS(at::cmd::CLCCStub::toUInt("256"));
    }
    SECTION("String to enum")
    {
        SECTION("Call dir")
        {
            REQUIRE(at::cmd::CLCCStub::toEnum<ModemCall::CallDir>("-1") == std::nullopt);
            REQUIRE(at::cmd::CLCCStub::toEnum<ModemCall::CallDir>("0").value() == ModemCall::CallDir::MO);
            REQUIRE(at::cmd::CLCCStub::toEnum<ModemCall::CallDir>("1").value() == ModemCall::CallDir::MT);
            REQUIRE(at::cmd::CLCCStub::toEnum<ModemCall::CallDir>("2") == std::nullopt);
        }
        SECTION("Call state")
        {
            REQUIRE(at::cmd::CLCCStub::toEnum<ModemCall::CallState>("-1") == std::nullopt);
            REQUIRE(at::cmd::CLCCStub::toEnum<ModemCall::CallState>("0").value() == ModemCall::CallState::Active);
            REQUIRE(at::cmd::CLCCStub::toEnum<ModemCall::CallState>("5").value() == ModemCall::CallState::Waiting);
            REQUIRE(at::cmd::CLCCStub::toEnum<ModemCall::CallState>("6") == std::nullopt);
        }
        SECTION("Call mode")
        {
            REQUIRE(at::cmd::CLCCStub::toEnum<ModemCall::CallMode>("-1") == std::nullopt);
            REQUIRE(at::cmd::CLCCStub::toEnum<ModemCall::CallMode>("0").value() == ModemCall::CallMode::Voice);
            REQUIRE(at::cmd::CLCCStub::toEnum<ModemCall::CallMode>("2").value() == ModemCall::CallMode::FAX);
            REQUIRE(at::cmd::CLCCStub::toEnum<ModemCall::CallMode>("3") == std::nullopt);
        }
    }
}

TEST_CASE("CFUN parser")
{
    SECTION("Empty data")
    {
        at::cmd::CFUN cmd;
        at::Result result;
        auto response = cmd.parseCFUN(result);
        REQUIRE(!response);
    }

    SECTION("Failing channel")
    {
        at::cmd::CFUN cmd;
        at::FailingChannel channel;
        auto base     = channel.cmd(cmd);
        auto response = cmd.parseCFUN(base);
        REQUIRE(!response);
        REQUIRE(response.code == at::Result::Code::ERROR);
    }

    SECTION("Success - valid token")
    {
        at::cmd::CFUN cmd;
        at::CFUN_successChannel channel;
        auto base     = channel.cmd(cmd);
        auto response = cmd.parseCFUN(base);
        REQUIRE(response);
        REQUIRE(response.functionality == at::cfun::Functionality::Full);
    }

    SECTION("Failed - invalid token")
    {
        at::cmd::CFUN cmd;
        at::CFUN_invalidTokenChannel channel;
        auto base     = channel.cmd(cmd);
        auto response = cmd.parseCFUN(base);
        REQUIRE(!response);
    }
}

TEST_CASE("CFUN set data")
{
    at::cmd::CFUN cmd;
    SECTION("None modifier set")
    {
        constexpr auto expectedResult = "AT+CFUN";
        REQUIRE(cmd.getCmd() == expectedResult);
    }

    SECTION("Get modifier set")
    {
        constexpr auto expectedResult = "AT+CFUN?";
        cmd.setModifier(at::cmd::Modifier::Get);
        REQUIRE(cmd.getCmd() == expectedResult);
    }

    SECTION("Set modifier set")
    {
        constexpr auto expectedResult = "AT+CFUN=";
        cmd.setModifier(at::cmd::Modifier::Set);
        REQUIRE(cmd.getCmd() == expectedResult);
    }

    SECTION("Set modifier set functionality only")
    {
        constexpr auto expectedResult = "AT+CFUN=1";
        cmd.setModifier(at::cmd::Modifier::Set);
        cmd.set(at::cfun::Functionality::Full);
        REQUIRE(cmd.getCmd() == expectedResult);
    }

    SECTION("Set modifier set functionality and reset")
    {
        constexpr auto expectedResult = "AT+CFUN=4,1";
        cmd.setModifier(at::cmd::Modifier::Set);
        cmd.set(at::cfun::Functionality::DisableRF, at::cfun::Reset::ResetTheME);
        REQUIRE(cmd.getCmd() == expectedResult);
    }
}

TEST_CASE("CPBR parser")
{
    SECTION("Empty data")
    {
        at::cmd::CPBR cmd;
        at::Result result;
        auto response = cmd.parseCPBR(result);
        REQUIRE(!response);
    }

    SECTION("Failing channel")
    {
        at::cmd::CPBR cmd;
        at::FailingChannel channel;
        auto base     = channel.cmd(cmd);
        auto response = cmd.parseCPBR(base);
        REQUIRE(!response);
        REQUIRE(response.code == at::Result::Code::ERROR);
    }

    SECTION("Success - valid token")
    {
        at::cmd::CPBR cmd;
        at::CPBR_successChannel channel;
        auto base     = channel.cmd(cmd);
        auto response = cmd.parseCPBR(base);
        REQUIRE(response);

        REQUIRE(response.contacts.size() == 2);

        REQUIRE(response.contacts[0].index == 1);
        REQUIRE(response.contacts[0].number == "123456789");
        REQUIRE(response.contacts[0].type == at::cpbr::ContactType::National);
        REQUIRE(response.contacts[0].name == "Mock1");

        REQUIRE(response.contacts[1].index == 2);
        REQUIRE(response.contacts[1].number == "+48123456789");
        REQUIRE(response.contacts[1].type == at::cpbr::ContactType::International);
        REQUIRE(response.contacts[1].name == "Mock2");
    }

    SECTION("Failed - to little tokens")
    {
        at::cmd::CPBR cmd;
        at::CPBR_toLittleTokens channel;
        auto base     = channel.cmd(cmd);
        auto response = cmd.parseCPBR(base);
        REQUIRE(!response);
        REQUIRE(response.code == at::Result::Code::PARSING_ERROR);
    }

    SECTION("Failed - to many tokens")
    {
        at::cmd::CPBR cmd;
        at::CPBR_toManyTokens channel;
        auto base     = channel.cmd(cmd);
        auto response = cmd.parseCPBR(base);
        REQUIRE(!response);
        REQUIRE(response.code == at::Result::Code::PARSING_ERROR);
    }

    SECTION("Failed - invalid type")
    {
        at::cmd::CPBR cmd;
        at::CPBR_invalidType channel;
        auto base     = channel.cmd(cmd);
        auto response = cmd.parseCPBR(base);
        REQUIRE(!response);
        REQUIRE(response.code == at::Result::Code::PARSING_ERROR);
    }
}

TEST_CASE("CPBR set data")
{
    at::cmd::CPBR cmd;
    SECTION("None modifier set")
    {
        constexpr auto expectedResult = "AT+CPBR";
        REQUIRE(cmd.getCmd() == expectedResult);
    }

    SECTION("Get modifier set")
    {
        constexpr auto expectedResult = "AT+CPBR?";
        cmd.setModifier(at::cmd::Modifier::Get);
        REQUIRE(cmd.getCmd() == expectedResult);
    }

    SECTION("Set modifier set")
    {
        constexpr auto expectedResult = "AT+CPBR=";
        cmd.setModifier(at::cmd::Modifier::Set);
        REQUIRE(cmd.getCmd() == expectedResult);
    }

    SECTION("Set commnad")
    {
        constexpr auto expectedResult = "AT+CPBR=1,5";
        cmd                           = at::cmd::CPBR(at::cmd::Modifier::Set);
        cmd.setSimContactsReadRange(1, 5);
        REQUIRE(cmd.getCmd() == expectedResult);
    }
}

TEST_CASE("QNWINFO parser test")
{
    SECTION("empty failed data")
    {
        at::cmd::QNWINFO cmd;
        at::Result base_result;
        auto result = cmd.parseQNWINFO(base_result);
        REQUIRE(!result);
        REQUIRE(result.act.empty());
        REQUIRE(result.op == 0);
        REQUIRE(result.band.empty());
        REQUIRE(result.channel == 0);
    }

    SECTION("failing channel")
    {
        at::cmd::QNWINFO cmd;
        at::QNWINFO_badChannel channel;
        auto base = channel.cmd(cmd);
        auto resp = cmd.parseQNWINFO(base);
        REQUIRE(!resp);
        REQUIRE(resp.code == at::Result::Code::PARSING_ERROR);
    }

    SECTION("bad data")
    {
        at::cmd::QNWINFO cmd;
        at::QNWINFO_emptyData channel;
        auto base = channel.cmd(cmd);
        auto resp = cmd.parseQNWINFO(base);
        REQUIRE(!resp);
        REQUIRE(resp.code == at::Result::Code::PARSING_ERROR);
    }

    SECTION("proper data no quotes")
    {
        at::cmd::QNWINFO cmd;
        at::QNWINFO_successNoQuoteChannel channel;
        auto base = channel.cmd(cmd);
        auto resp = cmd.parseQNWINFO(base);
        REQUIRE(resp);
        REQUIRE(resp.act == channel.act);
        REQUIRE(resp.op == channel.op);
        REQUIRE(resp.band == channel.band);
        REQUIRE(resp.channel == channel.channel);
    }

    SECTION("proper data with quotes")
    {
        at::cmd::QNWINFO cmd;
        at::QNWINFO_successWithQuoteChannel channel;
        auto base = channel.cmd(cmd);
        auto resp = cmd.parseQNWINFO(base);
        REQUIRE(resp);
        REQUIRE(resp.act == channel.act);
        REQUIRE(resp.op == channel.op);
        REQUIRE(resp.band == channel.band);
        REQUIRE(resp.channel == channel.channel);
    }

    SECTION("error data")
    {
        at::cmd::QNWINFO cmd;
        at::QNWINFO_errorChannel channel;
        auto base = channel.cmd(cmd);
        auto resp = cmd.parseQNWINFO(base);
        REQUIRE(!resp);
    }
}

TEST_CASE("QSIMSTAT parser")
{
    SECTION("Empty data")
    {
        at::cmd::QSIMSTAT cmd;
        at::Result result;
        auto response = cmd.parseQSIMSTAT(result);
        REQUIRE(!response);
    }

    SECTION("Failing channel")
    {
        at::cmd::QSIMSTAT cmd;
        at::FailingChannel channel;
        auto base     = channel.cmd(cmd);
        auto response = cmd.parseQSIMSTAT(base);
        REQUIRE(!response);
        REQUIRE(response.code == at::Result::Code::ERROR);
    }

    SECTION("Success - valid token")
    {
        at::cmd::QSIMSTAT cmd;
        at::QSIMSTAT_successChannel channel;
        auto base     = channel.cmd(cmd);
        auto response = cmd.parseQSIMSTAT(base);
        REQUIRE(response);
        REQUIRE(response.enabled == at::SimInsertedStatusEnable::Enable);
        REQUIRE(response.status == at::SimInsertedStatus::Inserted);
    }

    SECTION("to little tokens")
    {
        at::cmd::QSIMSTAT cmd;
        at::QSIMSTAT_toLittleTokens channel;
        auto base     = channel.cmd(cmd);
        auto response = cmd.parseQSIMSTAT(base);
        REQUIRE(!response);
        REQUIRE(response.code == at::Result::Code::PARSING_ERROR);
    }

    SECTION("Failed - to many tokens")
    {
        at::cmd::QSIMSTAT cmd;
        at::QSIMSTAT_toManyTokens channel;
        auto base     = channel.cmd(cmd);
        auto response = cmd.parseQSIMSTAT(base);
        REQUIRE(!response);
        REQUIRE(response.code == at::Result::Code::PARSING_ERROR);
    }

    SECTION("Failed - invalid enabled oken")
    {
        at::cmd::QSIMSTAT cmd;
        at::QSIMSTAT_invalidEnabled channel;
        auto base     = channel.cmd(cmd);
        auto response = cmd.parseQSIMSTAT(base);
        REQUIRE(!response);
        REQUIRE(response.code == at::Result::Code::PARSING_ERROR);
    }

    SECTION("Failed - invalid status token")
    {
        at::cmd::QSIMSTAT cmd;
        at::QSIMSTAT_invalidStatus channel;
        auto base     = channel.cmd(cmd);
        auto response = cmd.parseQSIMSTAT(base);
        REQUIRE(!response);
        REQUIRE(response.code == at::Result::Code::PARSING_ERROR);
    }
}
TEST_CASE("QCFGUsbnet parser")
{
    SECTION("Empty data")
    {
        at::cmd::QCFGUsbnet cmd;
        at::Result result;
        auto response = cmd.parseQCFGUsbnet(result);
        REQUIRE(!response);
    }

    SECTION("Failing channel")
    {
        at::cmd::QCFGUsbnet cmd;
        at::FailingChannel channel;
        auto base     = channel.cmd(cmd);
        auto response = cmd.parseQCFGUsbnet(base);
        REQUIRE(!response);
        REQUIRE(response.code == at::Result::Code::ERROR);
    }

    SECTION("success")
    {
        at::cmd::QCFGUsbnet cmd;
        at::QCGFGUsbnet_successChannel channel;
        auto base     = channel.cmd(cmd);
        auto response = cmd.parseQCFGUsbnet(base);
        REQUIRE(response);
        REQUIRE(response.net == at::qcfg::usbnet::Net::ECM);
    }

    SECTION("too few tokens")
    {
        at::cmd::QCFGUsbnet cmd;
        at::QSIMSTAT_toLittleTokens channel;
        auto base     = channel.cmd(cmd);
        auto response = cmd.parseQCFGUsbnet(base);
        REQUIRE(!response);
        REQUIRE(response.code == at::Result::Code::PARSING_ERROR);
    }

    SECTION("Failed - too many tokens")
    {
        at::cmd::QCFGUsbnet cmd;
        at::QCFGUsbnet_toManyTokens channel;
        auto base     = channel.cmd(cmd);
        auto response = cmd.parseQCFGUsbnet(base);
        REQUIRE(!response);
        REQUIRE(response.code == at::Result::Code::PARSING_ERROR);
    }

    SECTION("Failed - invalid token")
    {
        at::cmd::QCFGUsbnet cmd;
        at::QCFGUsbnet_invalidToken channel;
        auto base     = channel.cmd(cmd);
        auto response = cmd.parseQCFGUsbnet(base);
        REQUIRE(!response);
        REQUIRE(response.code == at::Result::Code::PARSING_ERROR);
    }
}

TEST_CASE("CSQ parser")
{
    SECTION("Empty data")
    {
        at::cmd::CSQ cmd;
        at::Result result;
        auto response = cmd.parseCSQ(result);
        REQUIRE(!response);
    }

    SECTION("Failing channel")
    {
        at::cmd::CSQ cmd;
        at::FailingChannel channel;
        auto base     = channel.cmd(cmd);
        auto response = cmd.parseCSQ(base);
        REQUIRE(!response);
        REQUIRE(response.code == at::Result::Code::ERROR);
    }

    SECTION("success")
    {
        constexpr uint32_t csq = 28;
        constexpr uint32_t ber = 99;

        at::cmd::CSQ cmd;
        at::CSQ_successChannel channel;
        auto base     = channel.cmd(cmd);
        auto response = cmd.parseCSQ(base);
        REQUIRE(response);
        REQUIRE(response.csq == csq);
        REQUIRE(response.ber == ber);
    }

    SECTION("too few tokens")
    {
        at::cmd::CSQ cmd;
        at::CSQ_tooFewTokens channel;
        auto base     = channel.cmd(cmd);
        auto response = cmd.parseCSQ(base);
        REQUIRE(!response);
        REQUIRE(response.code == at::Result::Code::PARSING_ERROR);
    }

    SECTION("Failed - too many tokens")
    {
        at::cmd::CSQ cmd;
        at::CSQ_toManyTokens channel;
        auto base     = channel.cmd(cmd);
        auto response = cmd.parseCSQ(base);
        REQUIRE(!response);
        REQUIRE(response.code == at::Result::Code::PARSING_ERROR);
    }
}