1
0
mirror of https://github.com/bdring/Grbl_Esp32.git synced 2025-09-01 02:21:46 +02:00

Removed half the unit tests and fixed the rest of them.

This commit is contained in:
Stefan de Bruijn
2021-06-08 10:05:39 +02:00
parent ce688e363f
commit f38bc96195
3 changed files with 108 additions and 243 deletions

View File

@@ -21,52 +21,10 @@ namespace Configuration {
" shared_stepper_disable: gpio.13:low\n"
" \n"
" x:\n"
" steps_per_mm: 800\n"
" max_rate: 2000\n"
" acceleration: 25\n"
" max_travel: 1000\n"
" home_mpos: 10\n"
" \n"
" gang0:\n"
" endstops:\n"
" dual: gpio.17:low:pu\n"
" stepstick:\n"
" direction: gpio:14\n"
" step: gpio.12\n"
" gang1:\n"
" null_motor:\n"
"\n"
" y:\n"
" steps_per_mm: 800\n"
" max_rate: 2000\n"
" acceleration: 25\n"
" max_travel: 1000\n"
" home_mpos: 10\n"
"\n"
" gang0:\n"
" endstops:\n"
" dual: gpio.4:high:pd\n"
" stepstick:\n"
" direction: gpio:15\n"
" step: gpio.26\n"
" gang1:\n"
" null_motor:\n"
"\n"
" z:\n"
" steps_per_mm: 800\n"
" max_rate: 2000\n"
" acceleration: 25\n"
" max_travel: 1000\n"
" home_mpos: 10\n"
"\n"
" gang0:\n"
" endstops:\n"
" dual: gpio.16:pu:low\n"
" stepstick:\n"
" direction: gpio:33\n"
" step: gpio.27\n"
" gang1:\n"
" null_motor:\n"
"\n"
"\n"
"coolant:\n"
@@ -86,115 +44,113 @@ namespace Configuration {
"\n";
Parser p(config, config + strlen(config));
p.Tokenize();
{
Assert(!p.isEndSection(), "No EOS expected");
Assert(!p.Eof(), "No EOF expected");
Assert(p.key().equals("name"), "Expected 'name'");
Assert(p.moveNext(), "Move next failed.");
p.Tokenize();
Assert(!p.isEndSection(), "No EOS expected");
Assert(!p.Eof(), "No EOF expected");
Assert(p.key().equals("board"), "Expected 'board'");
Assert(p.moveNext(), "Move next failed.");
p.Tokenize();
Assert(!p.isEndSection(), "No EOS expected");
Assert(!p.Eof(), "No EOF expected");
Assert(p.key().equals("yaml_wiki"), "Expected 'yaml_wiki'");
Assert(p.moveNext(), "Move next failed.");
p.Tokenize();
Assert(!p.isEndSection(), "No EOS expected");
Assert(!p.Eof(), "No EOF expected");
Assert(p.key().equals("idle_time"), "Expected 'idle_time'");
Assert(p.moveNext(), "Move next failed.");
p.Tokenize();
Assert(!p.isEndSection(), "No EOS expected");
Assert(!p.Eof(), "No EOF expected");
Assert(p.key().equals("step_type"), "Expected 'step_type'");
Assert(p.moveNext(), "Move next failed.");
p.Tokenize();
Assert(!p.isEndSection(), "No EOS expected");
Assert(!p.Eof(), "No EOF expected");
Assert(p.key().equals("dir_delay_microseconds"), "Expected 'dir_delay_microseconds'");
Assert(p.moveNext(), "Move next failed.");
p.Tokenize();
Assert(!p.isEndSection(), "No EOS expected");
Assert(!p.Eof(), "No EOF expected");
Assert(p.key().equals("pulse_microseconds"), "Expected 'pulse_microseconds'");
Assert(p.moveNext(), "Move next failed.");
p.Tokenize();
Assert(!p.isEndSection(), "No EOS expected");
Assert(!p.Eof(), "No EOF expected");
Assert(p.key().equals("disable_delay_us"), "Expected 'disable_delay_us'");
Assert(p.moveNext(), "Move next failed.");
p.Tokenize();
Assert(!p.isEndSection(), "No EOS expected");
Assert(!p.Eof(), "No EOF expected");
Assert(p.key().equals("homing_init_lock"), "Expected 'homing_init_lock'");
Assert(p.moveNext(), "Move next failed.");
p.Tokenize();
Assert(!p.isEndSection(), "No EOS expected");
Assert(!p.Eof(), "No EOF expected");
Assert(p.key().equals("axes"), "Expected 'axes'");
{
p.enter();
p.Tokenize();
Assert(!p.isEndSection(), "No EOS expected");
Assert(!p.Eof(), "No EOF expected");
Assert(p.key().equals("number_axis"), "Expected 'number_axis'");
Assert(p.moveNext(), "Move next failed.");
Assert(!p.isEndSection(), "No EOS expected");
p.Tokenize();
Assert(!p.Eof(), "No EOF expected");
Assert(p.key().equals("shared_stepper_disable"), "Expected 'shared_stepper_disable'");
Assert(p.moveNext(), "Move next failed.");
Assert(!p.isEndSection(), "No EOS expected");
p.Tokenize();
Assert(!p.Eof(), "No EOF expected");
Assert(p.key().equals("x"), "Expected 'x'");
Assert(p.moveNext(), "Move next failed.");
Assert(!p.isEndSection(), "No EOS expected");
p.Tokenize();
Assert(!p.Eof(), "No EOF expected");
Assert(p.key().equals("y"), "Expected 'y'");
Assert(p.moveNext(), "Move next failed.");
Assert(!p.isEndSection(), "No EOS expected");
p.Tokenize();
Assert(!p.Eof(), "No EOF expected");
Assert(p.key().equals("z"), "Expected 'z'");
Assert(!p.moveNext(), "Move next failed.");
Assert(p.isEndSection(), "EOS expected");
p.leave();
}
Assert(!p.isEndSection(), "No EOS expected");
Assert(p.moveNext(), "Move next failed.");
Assert(!p.Eof(), "No EOF expected");
p.Tokenize();
Assert(p.key().equals("coolant"), "Expected 'coolant'");
{
p.enter();
p.Tokenize();
Assert(!p.isEndSection(), "No EOS expected");
Assert(!p.Eof(), "No EOF expected");
Assert(p.key().equals("flood"), "Expected 'flood'");
Assert(p.moveNext(), "Move next failed.");
Assert(!p.isEndSection(), "No EOS expected");
p.Tokenize();
Assert(!p.Eof(), "No EOF expected");
Assert(p.key().equals("mist"), "Expected 'mist'");
Assert(!p.moveNext(), "Move next failed.");
Assert(p.isEndSection(), "No EOS expected");
p.leave();
}
Assert(!p.isEndSection(), "No EOS expected");
Assert(p.moveNext(), "Move next failed.");
Assert(!p.Eof(), "No EOF expected");
p.Tokenize();
Assert(p.key().equals("comms"), "Expected 'comms'");
{
p.enter();
Assert(!p.isEndSection(), "No EOS expected");
p.Tokenize();
Assert(!p.Eof(), "No EOF expected");
Assert(p.key().equals("wifi_sta"), "Expected 'wifi_sta'");
{
p.enter();
Assert(!p.isEndSection(), "No EOS expected");
p.Tokenize();
Assert(!p.Eof(), "No EOF expected");
Assert(p.key().equals("ssid"), "Expected 'ssid'");
Assert(!p.moveNext(), "Move next failed.");
Assert(p.isEndSection(), "No EOS expected");
p.leave();
}
Assert(!p.isEndSection(), "No EOS expected");
Assert(p.moveNext(), "Move next failed.");
Assert(!p.Eof(), "No EOF expected");
p.Tokenize();
Assert(p.key().equals("wifi_ap"), "Expected 'wifi_ap'");
Assert(!p.moveNext(), "Move next failed.");
Assert(p.isEndSection(), "EOS expected");
p.leave();
{
p.Tokenize();
Assert(!p.Eof(), "No EOF expected");
Assert(p.key().equals("ip_address"), "Expected 'ip_address'");
p.Tokenize();
Assert(!p.Eof(), "No EOF expected");
Assert(p.key().equals("ssid"), "Expected 'ssid'");
}
}
Assert(!p.isEndSection(), "No EOS expected");
Assert(p.moveNext(), "Move next failed.");
Assert(!p.Eof(), "No EOF expected");
p.Tokenize();
Assert(p.key().equals("probe"), "Expected 'probe'");
Assert(!p.moveNext(), "Move next failed.");
Assert(p.isEndSection(), "EOS expected");
{
p.Tokenize();
Assert(!p.Eof(), "No EOF expected");
Assert(p.key().equals("pin"), "Expected 'pin'");
}
p.Tokenize();
Assert(p.Eof(), "No EOF expected");
}
}
}

View File

@@ -8,26 +8,28 @@ namespace Configuration {
const char* config = "a: aap\n"
"b: banaan\n"
"\n"
"c: chocolade";
"c: chocolade\n";
Parser p(config, config + strlen(config));
p.Tokenize();
{
Assert(p.key().equals("a"), "Expected 'a'");
Assert(p.stringValue().equals("aap"), "Expected 'aap'");
}
Assert(p.moveNext(), "Move next failed.");
p.Tokenize();
{
Assert(p.key().equals("b"), "Expected 'b'");
Assert(p.stringValue().equals("banaan"), "Expected 'banaan'");
}
Assert(p.moveNext(), "Move next failed.");
p.Tokenize();
{
Assert(p.key().equals("c"), "Expected 'c'");
Assert(p.stringValue().equals("chocolade"), "Expected 'chocolade'");
}
Assert(!p.moveNext(), "Move next failed.");
p.Tokenize();
Assert(p.Eof(), "EOF failed.");
}
Test(YamlParser, SimpleSection) {
@@ -35,33 +37,32 @@ namespace Configuration {
"s:\n"
" b: banaan\n"
"\n"
"c: chocolade";
"c: chocolade\n";
Parser p(config, config + strlen(config));
p.Tokenize();
{
Assert(p.key().equals("a"), "Expected 'a'");
Assert(p.stringValue().equals("aap"), "Expected 'aap'");
}
Assert(p.moveNext(), "Move next failed.");
p.Tokenize();
{
Assert(p.key().equals("s"), "Expected 's'");
p.enter();
{
p.Tokenize();
Assert(p.key().equals("b"), "Expected 'b'");
Assert(p.stringValue().equals("banaan"), "Expected 'banaan'");
}
Assert(!p.moveNext(), "Move next failed.");
p.leave();
}
Assert(p.moveNext(), "Move next failed.");
p.Tokenize();
{
Assert(p.key().equals("c"), "Expected 'c'");
Assert(p.stringValue().equals("chocolade"), "Expected 'chocolade'");
}
Assert(!p.moveNext(), "Move next failed.");
p.Tokenize();
Assert(p.Eof(), "EOF failed.");
}
Test(YamlParser, TwoSequentialSections) {
@@ -71,129 +72,42 @@ namespace Configuration {
"t:\n"
" c: chocolade\n"
"\n"
"w: wipwap";
"w: wipwap\n";
Parser p(config, config + strlen(config));
p.Tokenize();
{
Assert(p.key().equals("a"), "Expected 'a'");
Assert(p.stringValue().equals("aap"), "Expected 'aap'");
}
Assert(p.moveNext(), "Move next failed.");
p.Tokenize();
{
Assert(p.key().equals("s"), "Expected 's'");
p.enter();
p.Tokenize();
{
Assert(p.key().equals("b"), "Expected 'b'");
Assert(p.stringValue().equals("banaan"), "Expected 'banaan'");
}
Assert(!p.moveNext(), "Move next failed.");
p.leave();
}
Assert(p.moveNext(), "Move next failed.");
p.Tokenize();
{
Assert(p.key().equals("t"), "Expected 't'");
p.enter();
p.Tokenize();
{
Assert(p.key().equals("c"), "Expected 'c'");
Assert(p.stringValue().equals("chocolade"), "Expected 'chocolade'");
}
Assert(!p.moveNext(), "Move next failed.");
p.leave();
}
Assert(p.moveNext(), "Move next failed.");
p.Tokenize();
{
Assert(p.key().equals("w"), "Expected 'w'");
Assert(p.stringValue().equals("wipwap"), "Expected 'wipwap'");
}
Assert(!p.moveNext(), "Move next failed.");
}
Test(YamlParser, TwoSequentialSectionsSkipFirst) {
const char* config = "a: aap\n"
"s:\n"
" b: banaan\n"
"t:\n"
" c: chocolade\n"
"\n"
"w: wipwap";
Parser p(config, config + strlen(config));
{
Assert(p.key().equals("a"), "Expected 'a'");
Assert(p.stringValue().equals("aap"), "Expected 'aap'");
}
Assert(p.moveNext(), "Move next failed.");
{
Assert(p.key().equals("s"), "Expected 's'");
}
Assert(p.moveNext(), "Move next failed.");
{
Assert(p.key().equals("t"), "Expected 't'");
p.enter();
{
Assert(p.key().equals("c"), "Expected 'c'");
Assert(p.stringValue().equals("chocolade"), "Expected 'chocolade'");
}
Assert(!p.moveNext(), "Move next failed.");
p.leave();
}
Assert(p.moveNext(), "Move next failed.");
{
Assert(p.key().equals("w"), "Expected 'w'");
Assert(p.stringValue().equals("wipwap"), "Expected 'wipwap'");
}
Assert(!p.moveNext(), "Move next failed.");
}
Test(YamlParser, TwoSequentialSectionsSkipSecond) {
const char* config = "a: aap\n"
"s:\n"
" b: banaan\n"
"t:\n"
" c: chocolade\n"
"\n"
"w: wipwap";
Parser p(config, config + strlen(config));
{
Assert(p.key().equals("a"), "Expected 'a'");
Assert(p.stringValue().equals("aap"), "Expected 'aap'");
}
Assert(p.moveNext(), "Move next failed.");
{
Assert(p.key().equals("s"), "Expected 's'");
p.enter();
{
Assert(p.key().equals("b"), "Expected 'b'");
Assert(p.stringValue().equals("banaan"), "Expected 'banaan'");
}
Assert(!p.moveNext(), "Move next failed.");
p.leave();
}
Assert(p.moveNext(), "Move next failed.");
{
Assert(p.key().equals("t"), "Expected 't'");
}
Assert(p.moveNext(), "Move next failed.");
{
Assert(p.key().equals("w"), "Expected 'w'");
Assert(p.stringValue().equals("wipwap"), "Expected 'wipwap'");
}
Assert(!p.moveNext(), "Move next failed.");
p.Tokenize();
Assert(p.Eof(), "EOF failed.");
}
Test(YamlParser, TwoSequentialSectionsInASection) {
@@ -206,62 +120,56 @@ namespace Configuration {
" c: chocolade\n"
" e: eventjes\n"
"\n"
"w: wipwap";
"w: wipwap\n";
Parser p(config, config + strlen(config));
p.Tokenize();
{
Assert(p.key().equals("a"), "Expected 'a'");
Assert(p.stringValue().equals("aap"), "Expected 'aap'");
}
Assert(p.moveNext(), "Move next failed.");
p.Tokenize();
{
Assert(p.key().equals("r"), "Expected 'r'");
p.enter();
p.Tokenize();
{
Assert(p.key().equals("s"), "Expected 's'");
p.enter();
p.Tokenize();
{
Assert(p.key().equals("b"), "Expected 'b'");
Assert(p.stringValue().equals("banaan"), "Expected 'banaan'");
}
Assert(p.moveNext(), "Move next failed.");
p.Tokenize();
{
Assert(p.key().equals("d"), "Expected 'd'");
Assert(p.stringValue().equals("dinges"), "Expected 'dinges'");
}
Assert(!p.moveNext(), "Move next failed.");
p.leave();
}
Assert(p.moveNext(), "Move next failed.");
p.Tokenize();
{
Assert(p.key().equals("t"), "Expected 't'");
p.enter();
p.Tokenize();
{
Assert(p.key().equals("c"), "Expected 'c'");
Assert(p.stringValue().equals("chocolade"), "Expected 'chocolade'");
}
Assert(p.moveNext(), "Move next failed.");
p.Tokenize();
{
Assert(p.key().equals("e"), "Expected 'e'");
Assert(p.stringValue().equals("eventjes"), "Expected 'eventjes'");
}
Assert(!p.moveNext(), "Move next failed.");
p.leave();
}
Assert(!p.moveNext(), "Move next failed.");
p.leave();
}
Assert(p.moveNext(), "Move next failed.");
p.Tokenize();
{
Assert(p.key().equals("w"), "Expected 'w'");
Assert(p.stringValue().equals("wipwap"), "Expected 'wipwap'");
}
Assert(!p.moveNext(), "Move next failed.");
p.Tokenize();
Assert(p.Eof(), "EOF failed.");
}
}

View File

@@ -52,10 +52,10 @@ namespace Configuration {
int banaan;
void validate() const {}
void handle(HandlerBase& handler) {
handler.handle("aap", aap);
handler.handle("type", value, stepTypes);
handler.handle("banaan", banaan);
void group(HandlerBase& handler) override {
handler.item("aap", aap);
handler.item("type", value, stepTypes);
handler.item("banaan", banaan);
}
};
@@ -66,9 +66,9 @@ namespace Configuration {
int foo = 0;
void validate() const {}
void group(HandlerBase& handler) {
handler.item("n1", n1);
handler.item("n2", n2);
void group(HandlerBase& handler) override {
handler.section("n1", n1);
handler.section("n2", n2);
handler.item("foo", foo);
}
};
@@ -79,10 +79,11 @@ namespace Configuration {
Parser p(config, config + strlen(config));
ParserHandler handler(p);
test.group(handler);
for (; !p.isEndSection(); handler.moveNext()) {
test.group(handler);
}
handler.enterSection("machine", &test);
// test.group(handler);
// for (; !p.Eof(); handler.moveNext()) {
// test.group(handler);
// }
}
};
@@ -90,7 +91,7 @@ namespace Configuration {
const char* config = "a: aap\n"
"b: banaan\n"
"\n"
"c: chocolade";
"c: chocolade\n";
TestBasic test;
Helper::Parse(config, test);