1 /* Copyright (c) 2010-2014 Samsung Electronics Co., Ltd. All rights reserved.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 #include "maps_route_test.h"
18 #include "maps_route_plugin.h"
19 #include "maps_route_segment_plugin.h"
20 #include "maps_error.h"
22 #include "maps_route_private.h"
23 #include "maps_util.h"
25 /* int maps_route_create(maps_route_h* route); */
26 /* int maps_route_destroy(maps_route_h route); */
27 void utc_maps_route_create_p(void)
29 maps_route_h route = NULL;
30 int error = maps_route_create(&route);
31 g_assert_cmpint(error, ==, MAPS_ERROR_NONE);
34 error = maps_route_destroy(route);
35 g_assert_cmpint(error, ==, MAPS_ERROR_NONE);
38 void utc_maps_route_create_n(void)
40 int error = maps_route_create(NULL);
41 g_assert_cmpint(error, ==, MAPS_ERROR_INVALID_PARAMETER);
43 error = maps_route_destroy(NULL);
44 g_assert_cmpint(error, ==, MAPS_ERROR_INVALID_PARAMETER);
47 /*----------------------------------------------------------------------------*/
48 static int __utc_put_to_hashtable(const char* feature_str,
49 maps_string_hashtable_h t)
51 if (!feature_str || !t)
52 return MAPS_ERROR_INVALID_PARAMETER;
53 return maps_string_hashtable_set(t, feature_str, feature_str);
62 test_env():h(NULL), iterations(0)
64 const int error = maps_route_create(&h);
65 g_assert_cmpint(error, ==, MAPS_ERROR_NONE);
68 maps_string_hashtable_h data_supported = NULL;
69 if (maps_string_hashtable_create(&data_supported) !=
73 __utc_put_to_hashtable(_S(MAPS_ROUTE_PATH), data_supported);
74 __utc_put_to_hashtable(_S(MAPS_ROUTE_SEGMENTS_PATH),
76 __utc_put_to_hashtable(_S(MAPS_ROUTE_SEGMENTS_MANEUVERS),
79 _maps_route_set_supported_data(h, data_supported);
80 maps_string_hashtable_destroy(data_supported);
85 const int error = maps_route_destroy(h);
86 g_assert_cmpint(error, ==, MAPS_ERROR_NONE);
90 /*----------------------------------------------------------------------------*/
92 /* int maps_route_clone(const maps_route_h origin, maps_route_h* cloned); */
93 void utc_maps_route_clone_p(void)
97 maps_route_h cloned = NULL;
98 int error = maps_route_clone(e.h, &cloned);
99 g_assert_cmpint(error, ==, MAPS_ERROR_NONE);
102 /* TODO: add checking of other fields */
104 error = maps_route_destroy(cloned);
105 g_assert_cmpint(error, ==, MAPS_ERROR_NONE);
108 void utc_maps_route_clone_n(void)
112 maps_route_h cloned = NULL;
113 int error = maps_route_clone(e.h, NULL);
114 g_assert_cmpint(error, ==, MAPS_ERROR_INVALID_PARAMETER);
116 error = maps_route_clone(NULL, &cloned);
117 g_assert_cmpint(error, ==, MAPS_ERROR_INVALID_PARAMETER);
120 /* int maps_route_set_route_id(maps_route_h route, const char* route_id); */
121 /* int maps_route_get_route_id(const maps_route_h route, char** route_id); */
122 void utc_maps_route_route_id_p(void)
126 int error = maps_route_set_route_id(e.h, "test_string");
127 g_assert_cmpint(error, ==, MAPS_ERROR_NONE);
130 error = maps_route_get_route_id(e.h, &ret);
131 g_assert_cmpint(error, ==, MAPS_ERROR_NONE);
132 g_assert_cmpstr(ret, ==, "test_string");
136 void utc_maps_route_route_id_n(void)
140 int error = maps_route_set_route_id(NULL, "test_string");
141 g_assert_cmpint(error, ==, MAPS_ERROR_INVALID_PARAMETER);
143 error = maps_route_set_route_id(e.h, NULL);
144 g_assert_cmpint(error, ==, MAPS_ERROR_INVALID_PARAMETER);
147 error = maps_route_get_route_id(NULL, &ret);
148 g_assert_cmpint(error, ==, MAPS_ERROR_INVALID_PARAMETER);
150 error = maps_route_get_route_id(e.h, NULL);
151 g_assert_cmpint(error, ==, MAPS_ERROR_INVALID_PARAMETER);
154 /* int maps_route_set_origin(maps_route_h route, maps_coordinates_h origin); */
155 /* int maps_route_get_origin(maps_route_h route, maps_coordinates_h* origin); */
156 void utc_maps_route_origin_p(void)
160 maps_coordinates_h coords = NULL;
161 int error = maps_coordinates_create(11.1, 22.2,
166 g_assert_cmpint(error, ==, MAPS_ERROR_NONE);
168 /* start test ------------------------------------------------------- */
169 error = maps_route_set_origin(e.h, coords);
170 g_assert_cmpint(error, ==, MAPS_ERROR_NONE);
172 maps_coordinates_h obtained_coords = NULL;
173 error = maps_route_get_origin(e.h, &obtained_coords);
174 g_assert_cmpint(error, ==, MAPS_ERROR_NONE);
175 g_assert(obtained_coords);
176 maps_coordinates_destroy(obtained_coords);
177 /* finish test ------------------------------------------------------ */
179 error = maps_coordinates_destroy(coords);
180 g_assert_cmpint(error, ==, MAPS_ERROR_NONE);
183 void utc_maps_route_origin_n(void)
187 maps_coordinates_h coords = NULL;
188 int error = maps_coordinates_create(11.1, 22.2,
193 g_assert_cmpint(error, ==, MAPS_ERROR_NONE);
195 /* start test ------------------------------------------------------- */
196 error = maps_route_set_origin(NULL, coords);
197 g_assert_cmpint(error, ==, MAPS_ERROR_INVALID_PARAMETER);
199 error = maps_route_set_origin(e.h, NULL);
200 g_assert_cmpint(error, ==, MAPS_ERROR_INVALID_PARAMETER);
202 maps_coordinates_h obtained_coords = NULL;
203 error = maps_route_get_origin(NULL, &obtained_coords);
204 g_assert_cmpint(error, ==, MAPS_ERROR_INVALID_PARAMETER);
206 error = maps_route_get_origin(e.h, NULL);
207 g_assert_cmpint(error, ==, MAPS_ERROR_INVALID_PARAMETER);
208 /* finish test ------------------------------------------------------ */
210 error = maps_coordinates_destroy(coords);
211 g_assert_cmpint(error, ==, MAPS_ERROR_NONE);
214 /* int maps_route_set_destination(maps_route_h route,
215 * maps_coordinates_h destination); */
216 /* int maps_route_get_destination(maps_route_h route,
217 * maps_coordinates_h* destination); */
218 void utc_maps_route_destination_p(void)
222 maps_coordinates_h coords = NULL;
223 int error = maps_coordinates_create(11.1, 22.2,
228 g_assert_cmpint(error, ==, MAPS_ERROR_NONE);
230 /* start test ------------------------------------------------------- */
231 error = maps_route_set_destination(e.h, coords);
232 g_assert_cmpint(error, ==, MAPS_ERROR_NONE);
234 maps_coordinates_h obtained_coords = NULL;
235 error = maps_route_get_destination(e.h, &obtained_coords);
236 g_assert_cmpint(error, ==, MAPS_ERROR_NONE);
237 g_assert(obtained_coords);
238 maps_coordinates_destroy(obtained_coords);
239 /* finish test ------------------------------------------------------ */
241 error = maps_coordinates_destroy(coords);
242 g_assert_cmpint(error, ==, MAPS_ERROR_NONE);
245 void utc_maps_route_destination_n(void)
249 maps_coordinates_h coords = NULL;
250 int error = maps_coordinates_create(11.1, 22.2,
255 g_assert_cmpint(error, ==, MAPS_ERROR_NONE);
257 /* start test ------------------------------------------------------- */
258 error = maps_route_set_destination(NULL, coords);
259 g_assert_cmpint(error, ==, MAPS_ERROR_INVALID_PARAMETER);
261 error = maps_route_set_destination(e.h, NULL);
262 g_assert_cmpint(error, ==, MAPS_ERROR_INVALID_PARAMETER);
264 maps_coordinates_h obtained_coords = NULL;
265 error = maps_route_get_destination(NULL, &obtained_coords);
266 g_assert_cmpint(error, ==, MAPS_ERROR_INVALID_PARAMETER);
268 error = maps_route_get_destination(e.h, NULL);
269 g_assert_cmpint(error, ==, MAPS_ERROR_INVALID_PARAMETER);
270 /* finish test ------------------------------------------------------ */
272 error = maps_coordinates_destroy(coords);
273 g_assert_cmpint(error, ==, MAPS_ERROR_NONE);
276 /* int maps_route_set_bounding_box(maps_route_h route,
277 * maps_area_h bounding_box); */
278 /* int maps_route_get_bounding_box(maps_route_h route,
279 * maps_area_h* bounding_box); */
280 void utc_maps_route_bounding_box_p(void)
284 maps_coordinates_h coords = NULL;
285 int error = maps_coordinates_create(11.1, 22.2,
290 g_assert_cmpint(error, ==, MAPS_ERROR_NONE);
292 maps_area_h bounding_box = NULL;
293 error = maps_area_create_circle(coords, 123.4, &bounding_box);
294 g_assert_cmpint(error, ==, MAPS_ERROR_NONE);
296 /* start test ------------------------------------------------------- */
297 error = maps_route_set_bounding_box(e.h, bounding_box);
298 g_assert_cmpint(error, ==, MAPS_ERROR_NONE);
300 maps_coordinates_h obtained_bounding_box = NULL;
301 error = maps_route_get_bounding_box(e.h, &obtained_bounding_box);
302 g_assert_cmpint(error, ==, MAPS_ERROR_NONE);
303 g_assert(obtained_bounding_box);
304 maps_area_destroy(obtained_bounding_box);
305 /* finish test ------------------------------------------------------ */
307 error = maps_area_destroy(bounding_box);
308 g_assert_cmpint(error, ==, MAPS_ERROR_NONE);
310 error = maps_coordinates_destroy(coords);
311 g_assert_cmpint(error, ==, MAPS_ERROR_NONE);
314 void utc_maps_route_bounding_box_n(void)
318 maps_coordinates_h coords = NULL;
319 int error = maps_coordinates_create(11.1, 22.2,
324 g_assert_cmpint(error, ==, MAPS_ERROR_NONE);
326 maps_area_h bounding_box = NULL;
327 error = maps_area_create_circle(coords, 123.4, &bounding_box);
328 g_assert_cmpint(error, ==, MAPS_ERROR_NONE);
330 /* start test ------------------------------------------------------- */
331 error = maps_route_set_bounding_box(NULL, bounding_box);
332 g_assert_cmpint(error, ==, MAPS_ERROR_INVALID_PARAMETER);
334 error = maps_route_set_bounding_box(e.h, NULL);
335 g_assert_cmpint(error, ==, MAPS_ERROR_INVALID_PARAMETER);
337 maps_coordinates_h obtained_bounding_box = NULL;
338 error = maps_route_get_bounding_box(NULL, &obtained_bounding_box);
339 g_assert_cmpint(error, ==, MAPS_ERROR_INVALID_PARAMETER);
341 error = maps_route_get_bounding_box(e.h, NULL);
342 g_assert_cmpint(error, ==, MAPS_ERROR_INVALID_PARAMETER);
343 /* finish test ------------------------------------------------------ */
345 error = maps_area_destroy(bounding_box);
346 g_assert_cmpint(error, ==, MAPS_ERROR_NONE);
348 error = maps_coordinates_destroy(coords);
349 g_assert_cmpint(error, ==, MAPS_ERROR_NONE);
352 /* int maps_route_set_total_distance(maps_route_h route,
353 * double total_distance); */
354 /* int maps_route_get_total_distance(maps_route_h route,
355 * double* total_distance); */
356 void utc_maps_route_total_distance_p(void)
360 int error = maps_route_set_total_distance(e.h, 42.0);
361 g_assert_cmpint(error, ==, MAPS_ERROR_NONE);
364 error = maps_route_get_total_distance(e.h, &ret);
365 g_assert_cmpint(error, ==, MAPS_ERROR_NONE);
366 g_assert_cmpfloat(ret, ==, 42.0);
369 void utc_maps_route_total_distance_n(void)
373 int error = maps_route_set_total_distance(NULL, 42.0);
374 g_assert_cmpint(error, ==, MAPS_ERROR_INVALID_PARAMETER);
377 error = maps_route_get_total_distance(NULL, &ret);
378 g_assert_cmpint(error, ==, MAPS_ERROR_INVALID_PARAMETER);
380 error = maps_route_get_total_distance(e.h, NULL);
381 g_assert_cmpint(error, ==, MAPS_ERROR_INVALID_PARAMETER);
384 /* int maps_route_set_total_duration(maps_route_h route,
385 * long total_duration); */
386 /* int maps_route_get_total_duration(maps_route_h route,
387 * long* total_duration); */
388 void utc_maps_route_total_duration_p(void)
392 int error = maps_route_set_total_duration(e.h, 42);
393 g_assert_cmpint(error, ==, MAPS_ERROR_NONE);
396 error = maps_route_get_total_duration(e.h, &ret);
397 g_assert_cmpint(error, ==, MAPS_ERROR_NONE);
398 g_assert_cmpint(ret, ==, 42);
401 void utc_maps_route_total_duration_n(void)
405 int error = maps_route_set_total_duration(NULL, 42);
406 g_assert_cmpint(error, ==, MAPS_ERROR_INVALID_PARAMETER);
409 error = maps_route_get_total_duration(NULL, &ret);
410 g_assert_cmpint(error, ==, MAPS_ERROR_INVALID_PARAMETER);
412 error = maps_route_get_total_duration(e.h, NULL);
413 g_assert_cmpint(error, ==, MAPS_ERROR_INVALID_PARAMETER);
416 /* int maps_route_set_transport_mode(maps_route_h route,
417 * maps_route_transport_mode_e transport_mode); */
418 /* int maps_route_get_transport_mode(const maps_route_h route,
419 * maps_route_transport_mode_e* transport_mode); */
420 void utc_maps_route_transport_mode_p(void)
425 maps_route_set_transport_mode(e.h,
426 MAPS_ROUTE_TRANSPORT_MODE_CAR);
427 g_assert_cmpint(error, ==, MAPS_ERROR_NONE);
429 maps_route_transport_mode_e transport_mode =
430 MAPS_ROUTE_TRANSPORT_MODE_TRUCK;
431 error = maps_route_get_transport_mode(e.h, &transport_mode);
432 g_assert_cmpint(error, ==, MAPS_ERROR_NONE);
433 g_assert_cmpint(transport_mode, ==, MAPS_ROUTE_TRANSPORT_MODE_CAR);
436 void utc_maps_route_transport_mode_n(void)
441 maps_route_set_transport_mode(NULL,
442 MAPS_ROUTE_TRANSPORT_MODE_CAR);
443 g_assert_cmpint(error, ==, MAPS_ERROR_INVALID_PARAMETER);
445 maps_route_transport_mode_e transport_mode =
446 MAPS_ROUTE_TRANSPORT_MODE_TRUCK;
447 error = maps_route_get_transport_mode(NULL, &transport_mode);
448 g_assert_cmpint(error, ==, MAPS_ERROR_INVALID_PARAMETER);
450 error = maps_route_get_transport_mode(e.h, NULL);
451 g_assert_cmpint(error, ==, MAPS_ERROR_INVALID_PARAMETER);
454 /* int maps_route_get_distance_unit(const maps_route_h route,
455 * maps_distance_unit_e* distance_unit); */
456 /* int maps_route_set_distance_unit(const maps_route_h route,
457 * const maps_distance_unit_e distance_unit); */
458 void utc_maps_route_distance_unit_p(void)
462 int error = maps_route_set_distance_unit(e.h, MAPS_DISTANCE_UNIT_M);
463 g_assert_cmpint(error, ==, MAPS_ERROR_NONE);
465 maps_distance_unit_e ret = MAPS_DISTANCE_UNIT_YD;
466 error = maps_route_get_distance_unit(e.h, &ret);
467 g_assert_cmpint(error, ==, MAPS_ERROR_NONE);
468 g_assert_cmpint(ret, ==, MAPS_DISTANCE_UNIT_M);
471 void utc_maps_route_distance_unit_n(void)
475 int error = maps_route_set_distance_unit(NULL, MAPS_DISTANCE_UNIT_M);
476 g_assert_cmpint(error, ==, MAPS_ERROR_INVALID_PARAMETER);
478 maps_distance_unit_e ret = MAPS_DISTANCE_UNIT_YD;
479 error = maps_route_get_distance_unit(NULL, &ret);
480 g_assert_cmpint(error, ==, MAPS_ERROR_INVALID_PARAMETER);
482 error = maps_route_get_distance_unit(e.h, NULL);
483 g_assert_cmpint(error, ==, MAPS_ERROR_INVALID_PARAMETER);
486 /* typedef bool(*maps_route_properties_cb)(const char* key, const char* value,
487 * void* user_data); */
488 /* int maps_route_set_properties(maps_route_h route,
489 * maps_item_hashtable_h properties); */
490 /* int maps_route_foreach_property(maps_route_h route,
491 * maps_route_properties_cb callback, void* user_data); */
492 static bool __utc_maps_route_properties_cb(int index, int total, char* key,
493 void* value, void* user_data)
498 g_assert_cmpstr(key, ==, "key");
499 g_assert_cmpstr((const char*) value, ==, "value");
502 test_env* e = (test_env*) user_data;
512 void utc_maps_route_properties_p(void)
516 maps_item_list_h obj = NULL;
517 int error = maps_item_hashtable_create(&obj);
518 g_assert_cmpint(error, ==, MAPS_ERROR_NONE);
520 error = maps_item_hashtable_set(obj, "key", "value",
521 maps_item_hashtable_clone_string,
522 maps_item_hashtable_free_string);
523 g_assert_cmpint(error, ==, MAPS_ERROR_NONE);
525 /* start test ------------------------------------------------------- */
526 error = maps_route_set_properties(e.h, obj);
527 g_assert_cmpint(error, ==, MAPS_ERROR_NONE);
529 error = maps_route_foreach_property(e.h, __utc_maps_route_properties_cb,
531 g_assert_cmpint(error, ==, MAPS_ERROR_NONE);
532 g_assert_cmpint(e.iterations, ==, 1);
533 /* finish test ------------------------------------------------------ */
535 error = maps_item_hashtable_destroy(obj);
536 g_assert_cmpint(error, ==, MAPS_ERROR_NONE);
539 void utc_maps_route_properties_n(void)
543 maps_item_list_h obj = NULL;
544 int error = maps_item_hashtable_create(&obj);
545 g_assert_cmpint(error, ==, MAPS_ERROR_NONE);
547 /* start test ------------------------------------------------------- */
548 error = maps_route_set_properties(NULL, obj);
549 g_assert_cmpint(error, ==, MAPS_ERROR_INVALID_PARAMETER);
551 error = maps_route_set_properties(e.h, NULL);
552 g_assert_cmpint(error, ==, MAPS_ERROR_INVALID_PARAMETER);
554 error = maps_route_foreach_property(NULL,
555 __utc_maps_route_properties_cb, &e);
556 g_assert_cmpint(error, ==, MAPS_ERROR_INVALID_PARAMETER);
558 error = maps_route_foreach_property(e.h, NULL, NULL);
559 g_assert_cmpint(error, ==, MAPS_ERROR_INVALID_PARAMETER);
560 /* finish test ------------------------------------------------------ */
562 error = maps_item_hashtable_destroy(obj);
563 g_assert_cmpint(error, ==, MAPS_ERROR_NONE);
566 /* typedef bool(*maps_route_path_cb)(int index, int total,
567 * maps_coordinates_h coordinates, void* user_data); */
568 /* int maps_route_foreach_path(const maps_route_h route,
569 * maps_route_path_cb callback, void* user_data); */
570 /* int maps_route_set_path(maps_route_h route, const maps_item_list_h path); */
571 static bool __utc_maps_route_path_cb(int index, int total,
572 maps_coordinates_h coordinates, void* user_data)
574 test_env* e = (test_env*) user_data;
578 g_assert(coordinates);
580 g_assert_cmpint(index, >=, 0);
581 g_assert_cmpint(total, >=, 1);
583 maps_coordinates_destroy(coordinates);
588 void utc_maps_route_path_p(void)
592 maps_item_list_h path = NULL;
593 int error = maps_item_list_create(&path);
594 g_assert_cmpint(error, ==, MAPS_ERROR_NONE);
596 maps_coordinates_h obj = NULL;
597 error = maps_coordinates_create(11.1, 22.2, &obj);
598 g_assert_cmpint(error, ==, MAPS_ERROR_NONE);
600 error = maps_item_list_append(path, obj, maps_coordinates_clone);
601 g_assert_cmpint(error, ==, MAPS_ERROR_NONE);
602 maps_coordinates_destroy(obj);
604 /* test start --------------------------------- */
605 error = maps_route_set_path(e.h, path);
606 g_assert_cmpint(error, ==, MAPS_ERROR_NONE);
608 error = maps_route_foreach_path(e.h, __utc_maps_route_path_cb, &e);
609 g_assert_cmpint(error, ==, MAPS_ERROR_NONE);
610 g_assert_cmpint(e.iterations, ==, 1);
611 /* test finish --------------------------------- */
613 error = maps_item_list_remove_all(path, maps_coordinates_destroy);
614 g_assert_cmpint(error, ==, MAPS_ERROR_NONE);
616 error = maps_item_list_destroy(path);
617 g_assert_cmpint(error, ==, MAPS_ERROR_NONE);
620 void utc_maps_route_path_n(void)
624 maps_item_list_h path = NULL;
625 int error = maps_item_list_create(&path);
626 g_assert_cmpint(error, ==, MAPS_ERROR_NONE);
628 maps_coordinates_h obj = NULL;
629 error = maps_coordinates_create(11.1, 22.2, &obj);
631 error = maps_item_list_append(path, obj, maps_coordinates_clone);
632 g_assert_cmpint(error, ==, MAPS_ERROR_NONE);
633 maps_coordinates_destroy(obj);
635 /* test start --------------------------------- */
636 error = maps_route_set_path(NULL, path);
637 g_assert_cmpint(error, ==, MAPS_ERROR_INVALID_PARAMETER);
639 error = maps_route_set_path(e.h, NULL);
640 g_assert_cmpint(error, ==, MAPS_ERROR_INVALID_PARAMETER);
642 error = maps_route_foreach_path(NULL, __utc_maps_route_path_cb, &e);
643 g_assert_cmpint(error, ==, MAPS_ERROR_INVALID_PARAMETER);
644 g_assert_cmpint(e.iterations, ==, 0);
646 error = maps_route_foreach_path(e.h, NULL, &e);
647 g_assert_cmpint(error, ==, MAPS_ERROR_INVALID_PARAMETER);
648 g_assert_cmpint(e.iterations, ==, 0);
649 /* test finish --------------------------------- */
651 /*error = maps_coordinates_destroy(obj); */
652 /*g_assert_cmpint(error, ==, MAPS_ERROR_NONE); */
654 error = maps_item_list_remove_all(path, maps_coordinates_destroy);
655 g_assert_cmpint(error, ==, MAPS_ERROR_NONE);
657 error = maps_item_list_destroy(path);
658 g_assert_cmpint(error, ==, MAPS_ERROR_NONE);
661 /* typedef bool(*maps_route_segment_cb)(int index, int total,
662 * maps_route_segment_h segment, void* user_data); */
663 /* int maps_route_foreach_segment(const maps_route_h route,
664 * maps_route_segment_cb callback, void* user_data); */
665 /* int maps_route_set_segments(maps_route_h route,
666 * const maps_item_list_h segments); */
667 static bool __utc_maps_route_segment_cb(int index, int total,
668 maps_route_segment_h segment, void* user_data)
670 test_env* e = (test_env*) user_data;
676 g_assert_cmpint(index, >=, 0);
677 g_assert_cmpint(total, >=, 1);
679 maps_route_segment_destroy(segment);
684 void utc_maps_route_segments_p(void)
688 maps_item_list_h segments = NULL;
689 int error = maps_item_list_create(&segments);
690 g_assert_cmpint(error, ==, MAPS_ERROR_NONE);
692 maps_route_segment_h obj = NULL;
693 error = maps_route_segment_create(&obj);
695 error = maps_item_list_append(segments, obj, maps_route_segment_clone);
696 g_assert_cmpint(error, ==, MAPS_ERROR_NONE);
697 maps_route_segment_destroy(obj);
699 /* test start --------------------------------- */
700 error = maps_route_set_segments(e.h, segments);
701 g_assert_cmpint(error, ==, MAPS_ERROR_NONE);
703 error = maps_route_foreach_segment(e.h, __utc_maps_route_segment_cb,
705 g_assert_cmpint(error, ==, MAPS_ERROR_NONE);
706 g_assert_cmpint(e.iterations, ==, 1);
707 /* test finish --------------------------------- */
709 error = maps_item_list_remove_all(segments, maps_route_segment_destroy);
710 g_assert_cmpint(error, ==, MAPS_ERROR_NONE);
712 error = maps_item_list_destroy(segments);
713 g_assert_cmpint(error, ==, MAPS_ERROR_NONE);
716 void utc_maps_route_segments_n(void)
720 maps_item_list_h segments = NULL;
721 int error = maps_item_list_create(&segments);
722 g_assert_cmpint(error, ==, MAPS_ERROR_NONE);
724 maps_route_segment_h obj = NULL;
725 error = maps_route_segment_create(&obj);
727 error = maps_item_list_append(segments, obj, maps_route_segment_clone);
728 g_assert_cmpint(error, ==, MAPS_ERROR_NONE);
729 maps_route_segment_destroy(obj);
731 /* test start --------------------------------- */
732 error = maps_route_set_segments(NULL, segments);
733 g_assert_cmpint(error, ==, MAPS_ERROR_INVALID_PARAMETER);
735 error = maps_route_set_segments(e.h, NULL);
736 g_assert_cmpint(error, ==, MAPS_ERROR_INVALID_PARAMETER);
738 error = maps_route_foreach_segment(NULL, __utc_maps_route_segment_cb,
740 g_assert_cmpint(error, ==, MAPS_ERROR_INVALID_PARAMETER);
741 g_assert_cmpint(e.iterations, ==, 0);
743 error = maps_route_foreach_segment(e.h, NULL, &e);
744 g_assert_cmpint(error, ==, MAPS_ERROR_INVALID_PARAMETER);
745 g_assert_cmpint(e.iterations, ==, 0);
746 /* test finish --------------------------------- */
748 error = maps_item_list_remove_all(segments, maps_route_segment_destroy);
749 g_assert_cmpint(error, ==, MAPS_ERROR_NONE);
751 error = maps_item_list_destroy(segments);
752 g_assert_cmpint(error, ==, MAPS_ERROR_NONE);