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, &coords);
162 g_assert_cmpint(error, ==, MAPS_ERROR_NONE);
164 /* start test ------------------------------------------------------- */
165 error = maps_route_set_origin(e.h, coords);
166 g_assert_cmpint(error, ==, MAPS_ERROR_NONE);
168 maps_coordinates_h obtained_coords = NULL;
169 error = maps_route_get_origin(e.h, &obtained_coords);
170 g_assert_cmpint(error, ==, MAPS_ERROR_NONE);
171 g_assert(obtained_coords);
172 maps_coordinates_destroy(obtained_coords);
173 /* finish test ------------------------------------------------------ */
175 error = maps_coordinates_destroy(coords);
176 g_assert_cmpint(error, ==, MAPS_ERROR_NONE);
179 void utc_maps_route_origin_n(void)
183 maps_coordinates_h coords = NULL;
184 int error = maps_coordinates_create(11.1, 22.2, &coords);
185 g_assert_cmpint(error, ==, MAPS_ERROR_NONE);
187 /* start test ------------------------------------------------------- */
188 error = maps_route_set_origin(NULL, coords);
189 g_assert_cmpint(error, ==, MAPS_ERROR_INVALID_PARAMETER);
191 error = maps_route_set_origin(e.h, NULL);
192 g_assert_cmpint(error, ==, MAPS_ERROR_INVALID_PARAMETER);
194 maps_coordinates_h obtained_coords = NULL;
195 error = maps_route_get_origin(NULL, &obtained_coords);
196 g_assert_cmpint(error, ==, MAPS_ERROR_INVALID_PARAMETER);
198 error = maps_route_get_origin(e.h, NULL);
199 g_assert_cmpint(error, ==, MAPS_ERROR_INVALID_PARAMETER);
200 /* finish test ------------------------------------------------------ */
202 error = maps_coordinates_destroy(coords);
203 g_assert_cmpint(error, ==, MAPS_ERROR_NONE);
206 /* int maps_route_set_destination(maps_route_h route,
207 * maps_coordinates_h destination); */
208 /* int maps_route_get_destination(maps_route_h route,
209 * maps_coordinates_h* destination); */
210 void utc_maps_route_destination_p(void)
214 maps_coordinates_h coords = NULL;
215 int error = maps_coordinates_create(11.1, 22.2, &coords);
216 g_assert_cmpint(error, ==, MAPS_ERROR_NONE);
218 /* start test ------------------------------------------------------- */
219 error = maps_route_set_destination(e.h, coords);
220 g_assert_cmpint(error, ==, MAPS_ERROR_NONE);
222 maps_coordinates_h obtained_coords = NULL;
223 error = maps_route_get_destination(e.h, &obtained_coords);
224 g_assert_cmpint(error, ==, MAPS_ERROR_NONE);
225 g_assert(obtained_coords);
226 maps_coordinates_destroy(obtained_coords);
227 /* finish test ------------------------------------------------------ */
229 error = maps_coordinates_destroy(coords);
230 g_assert_cmpint(error, ==, MAPS_ERROR_NONE);
233 void utc_maps_route_destination_n(void)
237 maps_coordinates_h coords = NULL;
238 int error = maps_coordinates_create(11.1, 22.2, &coords);
239 g_assert_cmpint(error, ==, MAPS_ERROR_NONE);
241 /* start test ------------------------------------------------------- */
242 error = maps_route_set_destination(NULL, coords);
243 g_assert_cmpint(error, ==, MAPS_ERROR_INVALID_PARAMETER);
245 error = maps_route_set_destination(e.h, NULL);
246 g_assert_cmpint(error, ==, MAPS_ERROR_INVALID_PARAMETER);
248 maps_coordinates_h obtained_coords = NULL;
249 error = maps_route_get_destination(NULL, &obtained_coords);
250 g_assert_cmpint(error, ==, MAPS_ERROR_INVALID_PARAMETER);
252 error = maps_route_get_destination(e.h, NULL);
253 g_assert_cmpint(error, ==, MAPS_ERROR_INVALID_PARAMETER);
254 /* finish test ------------------------------------------------------ */
256 error = maps_coordinates_destroy(coords);
257 g_assert_cmpint(error, ==, MAPS_ERROR_NONE);
260 /* int maps_route_set_bounding_box(maps_route_h route,
261 * maps_area_h bounding_box); */
262 /* int maps_route_get_bounding_box(maps_route_h route,
263 * maps_area_h* bounding_box); */
264 void utc_maps_route_bounding_box_p(void)
268 maps_coordinates_h coords = NULL;
269 int error = maps_coordinates_create(11.1, 22.2, &coords);
270 g_assert_cmpint(error, ==, MAPS_ERROR_NONE);
272 maps_area_h bounding_box = NULL;
273 error = maps_area_create_circle(coords, 123.4, &bounding_box);
274 g_assert_cmpint(error, ==, MAPS_ERROR_NONE);
276 /* start test ------------------------------------------------------- */
277 error = maps_route_set_bounding_box(e.h, bounding_box);
278 g_assert_cmpint(error, ==, MAPS_ERROR_NONE);
280 maps_coordinates_h obtained_bounding_box = NULL;
281 error = maps_route_get_bounding_box(e.h, &obtained_bounding_box);
282 g_assert_cmpint(error, ==, MAPS_ERROR_NONE);
283 g_assert(obtained_bounding_box);
284 maps_area_destroy(obtained_bounding_box);
285 /* finish test ------------------------------------------------------ */
287 error = maps_area_destroy(bounding_box);
288 g_assert_cmpint(error, ==, MAPS_ERROR_NONE);
290 error = maps_coordinates_destroy(coords);
291 g_assert_cmpint(error, ==, MAPS_ERROR_NONE);
294 void utc_maps_route_bounding_box_n(void)
298 maps_coordinates_h coords = NULL;
299 int error = maps_coordinates_create(11.1, 22.2, &coords);
300 g_assert_cmpint(error, ==, MAPS_ERROR_NONE);
302 maps_area_h bounding_box = NULL;
303 error = maps_area_create_circle(coords, 123.4, &bounding_box);
304 g_assert_cmpint(error, ==, MAPS_ERROR_NONE);
306 /* start test ------------------------------------------------------- */
307 error = maps_route_set_bounding_box(NULL, bounding_box);
308 g_assert_cmpint(error, ==, MAPS_ERROR_INVALID_PARAMETER);
310 error = maps_route_set_bounding_box(e.h, NULL);
311 g_assert_cmpint(error, ==, MAPS_ERROR_INVALID_PARAMETER);
313 maps_coordinates_h obtained_bounding_box = NULL;
314 error = maps_route_get_bounding_box(NULL, &obtained_bounding_box);
315 g_assert_cmpint(error, ==, MAPS_ERROR_INVALID_PARAMETER);
317 error = maps_route_get_bounding_box(e.h, NULL);
318 g_assert_cmpint(error, ==, MAPS_ERROR_INVALID_PARAMETER);
319 /* finish test ------------------------------------------------------ */
321 error = maps_area_destroy(bounding_box);
322 g_assert_cmpint(error, ==, MAPS_ERROR_NONE);
324 error = maps_coordinates_destroy(coords);
325 g_assert_cmpint(error, ==, MAPS_ERROR_NONE);
328 /* int maps_route_set_total_distance(maps_route_h route,
329 * double total_distance); */
330 /* int maps_route_get_total_distance(maps_route_h route,
331 * double* total_distance); */
332 void utc_maps_route_total_distance_p(void)
336 int error = maps_route_set_total_distance(e.h, 42.0);
337 g_assert_cmpint(error, ==, MAPS_ERROR_NONE);
340 error = maps_route_get_total_distance(e.h, &ret);
341 g_assert_cmpint(error, ==, MAPS_ERROR_NONE);
342 g_assert_cmpfloat(ret, ==, 42.0);
345 void utc_maps_route_total_distance_n(void)
349 int error = maps_route_set_total_distance(NULL, 42.0);
350 g_assert_cmpint(error, ==, MAPS_ERROR_INVALID_PARAMETER);
353 error = maps_route_get_total_distance(NULL, &ret);
354 g_assert_cmpint(error, ==, MAPS_ERROR_INVALID_PARAMETER);
356 error = maps_route_get_total_distance(e.h, NULL);
357 g_assert_cmpint(error, ==, MAPS_ERROR_INVALID_PARAMETER);
360 /* int maps_route_set_total_duration(maps_route_h route,
361 * long total_duration); */
362 /* int maps_route_get_total_duration(maps_route_h route,
363 * long* total_duration); */
364 void utc_maps_route_total_duration_p(void)
368 int error = maps_route_set_total_duration(e.h, 42);
369 g_assert_cmpint(error, ==, MAPS_ERROR_NONE);
372 error = maps_route_get_total_duration(e.h, &ret);
373 g_assert_cmpint(error, ==, MAPS_ERROR_NONE);
374 g_assert_cmpint(ret, ==, 42);
377 void utc_maps_route_total_duration_n(void)
381 int error = maps_route_set_total_duration(NULL, 42);
382 g_assert_cmpint(error, ==, MAPS_ERROR_INVALID_PARAMETER);
385 error = maps_route_get_total_duration(NULL, &ret);
386 g_assert_cmpint(error, ==, MAPS_ERROR_INVALID_PARAMETER);
388 error = maps_route_get_total_duration(e.h, NULL);
389 g_assert_cmpint(error, ==, MAPS_ERROR_INVALID_PARAMETER);
392 /* int maps_route_set_transport_mode(maps_route_h route,
393 * maps_route_transport_mode_e transport_mode); */
394 /* int maps_route_get_transport_mode(const maps_route_h route,
395 * maps_route_transport_mode_e* transport_mode); */
396 void utc_maps_route_transport_mode_p(void)
401 maps_route_set_transport_mode(e.h,
402 MAPS_ROUTE_TRANSPORT_MODE_CAR);
403 g_assert_cmpint(error, ==, MAPS_ERROR_NONE);
405 maps_route_transport_mode_e transport_mode =
406 MAPS_ROUTE_TRANSPORT_MODE_TRUCK;
407 error = maps_route_get_transport_mode(e.h, &transport_mode);
408 g_assert_cmpint(error, ==, MAPS_ERROR_NONE);
409 g_assert_cmpint(transport_mode, ==, MAPS_ROUTE_TRANSPORT_MODE_CAR);
412 void utc_maps_route_transport_mode_n(void)
417 maps_route_set_transport_mode(NULL,
418 MAPS_ROUTE_TRANSPORT_MODE_CAR);
419 g_assert_cmpint(error, ==, MAPS_ERROR_INVALID_PARAMETER);
421 maps_route_transport_mode_e transport_mode =
422 MAPS_ROUTE_TRANSPORT_MODE_TRUCK;
423 error = maps_route_get_transport_mode(NULL, &transport_mode);
424 g_assert_cmpint(error, ==, MAPS_ERROR_INVALID_PARAMETER);
426 error = maps_route_get_transport_mode(e.h, NULL);
427 g_assert_cmpint(error, ==, MAPS_ERROR_INVALID_PARAMETER);
430 /* int maps_route_get_distance_unit(const maps_route_h route,
431 * maps_distance_unit_e* distance_unit); */
432 /* int maps_route_set_distance_unit(const maps_route_h route,
433 * const maps_distance_unit_e distance_unit); */
434 void utc_maps_route_distance_unit_p(void)
438 int error = maps_route_set_distance_unit(e.h, MAPS_DISTANCE_UNIT_M);
439 g_assert_cmpint(error, ==, MAPS_ERROR_NONE);
441 maps_distance_unit_e ret = MAPS_DISTANCE_UNIT_YD;
442 error = maps_route_get_distance_unit(e.h, &ret);
443 g_assert_cmpint(error, ==, MAPS_ERROR_NONE);
444 g_assert_cmpint(ret, ==, MAPS_DISTANCE_UNIT_M);
447 void utc_maps_route_distance_unit_n(void)
451 int error = maps_route_set_distance_unit(NULL, MAPS_DISTANCE_UNIT_M);
452 g_assert_cmpint(error, ==, MAPS_ERROR_INVALID_PARAMETER);
454 maps_distance_unit_e ret = MAPS_DISTANCE_UNIT_YD;
455 error = maps_route_get_distance_unit(NULL, &ret);
456 g_assert_cmpint(error, ==, MAPS_ERROR_INVALID_PARAMETER);
458 error = maps_route_get_distance_unit(e.h, NULL);
459 g_assert_cmpint(error, ==, MAPS_ERROR_INVALID_PARAMETER);
462 /* typedef bool(*maps_route_properties_cb)(const char* key, const char* value,
463 * void* user_data); */
464 /* int maps_route_set_properties(maps_route_h route,
465 * maps_item_hashtable_h properties); */
466 /* int maps_route_foreach_property(maps_route_h route,
467 * maps_route_properties_cb callback, void* user_data); */
468 static bool __utc_maps_route_properties_cb(int index, int total, char* key,
469 void* value, void* user_data)
474 g_assert_cmpstr(key, ==, "key");
475 g_assert_cmpstr((const char*) value, ==, "value");
478 test_env* e = (test_env*) user_data;
488 void utc_maps_route_properties_p(void)
492 maps_item_list_h obj = NULL;
493 int error = maps_item_hashtable_create(&obj);
494 g_assert_cmpint(error, ==, MAPS_ERROR_NONE);
496 error = maps_item_hashtable_set(obj, "key", "value",
497 maps_item_hashtable_clone_string,
498 maps_item_hashtable_free_string);
499 g_assert_cmpint(error, ==, MAPS_ERROR_NONE);
501 /* start test ------------------------------------------------------- */
502 error = maps_route_set_properties(e.h, obj);
503 g_assert_cmpint(error, ==, MAPS_ERROR_NONE);
505 error = maps_route_foreach_property(e.h, __utc_maps_route_properties_cb,
507 g_assert_cmpint(error, ==, MAPS_ERROR_NONE);
508 g_assert_cmpint(e.iterations, ==, 1);
509 /* finish test ------------------------------------------------------ */
511 error = maps_item_hashtable_destroy(obj);
512 g_assert_cmpint(error, ==, MAPS_ERROR_NONE);
515 void utc_maps_route_properties_n(void)
519 maps_item_list_h obj = NULL;
520 int error = maps_item_hashtable_create(&obj);
521 g_assert_cmpint(error, ==, MAPS_ERROR_NONE);
523 /* start test ------------------------------------------------------- */
524 error = maps_route_set_properties(NULL, obj);
525 g_assert_cmpint(error, ==, MAPS_ERROR_INVALID_PARAMETER);
527 error = maps_route_set_properties(e.h, NULL);
528 g_assert_cmpint(error, ==, MAPS_ERROR_INVALID_PARAMETER);
530 error = maps_route_foreach_property(NULL,
531 __utc_maps_route_properties_cb, &e);
532 g_assert_cmpint(error, ==, MAPS_ERROR_INVALID_PARAMETER);
534 error = maps_route_foreach_property(e.h, NULL, NULL);
535 g_assert_cmpint(error, ==, MAPS_ERROR_INVALID_PARAMETER);
536 /* finish test ------------------------------------------------------ */
538 error = maps_item_hashtable_destroy(obj);
539 g_assert_cmpint(error, ==, MAPS_ERROR_NONE);
542 /* typedef bool(*maps_route_path_cb)(int index, int total,
543 * maps_coordinates_h coordinates, void* user_data); */
544 /* int maps_route_foreach_path(const maps_route_h route,
545 * maps_route_path_cb callback, void* user_data); */
546 /* int maps_route_set_path(maps_route_h route, const maps_item_list_h path); */
547 static bool __utc_maps_route_path_cb(int index, int total,
548 maps_coordinates_h coordinates, void* user_data)
550 test_env* e = (test_env*) user_data;
554 g_assert(coordinates);
556 g_assert_cmpint(index, >=, 0);
557 g_assert_cmpint(total, >=, 1);
559 maps_coordinates_destroy(coordinates);
564 void utc_maps_route_path_p(void)
568 maps_item_list_h path = NULL;
569 int error = maps_item_list_create(&path);
570 g_assert_cmpint(error, ==, MAPS_ERROR_NONE);
572 maps_coordinates_h obj = NULL;
573 error = maps_coordinates_create(11.1, 22.2, &obj);
574 g_assert_cmpint(error, ==, MAPS_ERROR_NONE);
576 error = maps_item_list_append(path, obj, maps_coordinates_clone);
577 g_assert_cmpint(error, ==, MAPS_ERROR_NONE);
578 maps_coordinates_destroy(obj);
580 /* test start --------------------------------- */
581 error = maps_route_set_path(e.h, path);
582 g_assert_cmpint(error, ==, MAPS_ERROR_NONE);
584 error = maps_route_foreach_path(e.h, __utc_maps_route_path_cb, &e);
585 g_assert_cmpint(error, ==, MAPS_ERROR_NONE);
586 g_assert_cmpint(e.iterations, ==, 1);
587 /* test finish --------------------------------- */
589 error = maps_item_list_remove_all(path, maps_coordinates_destroy);
590 g_assert_cmpint(error, ==, MAPS_ERROR_NONE);
592 error = maps_item_list_destroy(path);
593 g_assert_cmpint(error, ==, MAPS_ERROR_NONE);
596 void utc_maps_route_path_n(void)
600 maps_item_list_h path = NULL;
601 int error = maps_item_list_create(&path);
602 g_assert_cmpint(error, ==, MAPS_ERROR_NONE);
604 maps_coordinates_h obj = NULL;
605 error = maps_coordinates_create(11.1, 22.2, &obj);
607 error = maps_item_list_append(path, obj, maps_coordinates_clone);
608 g_assert_cmpint(error, ==, MAPS_ERROR_NONE);
609 maps_coordinates_destroy(obj);
611 /* test start --------------------------------- */
612 error = maps_route_set_path(NULL, path);
613 g_assert_cmpint(error, ==, MAPS_ERROR_INVALID_PARAMETER);
615 error = maps_route_set_path(e.h, NULL);
616 g_assert_cmpint(error, ==, MAPS_ERROR_INVALID_PARAMETER);
618 error = maps_route_foreach_path(NULL, __utc_maps_route_path_cb, &e);
619 g_assert_cmpint(error, ==, MAPS_ERROR_INVALID_PARAMETER);
620 g_assert_cmpint(e.iterations, ==, 0);
622 error = maps_route_foreach_path(e.h, NULL, &e);
623 g_assert_cmpint(error, ==, MAPS_ERROR_INVALID_PARAMETER);
624 g_assert_cmpint(e.iterations, ==, 0);
625 /* test finish --------------------------------- */
627 /*error = maps_coordinates_destroy(obj); */
628 /*g_assert_cmpint(error, ==, MAPS_ERROR_NONE); */
630 error = maps_item_list_remove_all(path, maps_coordinates_destroy);
631 g_assert_cmpint(error, ==, MAPS_ERROR_NONE);
633 error = maps_item_list_destroy(path);
634 g_assert_cmpint(error, ==, MAPS_ERROR_NONE);
637 /* typedef bool(*maps_route_segment_cb)(int index, int total,
638 * maps_route_segment_h segment, void* user_data); */
639 /* int maps_route_foreach_segment(const maps_route_h route,
640 * maps_route_segment_cb callback, void* user_data); */
641 /* int maps_route_set_segments(maps_route_h route,
642 * const maps_item_list_h segments); */
643 static bool __utc_maps_route_segment_cb(int index, int total,
644 maps_route_segment_h segment, void* user_data)
646 test_env* e = (test_env*) user_data;
652 g_assert_cmpint(index, >=, 0);
653 g_assert_cmpint(total, >=, 1);
655 maps_route_segment_destroy(segment);
660 void utc_maps_route_segments_p(void)
664 maps_item_list_h segments = NULL;
665 int error = maps_item_list_create(&segments);
666 g_assert_cmpint(error, ==, MAPS_ERROR_NONE);
668 maps_route_segment_h obj = NULL;
669 error = maps_route_segment_create(&obj);
671 error = maps_item_list_append(segments, obj, maps_route_segment_clone);
672 g_assert_cmpint(error, ==, MAPS_ERROR_NONE);
673 maps_route_segment_destroy(obj);
675 /* test start --------------------------------- */
676 error = maps_route_set_segments(e.h, segments);
677 g_assert_cmpint(error, ==, MAPS_ERROR_NONE);
679 error = maps_route_foreach_segment(e.h, __utc_maps_route_segment_cb,
681 g_assert_cmpint(error, ==, MAPS_ERROR_NONE);
682 g_assert_cmpint(e.iterations, ==, 1);
683 /* test finish --------------------------------- */
685 error = maps_item_list_remove_all(segments, maps_route_segment_destroy);
686 g_assert_cmpint(error, ==, MAPS_ERROR_NONE);
688 error = maps_item_list_destroy(segments);
689 g_assert_cmpint(error, ==, MAPS_ERROR_NONE);
692 void utc_maps_route_segments_n(void)
696 maps_item_list_h segments = NULL;
697 int error = maps_item_list_create(&segments);
698 g_assert_cmpint(error, ==, MAPS_ERROR_NONE);
700 maps_route_segment_h obj = NULL;
701 error = maps_route_segment_create(&obj);
703 error = maps_item_list_append(segments, obj, maps_route_segment_clone);
704 g_assert_cmpint(error, ==, MAPS_ERROR_NONE);
705 maps_route_segment_destroy(obj);
707 /* test start --------------------------------- */
708 error = maps_route_set_segments(NULL, segments);
709 g_assert_cmpint(error, ==, MAPS_ERROR_INVALID_PARAMETER);
711 error = maps_route_set_segments(e.h, NULL);
712 g_assert_cmpint(error, ==, MAPS_ERROR_INVALID_PARAMETER);
714 error = maps_route_foreach_segment(NULL, __utc_maps_route_segment_cb,
716 g_assert_cmpint(error, ==, MAPS_ERROR_INVALID_PARAMETER);
717 g_assert_cmpint(e.iterations, ==, 0);
719 error = maps_route_foreach_segment(e.h, NULL, &e);
720 g_assert_cmpint(error, ==, MAPS_ERROR_INVALID_PARAMETER);
721 g_assert_cmpint(e.iterations, ==, 0);
722 /* test finish --------------------------------- */
724 error = maps_item_list_remove_all(segments, maps_route_segment_destroy);
725 g_assert_cmpint(error, ==, MAPS_ERROR_NONE);
727 error = maps_item_list_destroy(segments);
728 g_assert_cmpint(error, ==, MAPS_ERROR_NONE);