Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: MTS-Serial libxDot-mbed5
Diff: CommandTerminal/Test/TestCommandTerminal.h
- Revision:
- 1:e52ae6584f1c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/CommandTerminal/Test/TestCommandTerminal.h Thu Jun 25 10:23:41 2015 -0500
@@ -0,0 +1,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 */