MicroLabo / Mbed OS mbed-Dot-AT-Firmware

Dependencies:   MTS-Serial libmDot-mbed5

Fork of Dot-AT-Firmware by MultiTech

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers TestCommandTerminal.h Source File

TestCommandTerminal.h

00001 #ifndef TESTCOMMANDTERMINAL_H
00002 #define TESTCOMMANDTERMINAL_H
00003 
00004 #include <string>
00005 #include <vector>
00006 
00007 #include "Commands.h"
00008 
00009 class MockSerial
00010 {
00011 
00012 public:
00013     std::string read_buff;
00014     std::string write_buff;
00015 
00016     int read(char* buff, int len)
00017     {
00018 
00019         return 0;
00020     }
00021 
00022     int write(char* buff)
00023     {
00024         write_buff.append(buff);
00025         return 0;
00026     }
00027 
00028     int writef(char* buff)
00029     {
00030         printf("MockSerial writef\r\n");
00031         write_buff.append(buff);
00032         return 0;
00033     }
00034 };
00035 
00036 class TestCommandTerminal: public TestCollection
00037 {
00038 public:
00039     TestCommandTerminal();
00040     ~TestCommandTerminal();
00041 
00042     virtual void run();
00043 
00044 };
00045 
00046 TestCommandTerminal::TestCommandTerminal() :
00047         TestCollection("CommandTerminal")
00048 {
00049 }
00050 
00051 TestCommandTerminal::~TestCommandTerminal()
00052 {
00053 }
00054 
00055 void TestCommandTerminal::run()
00056 {
00057     MockSerial test_serial;
00058 
00059     Test::start("Test AT");
00060     CmdAttention at_cmd;
00061     Test::assertTrue(std::string("AT").compare(at_cmd.text()) == 0);
00062     std::vector < std::string > args;
00063     args.push_back("AT");
00064     args.push_back("IGNORED");
00065     Test::assertTrue(at_cmd.verify(args));
00066     Test::assertTrue(at_cmd.action(args) == 0);
00067     Test::end();
00068 
00069 //    Test::start("Test ATI");
00070 //    printf("testing ati\r\n");
00071 //    CmdIdentification ati_cmd((mts::MTSSerial&)test_serial);
00072 //    printf("cmd created\r\n");
00073 //    Test::assertTrue(at_cmd.verify(args));
00074 //    printf("verified\r\n");
00075 //    Test::assertTrue(at_cmd.action(args) == 0);
00076 //    printf("actionied\r\n");
00077 //    Test::assertTrue(test_serial.write_buff.find("MultiTech") == 0);
00078 //    Test::end();
00079 
00080 }
00081 
00082 #endif /* TESTCOMMANDTERMINAL_H */