MCPcopy Create free account
hub / github.com/AcademySoftwareFoundation/xstudio / TEST

Function TEST

src/embedded_python/test/embedded_python_test.cpp:12–49  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

10using namespace xstudio::embedded_python;
11
12TEST(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}

Callers

nothing calls this directly

Calls 4

execMethod · 0.80
eval_localsMethod · 0.80
connectMethod · 0.80
evalMethod · 0.45

Tested by

no test coverage detected