250 Bottle bot(
"[add] [one] 14");
273 client.test_void(14);
274 client.test_1way(14);
277 Bottle bot(
"[test] [void] 14");
282 INFO(
"Result is " << bot.
toString() <<
" (should be blank)");
303 x = client.add_one(99);
304 INFO(
"Result " << x);
305 client.test_void(200);
306 client.test_void(201);
307 x = client.add_one(100);
308 INFO(
"Result " << x);
309 client.test_1way(200);
310 client.test_1way(201);
311 x = client.add_one(101);
312 INFO(
"Result " << x);
383 std::vector<DemoEnum>
lst1;
386 std::vector<DemoEnum>
lst2 = client.test_enum_vector(
lst1);
387 INFO(
"lst1 " <<
lst1.size() <<
" lst2 " <<
lst2.size());
408 CHECK(client.test_defaults());
426 msg.fromString(
"add pair 4 3");
432 msg.fromString(
"add pair 4");
437 msg.fromString(
"add pair");
443 msg.fromString(
"add");
455 msg.fromString(
"add pair 10 20");
461 msg.fromString(
"test partial 10 (40 50 60) 5");
467 msg.fromString(
"test partial 10 (40 50)");
474 SECTION(
"test defaults with rpc")
488 msg.fromString(
"test_tail_defaults");
493 msg.fromString(
"test_tail_defaults 55");
498 msg.fromString(
"test longer tail defaults");
503 msg.fromString(
"test longer tail defaults 888");
508 msg.fromString(
"test longer tail defaults 888 ENUM2 47");
514 SECTION(
"test names with spaces")
528 msg.fromString(
"add_one 42");
533 msg.fromString(
"add one 52");
538 msg.fromString(
"get_answer");
543 msg.fromString(
"get answer");
553 mesh.meshName =
"testing";
567 CHECK(
obj2.mesh.meshName == obj.mesh.meshName);
568 CHECK(
obj2.boundingBox.corners.size() == obj.boundingBox.corners.size());
587 x = client.check(
Value(99));
588 INFO(
"Result " << x);
590 x = client.check(
Value(
"6*7"));
591 INFO(
"Result " << x);
593 x = client.check(
Value(
"test"));
594 INFO(
"Result " << x);
597 Bottle b = client.getBottle();
624 x = client.get_answer();
625 INFO(
"Answer " << x);
628 x = client.add_one(88);
629 INFO(
"AddOne gives " << x);
636 s.lst.push_back(DemoStruct(5,10));
637 s.lst.push_back(DemoStruct(9,900));
643 DemoStructList::unwrapped s2;
644 s2.content.lst = s.lst;
653 s.lst.push_back(DemoStruct(5,10));
654 s.lst.push_back(DemoStruct(9,900));
655 INFO(
"String: " << s.toString());
656 CHECK(s.toString() ==
"((5 10) (9 900))");
661 INFO(
"String: " << d.toString());
662 CHECK(d.toString() ==
"10 20");
670 DemoStruct::Editor
e;
705 DemoStruct::Editor
e2;
738 d.int_list.resize(5);
739 DemoStructExt::Editor
e;
741 e.set_int_list(4,15);
749 CHECK(b.
get(1).
asList()->get(2).asList()->get(4).asInt32() == 15);
762 CHECK(help.find(
"get_answer") != std::string::npos);
768 Bottle bot(
"[help] get_answer");
775 CHECK(help.find(
"gets the answer") != std::string::npos);
778 SECTION(
"test structure general help")
781 DemoStruct::Editor
e;
791 CHECK(help.find(
'x') != std::string::npos);
794 SECTION(
"test structure specific help")
797 DemoStruct::Editor
e;
807 CHECK(help.find(
"this is the \\\"x\\\" part") != std::string::npos);
821 a.a_string =
"A string";
826 CHECK(a.a_bool == b.a_bool);
827 CHECK(a.a_i16 == b.a_i16);
828 CHECK(a.a_i32 == b.a_i32);
829 CHECK(a.a_i64 == b.a_i64);
830 CHECK(a.a_double == b.a_double);
831 CHECK(a.a_string == b.a_string);
841 a.a_list_of_bool = std::vector<bool>({
true,
false});
842 a.a_list_of_i8 = std::vector<std::int8_t>({-8, 8});
843 a.a_list_of_i16 = std::vector<std::int16_t>({-16, 16});
844 a.a_list_of_i32 = std::vector<std::int32_t>({-32, 32});
845 a.a_list_of_i64 = std::vector<std::int64_t>({-64, 64});
846 a.a_list_of_double = std::vector<double>({-0.64, 0.64});
847 a.a_list_of_string = std::vector<std::string>({
"A string",
"Another string"});
848 a.a_list_of_binary.resize(2);
849 a.a_list_of_binary[0].resize(6);
850 memset(a.a_list_of_binary[0].data(), 0, a.a_list_of_binary[0].size());
851 a.a_list_of_binary[0][a.a_list_of_binary[0].size() - 1] =
'C';
852 a.a_list_of_binary[1].resize(12);
853 memset(a.a_list_of_binary[1].data(), 0, a.a_list_of_binary[1].size());
854 a.a_list_of_binary[1][a.a_list_of_binary[1].size() - 1] =
'D';
856 a.a_list_of_list_of_double.resize(2);
857 a.a_list_of_list_of_double[0] = std::vector<double>({-0.64, 0.64});
858 a.a_list_of_list_of_double[1] = std::vector<double>({-0.32, 0.32});
863 CHECK(b.a_list_of_bool.size() == a.a_list_of_bool.size());
864 CHECK(b.a_list_of_bool[0] == a.a_list_of_bool[0]);
865 CHECK(b.a_list_of_bool[1] == a.a_list_of_bool[1]);
866 CHECK(b.a_list_of_i8.size() == a.a_list_of_i8.size());
867 CHECK(b.a_list_of_i8[0] == a.a_list_of_i8[0]);
868 CHECK(b.a_list_of_i8[1] == a.a_list_of_i8[1]);
869 CHECK(b.a_list_of_i16.size() == a.a_list_of_i16.size());
870 CHECK(b.a_list_of_i16[0] == a.a_list_of_i16[0]);
871 CHECK(b.a_list_of_i16[1] == a.a_list_of_i16[1]);
872 CHECK(b.a_list_of_i32.size() == a.a_list_of_i32.size());
873 CHECK(b.a_list_of_i32[0] == a.a_list_of_i32[0]);
874 CHECK(b.a_list_of_i32[1] == a.a_list_of_i32[1]);
875 CHECK(b.a_list_of_i64.size() == a.a_list_of_i64.size());
876 CHECK(b.a_list_of_i64[0] == a.a_list_of_i64[0]);
877 CHECK(b.a_list_of_i64[1] == a.a_list_of_i64[1]);
878 CHECK(b.a_list_of_double.size() == a.a_list_of_double.size());
879 CHECK(b.a_list_of_double[0] == a.a_list_of_double[0]);
880 CHECK(b.a_list_of_double[1] == a.a_list_of_double[1]);
881 CHECK(b.a_list_of_string.size() == a.a_list_of_string.size());
882 CHECK(b.a_list_of_string[0] == a.a_list_of_string[0]);
883 CHECK(b.a_list_of_string[1] == a.a_list_of_string[1]);
884 CHECK(b.a_list_of_binary.size() == a.a_list_of_binary.size());
885 CHECK(b.a_list_of_binary[0].size() == 6);
886 CHECK(b.a_list_of_binary[1].size() == 12);
887 CHECK(b.a_list_of_binary[0][5] ==
'C');
888 CHECK(b.a_list_of_binary[1][11] ==
'D');
890 CHECK(b.a_list_of_list_of_double.size() == a.a_list_of_list_of_double.size());
891 CHECK(b.a_list_of_list_of_double[0].size() == a.a_list_of_list_of_double[0].size());
892 CHECK(b.a_list_of_list_of_double[0][0] == a.a_list_of_list_of_double[0][0]);
893 CHECK(b.a_list_of_list_of_double[0][1] == a.a_list_of_list_of_double[0][1]);
894 CHECK(b.a_list_of_list_of_double[1].size() == a.a_list_of_list_of_double[1].size());
895 CHECK(b.a_list_of_list_of_double[1][0] == a.a_list_of_list_of_double[1][0]);
896 CHECK(b.a_list_of_list_of_double[1][1] == a.a_list_of_list_of_double[1][1]);
905 a.a_map_of_list_of_double[
"first"] = std::vector<double>({-0.64, 0.64});
906 a.a_map_of_list_of_double[
"second"] = std::vector<double>({-0.32, 0.32});
907 a.a_map_of_list_of_list_of_double[
"first"].push_back(std::vector<double>({-0.16, 0.16}));
908 a.a_map_of_list_of_list_of_double[
"first"].push_back(std::vector<double>({-0.08, 0.08}));
909 a.a_map_of_list_of_list_of_double[
"second"].push_back(std::vector<double>({-0.04, 0.04}));
910 a.a_map_of_list_of_list_of_double[
"second"].push_back(std::vector<double>({-0.02, 0.02}));
912 a.a_list_of_maps_of_doubles.push_back(std::map<std::string, double>({{
"0first", 0.1}, {
"0second", 0.2}}));
913 a.a_list_of_maps_of_doubles.push_back(std::map<std::string, double>({{
"1first", 1.1}, {
"1second", 1.2}}));
918 CHECK(b.a_map_of_list_of_double.size() == a.a_map_of_list_of_double.size());
919 CHECK(b.a_map_of_list_of_double[
"first"].size() == a.a_map_of_list_of_double[
"first"].size());
920 CHECK(b.a_map_of_list_of_double[
"first"][0] == a.a_map_of_list_of_double[
"first"][0]);
921 CHECK(b.a_map_of_list_of_double[
"first"][1] == a.a_map_of_list_of_double[
"first"][1]);
922 CHECK(b.a_map_of_list_of_double[
"second"].size() == a.a_map_of_list_of_double[
"second"].size());
923 CHECK(b.a_map_of_list_of_double[
"second"][0] == a.a_map_of_list_of_double[
"second"][0]);
924 CHECK(b.a_map_of_list_of_double[
"second"][1] == a.a_map_of_list_of_double[
"second"][1]);
926 CHECK(b.a_map_of_list_of_list_of_double.size() == a.a_map_of_list_of_list_of_double.size());
927 CHECK(b.a_map_of_list_of_list_of_double[
"first"].size() == a.a_map_of_list_of_list_of_double[
"first"].size());
928 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());
929 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]);
930 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]);
931 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());
932 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]);
933 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]);
934 CHECK(b.a_map_of_list_of_list_of_double[
"second"].size() == a.a_map_of_list_of_list_of_double[
"second"].size());
935 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());
936 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]);
937 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]);
938 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());
939 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]);
940 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]);
942 CHECK(b.a_list_of_maps_of_doubles.size() == a.a_list_of_maps_of_doubles.size());
943 CHECK(b.a_list_of_maps_of_doubles[0][
"0first"] == a.a_list_of_maps_of_doubles[0][
"0first"]);
944 CHECK(b.a_list_of_maps_of_doubles[0][
"0second"] == a.a_list_of_maps_of_doubles[0][
"0second"]);
945 CHECK(b.a_list_of_maps_of_doubles[1][
"1first"] == a.a_list_of_maps_of_doubles[1][
"1first"]);
946 CHECK(b.a_list_of_maps_of_doubles[1][
"1second"] == a.a_list_of_maps_of_doubles[1][
"1second"]);
949 SECTION(
"test lists with previous data")
955 a.a_list_of_bool = std::vector<bool>({
true,
false});
956 a.a_list_of_i8 = std::vector<std::int8_t>({-8, 8});
957 a.a_list_of_i16 = std::vector<std::int16_t>({-16, 16});
958 a.a_list_of_i32 = std::vector<std::int32_t>({-32, 32});
959 a.a_list_of_i64 = std::vector<std::int64_t>({-64, 64});
960 a.a_list_of_double = std::vector<double>({-0.64, 0.64});
961 a.a_list_of_string = std::vector<std::string>({
"A string",
"Another string"});
962 a.a_list_of_binary.resize(2);
963 a.a_list_of_binary[0].resize(6);
964 memset(a.a_list_of_binary[0].data(), 0, a.a_list_of_binary[0].size());
965 a.a_list_of_binary[0][a.a_list_of_binary[0].size() - 1] =
'C';
966 a.a_list_of_binary[1].resize(12);
967 memset(a.a_list_of_binary[1].data(), 0, a.a_list_of_binary[1].size());
968 a.a_list_of_binary[1][a.a_list_of_binary[1].size() - 1] =
'D';
970 b.a_list_of_bool = std::vector<bool>({
false,
true,
false});
971 b.a_list_of_i8 = std::vector<std::int8_t>({8, -8, 8});
972 b.a_list_of_i16 = std::vector<std::int16_t>({16, -16, 16});
973 b.a_list_of_i32 = std::vector<std::int32_t>({32, -32, 32});
974 b.a_list_of_i64 = std::vector<std::int64_t>({64, -64, 64});
975 b.a_list_of_double = std::vector<double>({0.64, -0.64, 0.64});
976 b.a_list_of_string = std::vector<std::string>({
"The string",
"A string",
"Another string"});
977 b.a_list_of_binary.resize(3);
978 b.a_list_of_binary[0].resize(12);
979 memset(b.a_list_of_binary[0].data(), 0, b.a_list_of_binary[0].size());
980 b.a_list_of_binary[0][b.a_list_of_binary[0].size() - 1] =
'E';
981 b.a_list_of_binary[1].resize(6);
982 memset(b.a_list_of_binary[1].data(), 0, b.a_list_of_binary[1].size());
983 b.a_list_of_binary[1][b.a_list_of_binary[1].size() - 1] =
'F';
984 b.a_list_of_binary[2].resize(12);
985 memset(b.a_list_of_binary[2].data(), 0, b.a_list_of_binary[2].size());
986 b.a_list_of_binary[2][b.a_list_of_binary[2].size() - 1] =
'G';
991 CHECK(b.a_list_of_bool.size() == a.a_list_of_bool.size());
992 CHECK(b.a_list_of_bool[0] == a.a_list_of_bool[0]);
993 CHECK(b.a_list_of_bool[1] == a.a_list_of_bool[1]);
994 CHECK(b.a_list_of_i8.size() == a.a_list_of_i8.size());
995 CHECK(b.a_list_of_i8[0] == a.a_list_of_i8[0]);
996 CHECK(b.a_list_of_i8[1] == a.a_list_of_i8[1]);
997 CHECK(b.a_list_of_i16.size() == a.a_list_of_i16.size());
998 CHECK(b.a_list_of_i16[0] == a.a_list_of_i16[0]);
999 CHECK(b.a_list_of_i16[1] == a.a_list_of_i16[1]);
1000 CHECK(b.a_list_of_i32.size() == a.a_list_of_i32.size());
1001 CHECK(b.a_list_of_i32[0] == a.a_list_of_i32[0]);
1002 CHECK(b.a_list_of_i32[1] == a.a_list_of_i32[1]);
1003 CHECK(b.a_list_of_i64.size() == a.a_list_of_i64.size());
1004 CHECK(b.a_list_of_i64[0] == a.a_list_of_i64[0]);
1005 CHECK(b.a_list_of_i64[1] == a.a_list_of_i64[1]);
1006 CHECK(b.a_list_of_double.size() == a.a_list_of_double.size());
1007 CHECK(b.a_list_of_double[0] == a.a_list_of_double[0]);
1008 CHECK(b.a_list_of_double[1] == a.a_list_of_double[1]);
1009 CHECK(b.a_list_of_string.size() == a.a_list_of_string.size());
1010 CHECK(b.a_list_of_string[0] == a.a_list_of_string[0]);
1011 CHECK(b.a_list_of_string[1] == a.a_list_of_string[1]);
1012 CHECK(b.a_list_of_binary.size() == a.a_list_of_binary.size());
1013 CHECK(b.a_list_of_binary[0].size() == 6);
1014 CHECK(b.a_list_of_binary[1].size() == 12);
1015 CHECK(b.a_list_of_binary[0][5] ==
'C');
1016 CHECK(b.a_list_of_binary[1][11] ==
'D');
1026 b.a_list_of_bool = std::vector<bool>({
true,
false});
1027 b.a_list_of_i8 = std::vector<std::int8_t>({-8, 8});
1028 b.a_list_of_i16 = std::vector<std::int16_t>({-16, 16});
1029 b.a_list_of_i32 = std::vector<std::int32_t>({-32, 32});
1030 b.a_list_of_i64 = std::vector<std::int64_t>({-64, 64});
1031 b.a_list_of_double = std::vector<double>({-0.64, 0.64});
1032 b.a_list_of_string = std::vector<std::string>({
"A string",
"Another string"});
1033 b.a_list_of_binary.resize(2);
1034 b.a_list_of_binary[0].resize(6);
1035 memset(b.a_list_of_binary[0].data(), 0, b.a_list_of_binary[0].size());
1036 b.a_list_of_binary[0][b.a_list_of_binary[0].size() - 1] =
'C';
1037 b.a_list_of_binary[1].resize(12);
1038 memset(b.a_list_of_binary[1].data(), 0, b.a_list_of_binary[1].size());
1039 b.a_list_of_binary[1][b.a_list_of_binary[1].size() - 1] =
'D';
1044 CHECK(b.a_list_of_bool.empty());
1045 CHECK(b.a_list_of_i8.empty());
1046 CHECK(b.a_list_of_i16.empty());
1047 CHECK(b.a_list_of_i32.empty());
1048 CHECK(b.a_list_of_i64.empty());
1049 CHECK(b.a_list_of_double.empty());
1050 CHECK(b.a_list_of_string.empty());
1051 CHECK(b.a_list_of_binary.empty());
1054 SECTION(
"test annotated types")
1062 a.a_ui32 = 0xffffffff;
1063 a.a_ui64 = 0xffffffffffffffff;
1071 CHECK(a.a_vocab == b.a_vocab);
1072 CHECK(a.a_ui8 == b.a_ui8);
1073 CHECK(a.a_ui16 == b.a_ui16);
1074 CHECK(a.a_ui32 == b.a_ui32);
1075 CHECK(a.a_ui64 == b.a_ui64);
1076 CHECK(a.a_float32 == b.a_float32);
1077 CHECK(a.a_float64 == b.a_float64);
1082 Settings::Editor settings;
1097 CHECK(receiver.state().id == 5);
1099 settings.set_name(
"hello");
1100 CHECK(receiver.state().name ==
"hello");
1102 settings.start_editing();
1104 CHECK(receiver.state().id == 5);
1106 settings.set_name(
"world");
1107 CHECK(receiver.state().name ==
"hello");
1108 settings.stop_editing();
1109 CHECK(receiver.state().id == 6);
1110 CHECK(receiver.state().name ==
"world");
1114 cmd.
fromString(
"patch (set id 3) (set name frog)");
1117 CHECK(receiver.state().id == 3);
1118 CHECK(receiver.state().name ==
"frog");
1123 CHECK(receiver.state().id == 9);
1125 cmd.
fromString(
"set id 99 name \"Space Monkey\"");
1128 CHECK(receiver.state().id == 99);
1129 CHECK(receiver.state().name ==
"Space Monkey");
1131 cmd.
fromString(
"set id 99 name \"Space Monkey\" id 101");
1134 CHECK(receiver.state().id == 101);
1150 INFO(
"Starting a long operation");
1151 client.do_start_a_service();
1153 INFO(
"Stopping a long operation");
1154 client.do_stop_a_service();
1170 INFO(
"Requesting a map type");
1196 INFO(
"calling a const method");
1197 CHECK(
const_cast<const Demo&
>(client).this_is_a_const_method());