2 * Copyright (C) 2016 Simon Fels <morphis@gravedo.de>
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 3, as published
6 * by the Free Software Foundation.
8 * This program is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranties of
10 * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
11 * PURPOSE. See the GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License along
14 * with this program. If not, see <http://www.gnu.org/licenses/>.
18 #include "anbox/qemu/at_parser.h"
20 #include <gtest/gtest.h>
24 TEST(AtParser, BasicCommands) {
25 anbox::qemu::AtParser parser;
27 std::string command = "ATE0Q0V1\nATE0Q0V1\n";
28 std::vector<uint8_t> data;
29 std::copy(command.begin(), command.end(), std::back_inserter(data));
31 int commands_expected = 0;
32 int commands_found = 0;
33 auto assert_at_command = [&](const std::string &expected_command) {
35 return [&](const std::string &command) {
37 ASSERT_STRCASEEQ(expected_command.c_str(), command.c_str());
41 parser.register_command("E0Q0V1", assert_at_command("E0Q0V1"));
42 parser.register_command("E0Q0V1", assert_at_command("E0Q0V1"));
44 parser.process_data(data);
46 ASSERT_EQ(commands_expected, commands_found);