1 #include <rtosc/rtosc.h>
2 #include <rtosc/thread-link.h>
3 #include <rtosc/ports.h>
4 #include <string>
5 #include "common.h"
6 
7 using namespace rtosc;
8 
9 std::string resultA;
10 int resultB = 0;
11 Ports ports = {
__anonf08e0a000102() 12     {"setstring:s", "", 0, [](msg_t msg,RtData&) {resultA = rtosc_argument(msg,0).s;}},
__anonf08e0a000202() 13     {"setint:i",    "", 0, [](msg_t msg,RtData&) {resultB = rtosc_argument(msg,0).i;}},
__anonf08e0a000302() 14     {"echo:ss",     "", 0, [](msg_t,RtData&) {}}
15 };
16 
17 ThreadLink tlink(512,100);
18 
main()19 int main()
20 {
21     for(int j=0; j<100; ++j) {
22         for(int i=0; i<100; ++i){
23             tlink.write("badvalue",  "");
24             tlink.write("setstring", "s", "testing");
25             tlink.write("setint",    "i", 123);
26             tlink.write("setint",    "s", "dog");
27             tlink.write("echo",      "ss", "hello", "rtosc");
28         }
29 
30         RtData d;
31         d.loc_size = 0;
32         d.obj = d.loc = NULL;
33         while(tlink.hasNext())
34             ports.dispatch(tlink.read(), d);
35     }
36     tlink.write("echo", "ss", "hello", "rtosc");
37 
38     assert_str_eq("testing", resultA.c_str(),
39             "Check String Dispatch Field", __LINE__);
40     assert_int_eq(123,       resultB, "Check Integer Dispatch Field", __LINE__);
41 
42     return test_summary();
43 }
44