mDot AT-Firmware for testing
Dependencies: MTS-Serial libmDot-mbed5
Fork of Dot-AT-Firmware by
CommandTerminal/Test/TestCommandTerminal.h@16:3b1d46c1db11, 2017-08-14 (annotated)
- Committer:
- Fran6
- Date:
- Mon Aug 14 12:40:21 2017 +0000
- Revision:
- 16:3b1d46c1db11
- Parent:
- 1:e52ae6584f1c
mDot AT-Firmware
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Mike Fiore |
1:e52ae6584f1c | 1 | #ifndef TESTCOMMANDTERMINAL_H |
Mike Fiore |
1:e52ae6584f1c | 2 | #define TESTCOMMANDTERMINAL_H |
Mike Fiore |
1:e52ae6584f1c | 3 | |
Mike Fiore |
1:e52ae6584f1c | 4 | #include <string> |
Mike Fiore |
1:e52ae6584f1c | 5 | #include <vector> |
Mike Fiore |
1:e52ae6584f1c | 6 | |
Mike Fiore |
1:e52ae6584f1c | 7 | #include "Commands.h" |
Mike Fiore |
1:e52ae6584f1c | 8 | |
Mike Fiore |
1:e52ae6584f1c | 9 | class MockSerial |
Mike Fiore |
1:e52ae6584f1c | 10 | { |
Mike Fiore |
1:e52ae6584f1c | 11 | |
Mike Fiore |
1:e52ae6584f1c | 12 | public: |
Mike Fiore |
1:e52ae6584f1c | 13 | std::string read_buff; |
Mike Fiore |
1:e52ae6584f1c | 14 | std::string write_buff; |
Mike Fiore |
1:e52ae6584f1c | 15 | |
Mike Fiore |
1:e52ae6584f1c | 16 | int read(char* buff, int len) |
Mike Fiore |
1:e52ae6584f1c | 17 | { |
Mike Fiore |
1:e52ae6584f1c | 18 | |
Mike Fiore |
1:e52ae6584f1c | 19 | return 0; |
Mike Fiore |
1:e52ae6584f1c | 20 | } |
Mike Fiore |
1:e52ae6584f1c | 21 | |
Mike Fiore |
1:e52ae6584f1c | 22 | int write(char* buff) |
Mike Fiore |
1:e52ae6584f1c | 23 | { |
Mike Fiore |
1:e52ae6584f1c | 24 | write_buff.append(buff); |
Mike Fiore |
1:e52ae6584f1c | 25 | return 0; |
Mike Fiore |
1:e52ae6584f1c | 26 | } |
Mike Fiore |
1:e52ae6584f1c | 27 | |
Mike Fiore |
1:e52ae6584f1c | 28 | int writef(char* buff) |
Mike Fiore |
1:e52ae6584f1c | 29 | { |
Mike Fiore |
1:e52ae6584f1c | 30 | printf("MockSerial writef\r\n"); |
Mike Fiore |
1:e52ae6584f1c | 31 | write_buff.append(buff); |
Mike Fiore |
1:e52ae6584f1c | 32 | return 0; |
Mike Fiore |
1:e52ae6584f1c | 33 | } |
Mike Fiore |
1:e52ae6584f1c | 34 | }; |
Mike Fiore |
1:e52ae6584f1c | 35 | |
Mike Fiore |
1:e52ae6584f1c | 36 | class TestCommandTerminal: public TestCollection |
Mike Fiore |
1:e52ae6584f1c | 37 | { |
Mike Fiore |
1:e52ae6584f1c | 38 | public: |
Mike Fiore |
1:e52ae6584f1c | 39 | TestCommandTerminal(); |
Mike Fiore |
1:e52ae6584f1c | 40 | ~TestCommandTerminal(); |
Mike Fiore |
1:e52ae6584f1c | 41 | |
Mike Fiore |
1:e52ae6584f1c | 42 | virtual void run(); |
Mike Fiore |
1:e52ae6584f1c | 43 | |
Mike Fiore |
1:e52ae6584f1c | 44 | }; |
Mike Fiore |
1:e52ae6584f1c | 45 | |
Mike Fiore |
1:e52ae6584f1c | 46 | TestCommandTerminal::TestCommandTerminal() : |
Mike Fiore |
1:e52ae6584f1c | 47 | TestCollection("CommandTerminal") |
Mike Fiore |
1:e52ae6584f1c | 48 | { |
Mike Fiore |
1:e52ae6584f1c | 49 | } |
Mike Fiore |
1:e52ae6584f1c | 50 | |
Mike Fiore |
1:e52ae6584f1c | 51 | TestCommandTerminal::~TestCommandTerminal() |
Mike Fiore |
1:e52ae6584f1c | 52 | { |
Mike Fiore |
1:e52ae6584f1c | 53 | } |
Mike Fiore |
1:e52ae6584f1c | 54 | |
Mike Fiore |
1:e52ae6584f1c | 55 | void TestCommandTerminal::run() |
Mike Fiore |
1:e52ae6584f1c | 56 | { |
Mike Fiore |
1:e52ae6584f1c | 57 | MockSerial test_serial; |
Mike Fiore |
1:e52ae6584f1c | 58 | |
Mike Fiore |
1:e52ae6584f1c | 59 | Test::start("Test AT"); |
Mike Fiore |
1:e52ae6584f1c | 60 | CmdAttention at_cmd; |
Mike Fiore |
1:e52ae6584f1c | 61 | Test::assertTrue(std::string("AT").compare(at_cmd.text()) == 0); |
Mike Fiore |
1:e52ae6584f1c | 62 | std::vector < std::string > args; |
Mike Fiore |
1:e52ae6584f1c | 63 | args.push_back("AT"); |
Mike Fiore |
1:e52ae6584f1c | 64 | args.push_back("IGNORED"); |
Mike Fiore |
1:e52ae6584f1c | 65 | Test::assertTrue(at_cmd.verify(args)); |
Mike Fiore |
1:e52ae6584f1c | 66 | Test::assertTrue(at_cmd.action(args) == 0); |
Mike Fiore |
1:e52ae6584f1c | 67 | Test::end(); |
Mike Fiore |
1:e52ae6584f1c | 68 | |
Mike Fiore |
1:e52ae6584f1c | 69 | // Test::start("Test ATI"); |
Mike Fiore |
1:e52ae6584f1c | 70 | // printf("testing ati\r\n"); |
Mike Fiore |
1:e52ae6584f1c | 71 | // CmdIdentification ati_cmd((mts::MTSSerial&)test_serial); |
Mike Fiore |
1:e52ae6584f1c | 72 | // printf("cmd created\r\n"); |
Mike Fiore |
1:e52ae6584f1c | 73 | // Test::assertTrue(at_cmd.verify(args)); |
Mike Fiore |
1:e52ae6584f1c | 74 | // printf("verified\r\n"); |
Mike Fiore |
1:e52ae6584f1c | 75 | // Test::assertTrue(at_cmd.action(args) == 0); |
Mike Fiore |
1:e52ae6584f1c | 76 | // printf("actionied\r\n"); |
Mike Fiore |
1:e52ae6584f1c | 77 | // Test::assertTrue(test_serial.write_buff.find("MultiTech") == 0); |
Mike Fiore |
1:e52ae6584f1c | 78 | // Test::end(); |
Mike Fiore |
1:e52ae6584f1c | 79 | |
Mike Fiore |
1:e52ae6584f1c | 80 | } |
Mike Fiore |
1:e52ae6584f1c | 81 | |
Mike Fiore |
1:e52ae6584f1c | 82 | #endif /* TESTCOMMANDTERMINAL_H */ |