|
|
@ -41,7 +41,7 @@ void test_hex_codes() { |
|
|
|
|
|
|
|
static bool abc_done = false; |
|
|
|
|
|
|
|
terminal::Terminal::addCommand("abc", [](const terminal::CommandContext& ctx) { |
|
|
|
terminal::Terminal::addCommand(F("abc"), [](const terminal::CommandContext& ctx) { |
|
|
|
TEST_ASSERT_EQUAL(2, ctx.argc); |
|
|
|
TEST_ASSERT_EQUAL_STRING("abc", ctx.argv[0].c_str()); |
|
|
|
TEST_ASSERT_EQUAL_STRING("abc", ctx.argv[1].c_str()); |
|
|
@ -68,17 +68,17 @@ void test_multiple_commands() { |
|
|
|
// set up counter to be chained between commands
|
|
|
|
static int command_calls = 0; |
|
|
|
|
|
|
|
terminal::Terminal::addCommand("test1", [](const terminal::CommandContext& ctx) { |
|
|
|
terminal::Terminal::addCommand(F("test1"), [](const terminal::CommandContext& ctx) { |
|
|
|
TEST_ASSERT_EQUAL_MESSAGE(1, ctx.argc, "Command without args should have argc == 1"); |
|
|
|
TEST_ASSERT_EQUAL(0, command_calls); |
|
|
|
command_calls = 1; |
|
|
|
}); |
|
|
|
terminal::Terminal::addCommand("test2", [](const terminal::CommandContext& ctx) { |
|
|
|
terminal::Terminal::addCommand(F("test2"), [](const terminal::CommandContext& ctx) { |
|
|
|
TEST_ASSERT_EQUAL_MESSAGE(1, ctx.argc, "Command without args should have argc == 1"); |
|
|
|
TEST_ASSERT_EQUAL(1, command_calls); |
|
|
|
command_calls = 2; |
|
|
|
}); |
|
|
|
terminal::Terminal::addCommand("test3", [](const terminal::CommandContext& ctx) { |
|
|
|
terminal::Terminal::addCommand(F("test3"), [](const terminal::CommandContext& ctx) { |
|
|
|
TEST_ASSERT_EQUAL_MESSAGE(1, ctx.argc, "Command without args should have argc == 1"); |
|
|
|
TEST_ASSERT_EQUAL(2, command_calls); |
|
|
|
command_calls = 3; |
|
|
@ -113,7 +113,7 @@ void test_command() { |
|
|
|
|
|
|
|
static int counter = 0; |
|
|
|
|
|
|
|
terminal::Terminal::addCommand("test.command", [](const terminal::CommandContext& ctx) { |
|
|
|
terminal::Terminal::addCommand(F("test.command"), [](const terminal::CommandContext& ctx) { |
|
|
|
TEST_ASSERT_EQUAL_MESSAGE(1, ctx.argc, "Command without args should have argc == 1"); |
|
|
|
++counter; |
|
|
|
}); |
|
|
@ -150,12 +150,12 @@ void test_command_args() { |
|
|
|
|
|
|
|
static bool waiting = false; |
|
|
|
|
|
|
|
terminal::Terminal::addCommand("test.command.arg1", [](const terminal::CommandContext& ctx) { |
|
|
|
terminal::Terminal::addCommand(F("test.command.arg1"), [](const terminal::CommandContext& ctx) { |
|
|
|
TEST_ASSERT_EQUAL(2, ctx.argc); |
|
|
|
waiting = false; |
|
|
|
}); |
|
|
|
|
|
|
|
terminal::Terminal::addCommand("test.command.arg1_empty", [](const terminal::CommandContext& ctx) { |
|
|
|
terminal::Terminal::addCommand(F("test.command.arg1_empty"), [](const terminal::CommandContext& ctx) { |
|
|
|
TEST_ASSERT_EQUAL(2, ctx.argc); |
|
|
|
TEST_ASSERT(!ctx.argv[1].length()); |
|
|
|
waiting = false; |
|
|
@ -192,7 +192,7 @@ void test_buffer() { |
|
|
|
|
|
|
|
void test_quotes() { |
|
|
|
|
|
|
|
terminal::Terminal::addCommand("test.quotes", [](const terminal::CommandContext& ctx) { |
|
|
|
terminal::Terminal::addCommand(F("test.quotes"), [](const terminal::CommandContext& ctx) { |
|
|
|
for (auto& arg : ctx.argv) { |
|
|
|
TEST_MESSAGE(arg.c_str()); |
|
|
|
} |
|
|
@ -216,11 +216,11 @@ void test_quotes() { |
|
|
|
|
|
|
|
void test_case_insensitive() { |
|
|
|
|
|
|
|
terminal::Terminal::addCommand("test.lowercase1", [](const terminal::CommandContext& ctx) { |
|
|
|
__asm__ volatile ("nop"); |
|
|
|
terminal::Terminal::addCommand(F("test.lowercase1"), [](const terminal::CommandContext& ctx) { |
|
|
|
TEST_FAIL_MESSAGE("`test.lowercase1` was registered first, but there's another function by the same name. This should not be called"); |
|
|
|
}); |
|
|
|
terminal::Terminal::addCommand("TEST.LOWERCASE1", [](const terminal::CommandContext& ctx) { |
|
|
|
TEST_FAIL_MESSAGE("`test.lowercase1` was already registered, this should not be registered / called"); |
|
|
|
terminal::Terminal::addCommand(F("TEST.LOWERCASE1"), [](const terminal::CommandContext& ctx) { |
|
|
|
__asm__ volatile ("nop"); |
|
|
|
}); |
|
|
|
|
|
|
|
IOStreamString str; |
|
|
@ -235,7 +235,7 @@ void test_case_insensitive() { |
|
|
|
|
|
|
|
void test_output() { |
|
|
|
|
|
|
|
terminal::Terminal::addCommand("test.output", [](const terminal::CommandContext& ctx) { |
|
|
|
terminal::Terminal::addCommand(F("test.output"), [](const terminal::CommandContext& ctx) { |
|
|
|
if (ctx.argc != 2) return; |
|
|
|
ctx.output.print(ctx.argv[1]); |
|
|
|
}); |
|
|
|