| 10 | using namespace xstudio::embedded_python; |
| 11 | |
| 12 | TEST(EmbeddedPython, Test) { |
| 13 | start_logger(spdlog::level::debug); |
| 14 | EmbeddedPython s{"test"}; |
| 15 | |
| 16 | s.exec("print ('hello')"); |
| 17 | |
| 18 | auto a = s.eval("print ('hello')"); |
| 19 | |
| 20 | auto b = s.eval("1+1"); |
| 21 | EXPECT_EQ(b, 2); |
| 22 | |
| 23 | auto c = s.eval("a+b", nlohmann::json({{"a", 1}, {"b", 2}})); |
| 24 | EXPECT_EQ(c, 3); |
| 25 | |
| 26 | auto d = |
| 27 | s.eval_locals("c=locals()['a']+locals()['b']", nlohmann::json({{"a", 1}, {"b", 2}})); |
| 28 | EXPECT_EQ(d["c"], 3); |
| 29 | |
| 30 | EXPECT_FALSE(s.connect(14441)); |
| 31 | try { |
| 32 | s.exec("print ('hello')"); |
| 33 | } catch (...) { |
| 34 | } |
| 35 | try { |
| 36 | s.exec("print hello')"); |
| 37 | } catch (...) { |
| 38 | } |
| 39 | try { |
| 40 | s.exec("print ('hello')"); |
| 41 | } catch (...) { |
| 42 | } |
| 43 | |
| 44 | // try{ |
| 45 | // auto u = s.create_session(true); |
| 46 | // auto c = s.eval("'"+to_string(u)+"' in xstudio_sessions"); |
| 47 | |
| 48 | // }catch(...){} |
| 49 | } |
nothing calls this directly
no test coverage detected