251 Bottle bot(
"[add] [one] 14");
274 client.test_void(14);
275 client.test_1way(14);
278 Bottle bot(
"[test] [void] 14");
283 INFO(
"Result is " << bot.
toString() <<
" (should be blank)");
304 x = client.add_one(99);
305 INFO(
"Result " << x);
306 client.test_void(200);
307 client.test_void(201);
308 x = client.add_one(100);
309 INFO(
"Result " << x);
310 client.test_1way(200);
311 client.test_1way(201);
312 x = client.add_one(101);
313 INFO(
"Result " << x);
384 std::vector<DemoEnum>
lst1;
387 std::vector<DemoEnum>
lst2 = client.test_enum_vector(
lst1);
388 INFO(
"lst1 " <<
lst1.size() <<
" lst2 " <<
lst2.size());
409 CHECK(client.test_defaults());
427 msg.fromString(
"add pair 4 3");
433 msg.fromString(
"add pair 4");
438 msg.fromString(
"add pair");
444 msg.fromString(
"add");
456 msg.fromString(
"add pair 10 20");
462 msg.fromString(
"test partial 10 (40 50 60) 5");
468 msg.fromString(
"test partial 10 (40 50)");
475 SECTION(
"test defaults with rpc")
489 msg.fromString(
"test_tail_defaults");
494 msg.fromString(
"test_tail_defaults 55");
499 msg.fromString(
"test longer tail defaults");
504 msg.fromString(
"test longer tail defaults 888");
509 msg.fromString(
"test longer tail defaults 888 ENUM2 47");
515 SECTION(
"test names with spaces")
529 msg.fromString(
"add_one 42");
534 msg.fromString(
"add one 52");
539 msg.fromString(
"get_answer");
544 msg.fromString(
"get answer");
554 mesh.meshName =
"testing";
568 CHECK(
obj2.mesh.meshName == obj.mesh.meshName);
569 CHECK(
obj2.boundingBox.corners.size() == obj.boundingBox.corners.size());
588 x = client.check(
Value(99));
589 INFO(
"Result " << x);
591 x = client.check(
Value(
"6*7"));
592 INFO(
"Result " << x);
594 x = client.check(
Value(
"test"));
595 INFO(
"Result " << x);
598 Bottle b = client.getBottle();
625 x = client.get_answer();
626 INFO(
"Answer " << x);
629 x = client.add_one(88);
630 INFO(
"AddOne gives " << x);
637 s.lst.push_back(DemoStruct(5,10));
638 s.lst.push_back(DemoStruct(9,900));
644 DemoStructList::unwrapped s2;
645 s2.content.lst = s.lst;
654 s.lst.push_back(DemoStruct(5,10));
655 s.lst.push_back(DemoStruct(9,900));
656 INFO(
"String: " << s.toString());
657 CHECK(s.toString() ==
"((5 10) (9 900))");
662 INFO(
"String: " << d.toString());
663 CHECK(d.toString() ==
"10 20");
671 DemoStruct::Editor
e;
706 DemoStruct::Editor
e2;
739 d.int_list.resize(5);
740 DemoStructExt::Editor
e;
742 e.set_int_list(4,15);
750 CHECK(b.
get(1).
asList()->get(2).asList()->get(4).asInt32() == 15);
763 CHECK(help.find(
"get_answer") != std::string::npos);
769 Bottle bot(
"[help] get_answer");
776 CHECK(help.find(
"gets the answer") != std::string::npos);
779 SECTION(
"test structure general help")
782 DemoStruct::Editor
e;
792 CHECK(help.find(
'x') != std::string::npos);
795 SECTION(
"test structure specific help")
798 DemoStruct::Editor
e;
808 CHECK(help.find(
"this is the \\\"x\\\" part") != std::string::npos);
822 a.a_string =
"A string";
827 CHECK(a.a_bool == b.a_bool);
828 CHECK(a.a_i16 == b.a_i16);
829 CHECK(a.a_i32 == b.a_i32);
830 CHECK(a.a_i64 == b.a_i64);
831 CHECK(a.a_double == b.a_double);
832 CHECK(a.a_string == b.a_string);
842 a.a_list_of_bool = std::vector<bool>({
true,
false});
843 a.a_list_of_i8 = std::vector<std::int8_t>({-8, 8});
844 a.a_list_of_i16 = std::vector<std::int16_t>({-16, 16});
845 a.a_list_of_i32 = std::vector<std::int32_t>({-32, 32});
846 a.a_list_of_i64 = std::vector<std::int64_t>({-64, 64});
847 a.a_list_of_double = std::vector<double>({-0.64, 0.64});
848 a.a_list_of_string = std::vector<std::string>({
"A string",
"Another string"});
849 a.a_list_of_binary.resize(2);
850 a.a_list_of_binary[0].resize(6);
851 memset(a.a_list_of_binary[0].data(), 0, a.a_list_of_binary[0].size());
852 a.a_list_of_binary[0][a.a_list_of_binary[0].size() - 1] =
'C';
853 a.a_list_of_binary[1].resize(12);
854 memset(a.a_list_of_binary[1].data(), 0, a.a_list_of_binary[1].size());
855 a.a_list_of_binary[1][a.a_list_of_binary[1].size() - 1] =
'D';
857 a.a_list_of_list_of_double.resize(2);
858 a.a_list_of_list_of_double[0] = std::vector<double>({-0.64, 0.64});
859 a.a_list_of_list_of_double[1] = std::vector<double>({-0.32, 0.32});
864 CHECK(b.a_list_of_bool.size() == a.a_list_of_bool.size());
865 CHECK(b.a_list_of_bool[0] == a.a_list_of_bool[0]);
866 CHECK(b.a_list_of_bool[1] == a.a_list_of_bool[1]);
867 CHECK(b.a_list_of_i8.size() == a.a_list_of_i8.size());
868 CHECK(b.a_list_of_i8[0] == a.a_list_of_i8[0]);
869 CHECK(b.a_list_of_i8[1] == a.a_list_of_i8[1]);
870 CHECK(b.a_list_of_i16.size() == a.a_list_of_i16.size());
871 CHECK(b.a_list_of_i16[0] == a.a_list_of_i16[0]);
872 CHECK(b.a_list_of_i16[1] == a.a_list_of_i16[1]);
873 CHECK(b.a_list_of_i32.size() == a.a_list_of_i32.size());
874 CHECK(b.a_list_of_i32[0] == a.a_list_of_i32[0]);
875 CHECK(b.a_list_of_i32[1] == a.a_list_of_i32[1]);
876 CHECK(b.a_list_of_i64.size() == a.a_list_of_i64.size());
877 CHECK(b.a_list_of_i64[0] == a.a_list_of_i64[0]);
878 CHECK(b.a_list_of_i64[1] == a.a_list_of_i64[1]);
879 CHECK(b.a_list_of_double.size() == a.a_list_of_double.size());
880 CHECK(b.a_list_of_double[0] == a.a_list_of_double[0]);
881 CHECK(b.a_list_of_double[1] == a.a_list_of_double[1]);
882 CHECK(b.a_list_of_string.size() == a.a_list_of_string.size());
883 CHECK(b.a_list_of_string[0] == a.a_list_of_string[0]);
884 CHECK(b.a_list_of_string[1] == a.a_list_of_string[1]);
885 CHECK(b.a_list_of_binary.size() == a.a_list_of_binary.size());
886 CHECK(b.a_list_of_binary[0].size() == 6);
887 CHECK(b.a_list_of_binary[1].size() == 12);
888 CHECK(b.a_list_of_binary[0][5] ==
'C');
889 CHECK(b.a_list_of_binary[1][11] ==
'D');
891 CHECK(b.a_list_of_list_of_double.size() == a.a_list_of_list_of_double.size());
892 CHECK(b.a_list_of_list_of_double[0].size() == a.a_list_of_list_of_double[0].size());
893 CHECK(b.a_list_of_list_of_double[0][0] == a.a_list_of_list_of_double[0][0]);
894 CHECK(b.a_list_of_list_of_double[0][1] == a.a_list_of_list_of_double[0][1]);
895 CHECK(b.a_list_of_list_of_double[1].size() == a.a_list_of_list_of_double[1].size());
896 CHECK(b.a_list_of_list_of_double[1][0] == a.a_list_of_list_of_double[1][0]);
897 CHECK(b.a_list_of_list_of_double[1][1] == a.a_list_of_list_of_double[1][1]);
906 a.a_map_of_list_of_double[
"first"] = std::vector<double>({-0.64, 0.64});
907 a.a_map_of_list_of_double[
"second"] = std::vector<double>({-0.32, 0.32});
908 a.a_map_of_list_of_list_of_double[
"first"].push_back(std::vector<double>({-0.16, 0.16}));
909 a.a_map_of_list_of_list_of_double[
"first"].push_back(std::vector<double>({-0.08, 0.08}));
910 a.a_map_of_list_of_list_of_double[
"second"].push_back(std::vector<double>({-0.04, 0.04}));
911 a.a_map_of_list_of_list_of_double[
"second"].push_back(std::vector<double>({-0.02, 0.02}));
913 a.a_list_of_maps_of_doubles.push_back(std::map<std::string, double>({{
"0first", 0.1}, {
"0second", 0.2}}));
914 a.a_list_of_maps_of_doubles.push_back(std::map<std::string, double>({{
"1first", 1.1}, {
"1second", 1.2}}));
919 CHECK(b.a_map_of_list_of_double.size() == a.a_map_of_list_of_double.size());
920 CHECK(b.a_map_of_list_of_double[
"first"].size() == a.a_map_of_list_of_double[
"first"].size());
921 CHECK(b.a_map_of_list_of_double[
"first"][0] == a.a_map_of_list_of_double[
"first"][0]);
922 CHECK(b.a_map_of_list_of_double[
"first"][1] == a.a_map_of_list_of_double[
"first"][1]);
923 CHECK(b.a_map_of_list_of_double[
"second"].size() == a.a_map_of_list_of_double[
"second"].size());
924 CHECK(b.a_map_of_list_of_double[
"second"][0] == a.a_map_of_list_of_double[
"second"][0]);
925 CHECK(b.a_map_of_list_of_double[
"second"][1] == a.a_map_of_list_of_double[
"second"][1]);
927 CHECK(b.a_map_of_list_of_list_of_double.size() == a.a_map_of_list_of_list_of_double.size());
928 CHECK(b.a_map_of_list_of_list_of_double[
"first"].size() == a.a_map_of_list_of_list_of_double[
"first"].size());
929 CHECK(b.a_map_of_list_of_list_of_double[
"first"][0].size() == a.a_map_of_list_of_list_of_double[
"first"][0].size());
930 CHECK(b.a_map_of_list_of_list_of_double[
"first"][0][0] == a.a_map_of_list_of_list_of_double[
"first"][0][0]);
931 CHECK(b.a_map_of_list_of_list_of_double[
"first"][0][1] == a.a_map_of_list_of_list_of_double[
"first"][0][1]);
932 CHECK(b.a_map_of_list_of_list_of_double[
"first"][1].size() == a.a_map_of_list_of_list_of_double[
"first"][1].size());
933 CHECK(b.a_map_of_list_of_list_of_double[
"first"][1][0] == a.a_map_of_list_of_list_of_double[
"first"][1][0]);
934 CHECK(b.a_map_of_list_of_list_of_double[
"first"][1][1] == a.a_map_of_list_of_list_of_double[
"first"][1][1]);
935 CHECK(b.a_map_of_list_of_list_of_double[
"second"].size() == a.a_map_of_list_of_list_of_double[
"second"].size());
936 CHECK(b.a_map_of_list_of_list_of_double[
"second"][0].size() == a.a_map_of_list_of_list_of_double[
"second"][0].size());
937 CHECK(b.a_map_of_list_of_list_of_double[
"second"][0][0] == a.a_map_of_list_of_list_of_double[
"second"][0][0]);
938 CHECK(b.a_map_of_list_of_list_of_double[
"second"][0][1] == a.a_map_of_list_of_list_of_double[
"second"][0][1]);
939 CHECK(b.a_map_of_list_of_list_of_double[
"second"][1].size() == a.a_map_of_list_of_list_of_double[
"second"][1].size());
940 CHECK(b.a_map_of_list_of_list_of_double[
"second"][1][0] == a.a_map_of_list_of_list_of_double[
"second"][1][0]);
941 CHECK(b.a_map_of_list_of_list_of_double[
"second"][1][1] == a.a_map_of_list_of_list_of_double[
"second"][1][1]);
943 CHECK(b.a_list_of_maps_of_doubles.size() == a.a_list_of_maps_of_doubles.size());
944 CHECK(b.a_list_of_maps_of_doubles[0][
"0first"] == a.a_list_of_maps_of_doubles[0][
"0first"]);
945 CHECK(b.a_list_of_maps_of_doubles[0][
"0second"] == a.a_list_of_maps_of_doubles[0][
"0second"]);
946 CHECK(b.a_list_of_maps_of_doubles[1][
"1first"] == a.a_list_of_maps_of_doubles[1][
"1first"]);
947 CHECK(b.a_list_of_maps_of_doubles[1][
"1second"] == a.a_list_of_maps_of_doubles[1][
"1second"]);
950 SECTION(
"test lists with previous data")
956 a.a_list_of_bool = std::vector<bool>({
true,
false});
957 a.a_list_of_i8 = std::vector<std::int8_t>({-8, 8});
958 a.a_list_of_i16 = std::vector<std::int16_t>({-16, 16});
959 a.a_list_of_i32 = std::vector<std::int32_t>({-32, 32});
960 a.a_list_of_i64 = std::vector<std::int64_t>({-64, 64});
961 a.a_list_of_double = std::vector<double>({-0.64, 0.64});
962 a.a_list_of_string = std::vector<std::string>({
"A string",
"Another string"});
963 a.a_list_of_binary.resize(2);
964 a.a_list_of_binary[0].resize(6);
965 memset(a.a_list_of_binary[0].data(), 0, a.a_list_of_binary[0].size());
966 a.a_list_of_binary[0][a.a_list_of_binary[0].size() - 1] =
'C';
967 a.a_list_of_binary[1].resize(12);
968 memset(a.a_list_of_binary[1].data(), 0, a.a_list_of_binary[1].size());
969 a.a_list_of_binary[1][a.a_list_of_binary[1].size() - 1] =
'D';
971 b.a_list_of_bool = std::vector<bool>({
false,
true,
false});
972 b.a_list_of_i8 = std::vector<std::int8_t>({8, -8, 8});
973 b.a_list_of_i16 = std::vector<std::int16_t>({16, -16, 16});
974 b.a_list_of_i32 = std::vector<std::int32_t>({32, -32, 32});
975 b.a_list_of_i64 = std::vector<std::int64_t>({64, -64, 64});
976 b.a_list_of_double = std::vector<double>({0.64, -0.64, 0.64});
977 b.a_list_of_string = std::vector<std::string>({
"The string",
"A string",
"Another string"});
978 b.a_list_of_binary.resize(3);
979 b.a_list_of_binary[0].resize(12);
980 memset(b.a_list_of_binary[0].data(), 0, b.a_list_of_binary[0].size());
981 b.a_list_of_binary[0][b.a_list_of_binary[0].size() - 1] =
'E';
982 b.a_list_of_binary[1].resize(6);
983 memset(b.a_list_of_binary[1].data(), 0, b.a_list_of_binary[1].size());
984 b.a_list_of_binary[1][b.a_list_of_binary[1].size() - 1] =
'F';
985 b.a_list_of_binary[2].resize(12);
986 memset(b.a_list_of_binary[2].data(), 0, b.a_list_of_binary[2].size());
987 b.a_list_of_binary[2][b.a_list_of_binary[2].size() - 1] =
'G';
992 CHECK(b.a_list_of_bool.size() == a.a_list_of_bool.size());
993 CHECK(b.a_list_of_bool[0] == a.a_list_of_bool[0]);
994 CHECK(b.a_list_of_bool[1] == a.a_list_of_bool[1]);
995 CHECK(b.a_list_of_i8.size() == a.a_list_of_i8.size());
996 CHECK(b.a_list_of_i8[0] == a.a_list_of_i8[0]);
997 CHECK(b.a_list_of_i8[1] == a.a_list_of_i8[1]);
998 CHECK(b.a_list_of_i16.size() == a.a_list_of_i16.size());
999 CHECK(b.a_list_of_i16[0] == a.a_list_of_i16[0]);
1000 CHECK(b.a_list_of_i16[1] == a.a_list_of_i16[1]);
1001 CHECK(b.a_list_of_i32.size() == a.a_list_of_i32.size());
1002 CHECK(b.a_list_of_i32[0] == a.a_list_of_i32[0]);
1003 CHECK(b.a_list_of_i32[1] == a.a_list_of_i32[1]);
1004 CHECK(b.a_list_of_i64.size() == a.a_list_of_i64.size());
1005 CHECK(b.a_list_of_i64[0] == a.a_list_of_i64[0]);
1006 CHECK(b.a_list_of_i64[1] == a.a_list_of_i64[1]);
1007 CHECK(b.a_list_of_double.size() == a.a_list_of_double.size());
1008 CHECK(b.a_list_of_double[0] == a.a_list_of_double[0]);
1009 CHECK(b.a_list_of_double[1] == a.a_list_of_double[1]);
1010 CHECK(b.a_list_of_string.size() == a.a_list_of_string.size());
1011 CHECK(b.a_list_of_string[0] == a.a_list_of_string[0]);
1012 CHECK(b.a_list_of_string[1] == a.a_list_of_string[1]);
1013 CHECK(b.a_list_of_binary.size() == a.a_list_of_binary.size());
1014 CHECK(b.a_list_of_binary[0].size() == 6);
1015 CHECK(b.a_list_of_binary[1].size() == 12);
1016 CHECK(b.a_list_of_binary[0][5] ==
'C');
1017 CHECK(b.a_list_of_binary[1][11] ==
'D');
1027 b.a_list_of_bool = std::vector<bool>({
true,
false});
1028 b.a_list_of_i8 = std::vector<std::int8_t>({-8, 8});
1029 b.a_list_of_i16 = std::vector<std::int16_t>({-16, 16});
1030 b.a_list_of_i32 = std::vector<std::int32_t>({-32, 32});
1031 b.a_list_of_i64 = std::vector<std::int64_t>({-64, 64});
1032 b.a_list_of_double = std::vector<double>({-0.64, 0.64});
1033 b.a_list_of_string = std::vector<std::string>({
"A string",
"Another string"});
1034 b.a_list_of_binary.resize(2);
1035 b.a_list_of_binary[0].resize(6);
1036 memset(b.a_list_of_binary[0].data(), 0, b.a_list_of_binary[0].size());
1037 b.a_list_of_binary[0][b.a_list_of_binary[0].size() - 1] =
'C';
1038 b.a_list_of_binary[1].resize(12);
1039 memset(b.a_list_of_binary[1].data(), 0, b.a_list_of_binary[1].size());
1040 b.a_list_of_binary[1][b.a_list_of_binary[1].size() - 1] =
'D';
1045 CHECK(b.a_list_of_bool.empty());
1046 CHECK(b.a_list_of_i8.empty());
1047 CHECK(b.a_list_of_i16.empty());
1048 CHECK(b.a_list_of_i32.empty());
1049 CHECK(b.a_list_of_i64.empty());
1050 CHECK(b.a_list_of_double.empty());
1051 CHECK(b.a_list_of_string.empty());
1052 CHECK(b.a_list_of_binary.empty());
1055 SECTION(
"test annotated types")
1063 a.a_ui32 = 0xffffffff;
1064 a.a_ui64 = 0xffffffffffffffff;
1072 CHECK(a.a_vocab == b.a_vocab);
1073 CHECK(a.a_ui8 == b.a_ui8);
1074 CHECK(a.a_ui16 == b.a_ui16);
1075 CHECK(a.a_ui32 == b.a_ui32);
1076 CHECK(a.a_ui64 == b.a_ui64);
1077 CHECK(a.a_float32 == b.a_float32);
1078 CHECK(a.a_float64 == b.a_float64);
1083 Settings::Editor settings;
1098 CHECK(receiver.state().id == 5);
1100 settings.set_name(
"hello");
1101 CHECK(receiver.state().name ==
"hello");
1103 settings.start_editing();
1105 CHECK(receiver.state().id == 5);
1107 settings.set_name(
"world");
1108 CHECK(receiver.state().name ==
"hello");
1109 settings.stop_editing();
1110 CHECK(receiver.state().id == 6);
1111 CHECK(receiver.state().name ==
"world");
1115 cmd.
fromString(
"patch (set id 3) (set name frog)");
1118 CHECK(receiver.state().id == 3);
1119 CHECK(receiver.state().name ==
"frog");
1124 CHECK(receiver.state().id == 9);
1126 cmd.
fromString(
"set id 99 name \"Space Monkey\"");
1129 CHECK(receiver.state().id == 99);
1130 CHECK(receiver.state().name ==
"Space Monkey");
1132 cmd.
fromString(
"set id 99 name \"Space Monkey\" id 101");
1135 CHECK(receiver.state().id == 101);
1151 INFO(
"Starting a long operation");
1152 client.do_start_a_service();
1154 INFO(
"Stopping a long operation");
1155 client.do_stop_a_service();
1171 INFO(
"Requesting a map type");
1197 INFO(
"calling a const method");
1198 CHECK(
const_cast<const Demo&
>(client).this_is_a_const_method());