test_macros.h 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474
  1. /**************************************************************************/
  2. /* test_macros.h */
  3. /**************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* https://godotengine.org */
  7. /**************************************************************************/
  8. /* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
  9. /* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
  10. /* */
  11. /* Permission is hereby granted, free of charge, to any person obtaining */
  12. /* a copy of this software and associated documentation files (the */
  13. /* "Software"), to deal in the Software without restriction, including */
  14. /* without limitation the rights to use, copy, modify, merge, publish, */
  15. /* distribute, sublicense, and/or sell copies of the Software, and to */
  16. /* permit persons to whom the Software is furnished to do so, subject to */
  17. /* the following conditions: */
  18. /* */
  19. /* The above copyright notice and this permission notice shall be */
  20. /* included in all copies or substantial portions of the Software. */
  21. /* */
  22. /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
  23. /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
  24. /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
  25. /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
  26. /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
  27. /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
  28. /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
  29. /**************************************************************************/
  30. #pragma once
  31. #include "display_server_mock.h"
  32. #include "core/core_globals.h"
  33. #include "core/input/input_map.h"
  34. #include "core/object/message_queue.h"
  35. #include "core/variant/variant.h"
  36. // See documentation for doctest at:
  37. // https://github.com/onqtam/doctest/blob/master/doc/markdown/readme.md#reference
  38. #include "thirdparty/doctest/doctest.h"
  39. // The test is skipped with this, run pending tests with `--test --no-skip`.
  40. #define TEST_CASE_PENDING(name) TEST_CASE(name *doctest::skip())
  41. // The test case is marked as failed, but does not fail the entire test run.
  42. #define TEST_CASE_MAY_FAIL(name) TEST_CASE(name *doctest::may_fail())
  43. // Provide aliases to conform with Godot naming conventions (see error macros).
  44. #define TEST_COND(cond, ...) DOCTEST_CHECK_FALSE_MESSAGE(cond, __VA_ARGS__)
  45. #define TEST_FAIL(cond, ...) DOCTEST_FAIL(cond, __VA_ARGS__)
  46. #define TEST_FAIL_COND(cond, ...) DOCTEST_REQUIRE_FALSE_MESSAGE(cond, __VA_ARGS__)
  47. #define TEST_FAIL_COND_WARN(cond, ...) DOCTEST_WARN_FALSE_MESSAGE(cond, __VA_ARGS__)
  48. // Temporarily disable error prints to test failure paths.
  49. // This allows to avoid polluting the test summary with error messages.
  50. // The `print_error_enabled` boolean is defined in `core/core_globals.cpp` and
  51. // works at global scope. It's used by various loggers in `should_log()` method,
  52. // which are used by error macros which call into `OS::print_error`, effectively
  53. // disabling any error messages to be printed from the engine side (not tests).
  54. #define ERR_PRINT_OFF CoreGlobals::print_error_enabled = false;
  55. #define ERR_PRINT_ON CoreGlobals::print_error_enabled = true;
  56. // Stringify all `Variant` compatible types for doctest output by default.
  57. // https://github.com/onqtam/doctest/blob/master/doc/markdown/stringification.md
  58. #define DOCTEST_STRINGIFY_VARIANT(m_type) \
  59. template <> \
  60. struct doctest::StringMaker<m_type> { \
  61. static doctest::String convert(const m_type &p_val) { \
  62. const Variant val = p_val; \
  63. return val.operator ::String().utf8().get_data(); \
  64. } \
  65. };
  66. #define DOCTEST_STRINGIFY_VARIANT_POINTER(m_type) \
  67. template <> \
  68. struct doctest::StringMaker<m_type> { \
  69. static doctest::String convert(const m_type *p_val) { \
  70. const Variant val = p_val; \
  71. return val.operator ::String().utf8().get_data(); \
  72. } \
  73. };
  74. DOCTEST_STRINGIFY_VARIANT(Variant);
  75. DOCTEST_STRINGIFY_VARIANT(::String); // Disambiguate from `doctest::String`.
  76. DOCTEST_STRINGIFY_VARIANT(Vector2);
  77. DOCTEST_STRINGIFY_VARIANT(Vector2i);
  78. DOCTEST_STRINGIFY_VARIANT(Rect2);
  79. DOCTEST_STRINGIFY_VARIANT(Rect2i);
  80. DOCTEST_STRINGIFY_VARIANT(Vector3);
  81. DOCTEST_STRINGIFY_VARIANT(Vector3i);
  82. DOCTEST_STRINGIFY_VARIANT(Vector4);
  83. DOCTEST_STRINGIFY_VARIANT(Vector4i);
  84. DOCTEST_STRINGIFY_VARIANT(Transform2D);
  85. DOCTEST_STRINGIFY_VARIANT(Plane);
  86. DOCTEST_STRINGIFY_VARIANT(Projection);
  87. DOCTEST_STRINGIFY_VARIANT(Quaternion);
  88. DOCTEST_STRINGIFY_VARIANT(AABB);
  89. DOCTEST_STRINGIFY_VARIANT(Basis);
  90. DOCTEST_STRINGIFY_VARIANT(Transform3D);
  91. DOCTEST_STRINGIFY_VARIANT(::Color); // Disambiguate from `doctest::Color`.
  92. DOCTEST_STRINGIFY_VARIANT(StringName);
  93. DOCTEST_STRINGIFY_VARIANT(NodePath);
  94. DOCTEST_STRINGIFY_VARIANT(RID);
  95. DOCTEST_STRINGIFY_VARIANT_POINTER(Object);
  96. DOCTEST_STRINGIFY_VARIANT(Callable);
  97. DOCTEST_STRINGIFY_VARIANT(Signal);
  98. DOCTEST_STRINGIFY_VARIANT(Dictionary);
  99. DOCTEST_STRINGIFY_VARIANT(Array);
  100. DOCTEST_STRINGIFY_VARIANT(PackedByteArray);
  101. DOCTEST_STRINGIFY_VARIANT(PackedInt32Array);
  102. DOCTEST_STRINGIFY_VARIANT(PackedInt64Array);
  103. DOCTEST_STRINGIFY_VARIANT(PackedFloat32Array);
  104. DOCTEST_STRINGIFY_VARIANT(PackedFloat64Array);
  105. DOCTEST_STRINGIFY_VARIANT(PackedStringArray);
  106. DOCTEST_STRINGIFY_VARIANT(PackedVector2Array);
  107. DOCTEST_STRINGIFY_VARIANT(PackedVector3Array);
  108. DOCTEST_STRINGIFY_VARIANT(PackedColorArray);
  109. DOCTEST_STRINGIFY_VARIANT(PackedVector4Array);
  110. // Register test commands to be launched from the command-line.
  111. // For instance: REGISTER_TEST_COMMAND("gdscript-parser" &test_parser_func).
  112. // Example usage: `godot --test gdscript-parser`.
  113. typedef void (*TestFunc)();
  114. extern HashMap<String, TestFunc> *test_commands;
  115. int register_test_command(String p_command, TestFunc p_function);
  116. #define REGISTER_TEST_COMMAND(m_command, m_function) \
  117. DOCTEST_GLOBAL_NO_WARNINGS(DOCTEST_ANONYMOUS(DOCTEST_ANON_VAR_), \
  118. register_test_command(m_command, m_function))
  119. // Utility macros to send an event actions to a given object
  120. // Requires Message Queue and InputMap to be setup.
  121. // SEND_GUI_ACTION - takes an input map key. e.g SEND_GUI_ACTION("ui_text_newline").
  122. // SEND_GUI_KEY_EVENT - takes a keycode set. e.g SEND_GUI_KEY_EVENT(Key::A | KeyModifierMask::META).
  123. // SEND_GUI_KEY_UP_EVENT - takes a keycode set. e.g SEND_GUI_KEY_UP_EVENT(Key::A | KeyModifierMask::META).
  124. // SEND_GUI_MOUSE_BUTTON_EVENT - takes a position, mouse button, mouse mask and modifiers e.g SEND_GUI_MOUSE_BUTTON_EVENT(Vector2(50, 50), MOUSE_BUTTON_NONE, MOUSE_BUTTON_NONE, Key::None);
  125. // SEND_GUI_MOUSE_BUTTON_RELEASED_EVENT - takes a position, mouse button, mouse mask and modifiers e.g SEND_GUI_MOUSE_BUTTON_RELEASED_EVENT(Vector2(50, 50), MOUSE_BUTTON_NONE, MOUSE_BUTTON_NONE, Key::None);
  126. // SEND_GUI_MOUSE_MOTION_EVENT - takes a position, mouse mask and modifiers e.g SEND_GUI_MOUSE_MOTION_EVENT(Vector2(50, 50), MouseButtonMask::LEFT, KeyModifierMask::META);
  127. // SEND_GUI_DOUBLE_CLICK - takes a position and modifiers. e.g SEND_GUI_DOUBLE_CLICK(Vector2(50, 50), KeyModifierMask::META);
  128. #define _SEND_DISPLAYSERVER_EVENT(m_event) ((DisplayServerMock *)(DisplayServer::get_singleton()))->simulate_event(m_event);
  129. #define SEND_GUI_ACTION(m_action) \
  130. { \
  131. const List<Ref<InputEvent>> *events = InputMap::get_singleton()->action_get_events(m_action); \
  132. const List<Ref<InputEvent>>::Element *first_event = events->front(); \
  133. Ref<InputEventKey> event = first_event->get()->duplicate(); \
  134. event->set_pressed(true); \
  135. _SEND_DISPLAYSERVER_EVENT(event); \
  136. MessageQueue::get_singleton()->flush(); \
  137. }
  138. #define SEND_GUI_KEY_EVENT(m_input) \
  139. { \
  140. Ref<InputEventKey> event = InputEventKey::create_reference(m_input); \
  141. event->set_pressed(true); \
  142. _SEND_DISPLAYSERVER_EVENT(event); \
  143. MessageQueue::get_singleton()->flush(); \
  144. }
  145. #define SEND_GUI_KEY_UP_EVENT(m_input) \
  146. { \
  147. Ref<InputEventKey> event = InputEventKey::create_reference(m_input); \
  148. event->set_pressed(false); \
  149. _SEND_DISPLAYSERVER_EVENT(event); \
  150. MessageQueue::get_singleton()->flush(); \
  151. }
  152. #define _UPDATE_EVENT_MODIFIERS(m_event, m_modifiers) \
  153. m_event->set_shift_pressed(((m_modifiers) & KeyModifierMask::SHIFT) != Key::NONE); \
  154. m_event->set_alt_pressed(((m_modifiers) & KeyModifierMask::ALT) != Key::NONE); \
  155. m_event->set_ctrl_pressed(((m_modifiers) & KeyModifierMask::CTRL) != Key::NONE); \
  156. m_event->set_meta_pressed(((m_modifiers) & KeyModifierMask::META) != Key::NONE);
  157. #define _CREATE_GUI_MOUSE_EVENT(m_screen_pos, m_input, m_mask, m_modifiers) \
  158. Ref<InputEventMouseButton> event; \
  159. event.instantiate(); \
  160. event->set_position(m_screen_pos); \
  161. event->set_button_index(m_input); \
  162. event->set_button_mask(m_mask); \
  163. event->set_factor(1); \
  164. _UPDATE_EVENT_MODIFIERS(event, m_modifiers); \
  165. event->set_pressed(true);
  166. #define _CREATE_GUI_TOUCH_EVENT(m_screen_pos, m_pressed, m_double) \
  167. Ref<InputEventScreenTouch> event; \
  168. event.instantiate(); \
  169. event->set_position(m_screen_pos); \
  170. event->set_pressed(m_pressed); \
  171. event->set_double_tap(m_double);
  172. #define SEND_GUI_MOUSE_BUTTON_EVENT(m_screen_pos, m_input, m_mask, m_modifiers) \
  173. { \
  174. _CREATE_GUI_MOUSE_EVENT(m_screen_pos, m_input, m_mask, m_modifiers); \
  175. _SEND_DISPLAYSERVER_EVENT(event); \
  176. MessageQueue::get_singleton()->flush(); \
  177. }
  178. #define SEND_GUI_MOUSE_BUTTON_RELEASED_EVENT(m_screen_pos, m_input, m_mask, m_modifiers) \
  179. { \
  180. _CREATE_GUI_MOUSE_EVENT(m_screen_pos, m_input, m_mask, m_modifiers); \
  181. event->set_pressed(false); \
  182. _SEND_DISPLAYSERVER_EVENT(event); \
  183. MessageQueue::get_singleton()->flush(); \
  184. }
  185. #define SEND_GUI_DOUBLE_CLICK(m_screen_pos, m_modifiers) \
  186. { \
  187. _CREATE_GUI_MOUSE_EVENT(m_screen_pos, MouseButton::LEFT, MouseButtonMask::NONE, m_modifiers); \
  188. event->set_double_click(true); \
  189. _SEND_DISPLAYSERVER_EVENT(event); \
  190. MessageQueue::get_singleton()->flush(); \
  191. }
  192. // We toggle _print_error_enabled to prevent display server not supported warnings.
  193. #define SEND_GUI_MOUSE_MOTION_EVENT(m_screen_pos, m_mask, m_modifiers) \
  194. { \
  195. bool errors_enabled = CoreGlobals::print_error_enabled; \
  196. CoreGlobals::print_error_enabled = false; \
  197. Ref<InputEventMouseMotion> event; \
  198. event.instantiate(); \
  199. event->set_position(m_screen_pos); \
  200. event->set_button_mask(m_mask); \
  201. _UPDATE_EVENT_MODIFIERS(event, m_modifiers); \
  202. _SEND_DISPLAYSERVER_EVENT(event); \
  203. MessageQueue::get_singleton()->flush(); \
  204. CoreGlobals::print_error_enabled = errors_enabled; \
  205. }
  206. #define SEND_GUI_TOUCH_EVENT(m_screen_pos, m_pressed, m_double) \
  207. { \
  208. _CREATE_GUI_TOUCH_EVENT(m_screen_pos, m_pressed, m_double) \
  209. _SEND_DISPLAYSERVER_EVENT(event); \
  210. MessageQueue::get_singleton()->flush(); \
  211. }
  212. // Utility class / macros for testing signals
  213. //
  214. // Use SIGNAL_WATCH(*object, "signal_name") to start watching
  215. // Makes sure to call SIGNAL_UNWATCH(*object, "signal_name") to stop watching in cleanup, this is not done automatically.
  216. //
  217. // The SignalWatcher will capture all signals and their args sent between checks.
  218. //
  219. // Use SIGNAL_CHECK("signal_name"), Vector<Vector<Variant>>), to check the arguments of all fired signals.
  220. // The outer vector is each fired signal, the inner vector the list of arguments for that signal. Order does matter.
  221. //
  222. // Use SIGNAL_CHECK_FALSE("signal_name") to check if a signal was not fired.
  223. //
  224. // Use SIGNAL_DISCARD("signal_name") to discard records all of the given signal, use only in placed you don't need to check.
  225. //
  226. // All signals are automatically discarded between test/sub test cases.
  227. class SignalWatcher : public Object {
  228. private:
  229. inline static SignalWatcher *singleton;
  230. /* Equal to: RBMap<String, Vector<Vector<Variant>>> */
  231. HashMap<String, Array> _signals;
  232. void _add_signal_entry(const Array &p_args, const String &p_name) {
  233. if (!_signals.has(p_name)) {
  234. _signals[p_name] = Array();
  235. }
  236. _signals[p_name].push_back(p_args);
  237. }
  238. void _signal_callback_zero(const String &p_name) {
  239. Array args;
  240. _add_signal_entry(args, p_name);
  241. }
  242. void _signal_callback_one(Variant p_arg1, const String &p_name) {
  243. Array args = { p_arg1 };
  244. _add_signal_entry(args, p_name);
  245. }
  246. void _signal_callback_two(Variant p_arg1, Variant p_arg2, const String &p_name) {
  247. Array args = { p_arg1, p_arg2 };
  248. _add_signal_entry(args, p_name);
  249. }
  250. void _signal_callback_three(Variant p_arg1, Variant p_arg2, Variant p_arg3, const String &p_name) {
  251. Array args = { p_arg1, p_arg2, p_arg3 };
  252. _add_signal_entry(args, p_name);
  253. }
  254. public:
  255. static SignalWatcher *get_singleton() { return singleton; }
  256. void watch_signal(Object *p_object, const String &p_signal) {
  257. MethodInfo method_info;
  258. ClassDB::get_signal(p_object->get_class(), p_signal, &method_info);
  259. switch (method_info.arguments.size()) {
  260. case 0: {
  261. p_object->connect(p_signal, callable_mp(this, &SignalWatcher::_signal_callback_zero).bind(p_signal));
  262. } break;
  263. case 1: {
  264. p_object->connect(p_signal, callable_mp(this, &SignalWatcher::_signal_callback_one).bind(p_signal));
  265. } break;
  266. case 2: {
  267. p_object->connect(p_signal, callable_mp(this, &SignalWatcher::_signal_callback_two).bind(p_signal));
  268. } break;
  269. case 3: {
  270. p_object->connect(p_signal, callable_mp(this, &SignalWatcher::_signal_callback_three).bind(p_signal));
  271. } break;
  272. default: {
  273. MESSAGE("Signal ", p_signal, " arg count not supported.");
  274. } break;
  275. }
  276. }
  277. void unwatch_signal(Object *p_object, const String &p_signal) {
  278. MethodInfo method_info;
  279. ClassDB::get_signal(p_object->get_class(), p_signal, &method_info);
  280. switch (method_info.arguments.size()) {
  281. case 0: {
  282. p_object->disconnect(p_signal, callable_mp(this, &SignalWatcher::_signal_callback_zero));
  283. } break;
  284. case 1: {
  285. p_object->disconnect(p_signal, callable_mp(this, &SignalWatcher::_signal_callback_one));
  286. } break;
  287. case 2: {
  288. p_object->disconnect(p_signal, callable_mp(this, &SignalWatcher::_signal_callback_two));
  289. } break;
  290. case 3: {
  291. p_object->disconnect(p_signal, callable_mp(this, &SignalWatcher::_signal_callback_three));
  292. } break;
  293. default: {
  294. MESSAGE("Signal ", p_signal, " arg count not supported.");
  295. } break;
  296. }
  297. }
  298. bool check(const String &p_name, const Array &p_args) {
  299. if (!_signals.has(p_name)) {
  300. MESSAGE("Signal ", p_name, " not emitted");
  301. return false;
  302. }
  303. if (p_args.size() != _signals[p_name].size()) {
  304. MESSAGE("Signal has " << _signals[p_name] << " expected " << p_args);
  305. discard_signal(p_name);
  306. return false;
  307. }
  308. bool match = true;
  309. for (int i = 0; i < p_args.size(); i++) {
  310. if (((Array)p_args[i]).size() != ((Array)_signals[p_name][i]).size()) {
  311. MESSAGE("Signal has " << _signals[p_name][i] << " expected " << p_args[i]);
  312. match = false;
  313. continue;
  314. }
  315. for (int j = 0; j < ((Array)p_args[i]).size(); j++) {
  316. if (((Array)p_args[i])[j] != ((Array)_signals[p_name][i])[j]) {
  317. MESSAGE("Signal has " << _signals[p_name][i] << " expected " << p_args[i]);
  318. match = false;
  319. break;
  320. }
  321. }
  322. }
  323. discard_signal(p_name);
  324. return match;
  325. }
  326. bool check_false(const String &p_name) {
  327. bool has = _signals.has(p_name);
  328. if (has) {
  329. MESSAGE("Signal has " << _signals[p_name] << " expected none.");
  330. }
  331. discard_signal(p_name);
  332. return !has;
  333. }
  334. void discard_signal(const String &p_name) {
  335. if (_signals.has(p_name)) {
  336. _signals.erase(p_name);
  337. }
  338. }
  339. void _clear_signals() {
  340. _signals.clear();
  341. }
  342. SignalWatcher() {
  343. singleton = this;
  344. }
  345. ~SignalWatcher() {
  346. singleton = nullptr;
  347. }
  348. };
  349. #define SIGNAL_WATCH(m_object, m_signal) SignalWatcher::get_singleton()->watch_signal(m_object, m_signal);
  350. #define SIGNAL_UNWATCH(m_object, m_signal) SignalWatcher::get_singleton()->unwatch_signal(m_object, m_signal);
  351. #define SIGNAL_CHECK(m_signal, m_args) CHECK(SignalWatcher::get_singleton()->check(m_signal, m_args));
  352. #define SIGNAL_CHECK_FALSE(m_signal) CHECK(SignalWatcher::get_singleton()->check_false(m_signal));
  353. #define SIGNAL_DISCARD(m_signal) SignalWatcher::get_singleton()->discard_signal(m_signal);
  354. #define MULTICHECK_STRING_EQ(m_obj, m_func, m_param1, m_eq) \
  355. CHECK(m_obj.m_func(m_param1) == m_eq); \
  356. CHECK(m_obj.m_func(U##m_param1) == m_eq); \
  357. CHECK(m_obj.m_func(L##m_param1) == m_eq); \
  358. CHECK(m_obj.m_func(String(m_param1)) == m_eq);
  359. #define MULTICHECK_STRING_INT_EQ(m_obj, m_func, m_param1, m_param2, m_eq) \
  360. CHECK(m_obj.m_func(m_param1, m_param2) == m_eq); \
  361. CHECK(m_obj.m_func(U##m_param1, m_param2) == m_eq); \
  362. CHECK(m_obj.m_func(L##m_param1, m_param2) == m_eq); \
  363. CHECK(m_obj.m_func(String(m_param1), m_param2) == m_eq);
  364. #define MULTICHECK_STRING_INT_INT_EQ(m_obj, m_func, m_param1, m_param2, m_param3, m_eq) \
  365. CHECK(m_obj.m_func(m_param1, m_param2, m_param3) == m_eq); \
  366. CHECK(m_obj.m_func(U##m_param1, m_param2, m_param3) == m_eq); \
  367. CHECK(m_obj.m_func(L##m_param1, m_param2, m_param3) == m_eq); \
  368. CHECK(m_obj.m_func(String(m_param1), m_param2, m_param3) == m_eq);
  369. #define MULTICHECK_STRING_STRING_EQ(m_obj, m_func, m_param1, m_param2, m_eq) \
  370. CHECK(m_obj.m_func(m_param1, m_param2) == m_eq); \
  371. CHECK(m_obj.m_func(U##m_param1, U##m_param2) == m_eq); \
  372. CHECK(m_obj.m_func(L##m_param1, L##m_param2) == m_eq); \
  373. CHECK(m_obj.m_func(String(m_param1), String(m_param2)) == m_eq);
  374. #define MULTICHECK_GET_SLICE(m_obj, m_param1, m_slices) \
  375. for (int i = 0; i < m_obj.get_slice_count(m_param1); ++i) { \
  376. CHECK(m_obj.get_slice(m_param1, i) == m_slices[i]); \
  377. } \
  378. for (int i = 0; i < m_obj.get_slice_count(U##m_param1); ++i) { \
  379. CHECK(m_obj.get_slice(U##m_param1, i) == m_slices[i]); \
  380. } \
  381. for (int i = 0; i < m_obj.get_slice_count(L##m_param1); ++i) { \
  382. CHECK(m_obj.get_slice(L##m_param1, i) == m_slices[i]); \
  383. } \
  384. for (int i = 0; i < m_obj.get_slice_count(String(m_param1)); ++i) { \
  385. CHECK(m_obj.get_slice(String(m_param1), i) == m_slices[i]); \
  386. }
  387. #define MULTICHECK_SPLIT(m_obj, m_func, m_param1, m_param2, m_param3, m_slices, m_expected_size) \
  388. do { \
  389. Vector<String> string_list; \
  390. \
  391. string_list = m_obj.m_func(m_param1, m_param2, m_param3); \
  392. CHECK(m_expected_size == string_list.size()); \
  393. for (int i = 0; i < string_list.size(); ++i) { \
  394. CHECK(string_list[i] == m_slices[i]); \
  395. } \
  396. \
  397. string_list = m_obj.m_func(U##m_param1, m_param2, m_param3); \
  398. CHECK(m_expected_size == string_list.size()); \
  399. for (int i = 0; i < string_list.size(); ++i) { \
  400. CHECK(string_list[i] == m_slices[i]); \
  401. } \
  402. \
  403. string_list = m_obj.m_func(L##m_param1, m_param2, m_param3); \
  404. CHECK(m_expected_size == string_list.size()); \
  405. for (int i = 0; i < string_list.size(); ++i) { \
  406. CHECK(string_list[i] == m_slices[i]); \
  407. } \
  408. \
  409. string_list = m_obj.m_func(String(m_param1), m_param2, m_param3); \
  410. CHECK(m_expected_size == string_list.size()); \
  411. for (int i = 0; i < string_list.size(); ++i) { \
  412. CHECK(string_list[i] == m_slices[i]); \
  413. } \
  414. } while (false)