blob: 0d5e80125bd6f72d8cc13314d3f44940960752db (
plain)
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
|
#ifndef TESTCOMMANDTERMINAL_H
#define TESTCOMMANDTERMINAL_H
#include <string>
#include <vector>
#include "Commands.h"
class MockSerial
{
public:
std::string read_buff;
std::string write_buff;
int read(char* buff, int len)
{
return 0;
}
int write(char* buff)
{
write_buff.append(buff);
return 0;
}
int writef(char* buff)
{
printf("MockSerial writef\r\n");
write_buff.append(buff);
return 0;
}
};
class TestCommandTerminal: public TestCollection
{
public:
TestCommandTerminal();
~TestCommandTerminal();
virtual void run();
};
TestCommandTerminal::TestCommandTerminal() :
TestCollection("CommandTerminal")
{
}
TestCommandTerminal::~TestCommandTerminal()
{
}
void TestCommandTerminal::run()
{
MockSerial test_serial;
Test::start("Test AT");
CmdAttention at_cmd;
Test::assertTrue(std::string("AT").compare(at_cmd.text()) == 0);
std::vector < std::string > args;
args.push_back("AT");
args.push_back("IGNORED");
Test::assertTrue(at_cmd.verify(args));
Test::assertTrue(at_cmd.action(args) == 0);
Test::end();
// Test::start("Test ATI");
// printf("testing ati\r\n");
// CmdIdentification ati_cmd((mts::MTSSerial&)test_serial);
// printf("cmd created\r\n");
// Test::assertTrue(at_cmd.verify(args));
// printf("verified\r\n");
// Test::assertTrue(at_cmd.action(args) == 0);
// printf("actionied\r\n");
// Test::assertTrue(test_serial.write_buff.find("MultiTech") == 0);
// Test::end();
}
#endif /* TESTCOMMANDTERMINAL_H */
|