diff --git a/radio/src/Makefile b/radio/src/Makefile index b06c34edc..4d01105a1 100644 --- a/radio/src/Makefile +++ b/radio/src/Makefile @@ -1500,5 +1500,5 @@ gtest_main.a : gtest-all.o gtest_main.o GTEST_TESTS_SRCS = $(shell find tests/ -type f -name '*.cpp') gtests: $(BOARDSRC) $(CPPSRC) $(GTEST_TESTS_SRCS) targets/simu/simpgmspace.cpp *.h gtest_main.a - g++ -std=gnu++0x $(CPPFLAGS) $(BOARDSRC) $(CPPSRC) $(GTEST_TESTS_SRCS) targets/simu/simpgmspace.cpp -I$(GTEST_DIR) ${INCFLAGS} -I$(GTEST_DIR)/include -o gtests -lpthread -MD -DSIMU -lQtCore -lQtGui gtest_main.a + g++ -std=gnu++0x $(CPPFLAGS) $(BOARDSRC) $(CPPSRC) $(LUASRC) $(GTEST_TESTS_SRCS) targets/simu/simpgmspace.cpp -I$(GTEST_DIR) ${INCFLAGS} -I$(GTEST_DIR)/include -o gtests -lpthread -MD -DSIMU -lQtCore -lQtGui gtest_main.a -fexceptions diff --git a/radio/src/tests/frsky.cpp b/radio/src/tests/frsky.cpp index 08761bfc3..74fd0f043 100644 --- a/radio/src/tests/frsky.cpp +++ b/radio/src/tests/frsky.cpp @@ -34,10 +34,7 @@ * */ -#include -#include -#include -#include +#include #include #include diff --git a/radio/src/tests/gtests.cpp b/radio/src/tests/gtests.cpp index 90a1e3b86..bce79a477 100644 --- a/radio/src/tests/gtests.cpp +++ b/radio/src/tests/gtests.cpp @@ -34,11 +34,7 @@ * */ -#include -#include #include -#include -#include #include #define SWAP_DEFINED @@ -177,6 +173,7 @@ int main(int argc, char **argv) StartEepromThread(NULL); g_menuStackPtr = 0; g_menuStack[0] = menuMainView; + LUA_RESET(); ::testing::InitGoogleTest(&argc, argv); return RUN_ALL_TESTS(); } diff --git a/radio/src/tests/lua.cpp b/radio/src/tests/lua.cpp new file mode 100755 index 000000000..77113e8ec --- /dev/null +++ b/radio/src/tests/lua.cpp @@ -0,0 +1,63 @@ +/* + * Authors (alphabetical order) + * - Andre Bernet + * - Andreas Weitl + * - Bertrand Songis + * - Bryan J. Rentoul (Gruvin) + * - Cameron Weeks + * - Erez Raviv + * - Gabriel Birkus + * - Jean-Pierre Parisy + * - Karl Szmutny + * - Michael Blandford + * - Michal Hlavinka + * - Pat Mackenzie + * - Philip Moss + * - Rob Thomson + * - Romolo Manfredini + * - Thomas Husterer + * + * opentx is based on code named + * gruvin9x by Bryan J. Rentoul: http://code.google.com/p/gruvin9x/, + * er9x by Erez Raviv: http://code.google.com/p/er9x/, + * and the original (and ongoing) project by + * Thomas Husterer, th9x: http://code.google.com/p/th9x/ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + */ + +#include +#include + +#if defined(LUA) + +#define SWAP_DEFINED +#include "opentx.h" + +#include +#include +#include + +void luaExecStr(const char * str) +{ + extern lua_State * L; + luaL_dostring(L, str); +} + +TEST(Lua, testSetModelId) +{ + luaExecStr("info = model.getInfo()"); + luaExecStr("info.id = 2"); + luaExecStr("model.setInfo(info)"); + EXPECT_EQ(g_model.header.modelId, 2); +} + +#endif diff --git a/radio/src/tests/mixer.cpp b/radio/src/tests/mixer.cpp index 79bb15f81..8bd038f3a 100644 --- a/radio/src/tests/mixer.cpp +++ b/radio/src/tests/mixer.cpp @@ -34,10 +34,6 @@ * */ -#include -#include -#include -#include #include #include diff --git a/radio/src/tests/switches.cpp b/radio/src/tests/switches.cpp index b9c144621..85344c517 100644 --- a/radio/src/tests/switches.cpp +++ b/radio/src/tests/switches.cpp @@ -34,10 +34,6 @@ * */ -#include -#include -#include -#include #include #include