Add gtest for coverage and auto test
[platform/core/api/uwb.git] / tests / capi-network-uwb-gtest.cpp
1 /*
2  * gtest-uwb.cpp
3  *
4  * Copyright (c) 2020 Samsung Electronics Co., Ltd. All rights reserved.
5  *
6  * Contact: Jihoon Jung <jh8801.jung@samsung.com>
7  *
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  *
20  */
21
22 /*****************************************************************************
23  *  Standard headers
24  *****************************************************************************/
25
26 /*****************************************************************************
27  *  System headers
28  *****************************************************************************/
29 #include <glib.h>
30 #include <gtest/gtest.h>
31 /*****************************************************************************
32  *  Local headers
33  *****************************************************************************/
34 #include <uwb.h>
35
36 /*****************************************************************************
37  *  Macros and Typedefs
38  *****************************************************************************/
39 /*****************************************************************************
40  *  Global Variables
41  *****************************************************************************/
42 /*****************************************************************************
43  *  Local Functions Definition
44  *****************************************************************************/
45
46 class UwbManagerTest : public ::testing::Test {
47 protected:
48         void SetUp() override
49         {
50                 uwb_initialize();
51         }
52
53         void TearDown() override
54         {
55                 uwb_deinitialize();
56         }
57 };
58
59 TEST_F(UwbManagerTest, uwb_initialize_Positive)
60 {
61         int ret = UWB_ERROR_NONE;
62
63         ret = uwb_deinitialize();
64         ASSERT_EQ(UWB_ERROR_NONE, ret);
65
66         ret = uwb_initialize();
67         ASSERT_EQ(UWB_ERROR_NONE, ret);
68 }
69
70 TEST_F(UwbManagerTest, uwb_initialize_Negative)
71 {
72         int ret = UWB_ERROR_NONE;
73
74         ret = uwb_initialize();
75         ASSERT_EQ(UWB_ERROR_ALREADY_INITIALIZED, ret);
76 }
77
78 TEST_F(UwbManagerTest, uwb_deinitialize_Positive)
79 {
80         int ret = UWB_ERROR_NONE;
81
82         ret = uwb_deinitialize();
83         ASSERT_EQ(UWB_ERROR_NONE, ret);
84
85         ret = uwb_initialize();
86         ASSERT_EQ(UWB_ERROR_NONE, ret);
87 }
88
89 TEST_F(UwbManagerTest, uwb_deinitialize_Negative)
90 {
91         int ret = UWB_ERROR_NONE;
92
93         ret = uwb_deinitialize();
94         ASSERT_EQ(UWB_ERROR_NONE, ret);
95
96         ret = uwb_deinitialize();
97         ASSERT_EQ(UWB_ERROR_NOT_INITIALIZED, ret);
98
99         ret = uwb_initialize();
100         ASSERT_EQ(UWB_ERROR_NONE, ret);
101 }
102
103 TEST_F(UwbManagerTest, uwb_reset_Positive)
104 {
105         int ret = UWB_ERROR_NONE;
106
107         ret = uwb_reset();
108
109         ASSERT_EQ(UWB_ERROR_NONE, ret);
110 }
111
112 TEST_F(UwbManagerTest, uwb_reset_Negative)
113 {
114         int ret = UWB_ERROR_NONE;
115
116         ret = uwb_deinitialize();
117         ASSERT_EQ(UWB_ERROR_NONE, ret);
118
119         ret = uwb_reset();
120         EXPECT_EQ(UWB_ERROR_NOT_INITIALIZED, ret);
121
122         ret = uwb_initialize();
123         ASSERT_EQ(UWB_ERROR_NONE, ret);
124 }
125
126 TEST_F(UwbManagerTest, uwb_factory_reset_Positive)
127 {
128         int ret = UWB_ERROR_NONE;
129
130         ret = uwb_factory_reset();
131
132         ASSERT_EQ(UWB_ERROR_NONE, ret);
133 }
134
135 TEST_F(UwbManagerTest, uwb_factory_reset_Negative)
136 {
137         int ret = UWB_ERROR_NONE;
138
139         ret = uwb_deinitialize();
140         ASSERT_EQ(UWB_ERROR_NONE, ret);
141
142         ret = uwb_factory_reset();
143         EXPECT_EQ(UWB_ERROR_NOT_INITIALIZED, ret);
144
145         ret = uwb_initialize();
146         ASSERT_EQ(UWB_ERROR_NONE, ret);
147 }
148
149 void __uwb_message_received_cb(uint64_t node_id, const unsigned char *message,
150         int message_length, void *user_data)
151 {
152
153 }
154
155 TEST_F(UwbManagerTest, uwb_set_message_received_cb_Positive)
156 {
157         int ret = UWB_ERROR_NONE;
158
159         ret = uwb_set_message_received_cb(__uwb_message_received_cb, NULL);
160
161         ASSERT_EQ(UWB_ERROR_NONE, ret);
162 }
163
164 TEST_F(UwbManagerTest, uwb_set_message_received_cb_Negative)
165 {
166         int ret = UWB_ERROR_NONE;
167
168         ret = uwb_set_message_received_cb(NULL, NULL);
169         ASSERT_EQ(UWB_ERROR_INVALID_PARAMETER, ret);
170 }
171
172 void __uwb_position_changed_cb(uint64_t node_id, int x, int y, int z,
173         void *user_data)
174 {
175
176 }
177
178 TEST_F(UwbManagerTest, uwb_set_position_changed_cb_Positive)
179 {
180         int ret = UWB_ERROR_NONE;
181
182         ret = uwb_set_position_changed_cb(__uwb_position_changed_cb, NULL);
183
184         ASSERT_EQ(UWB_ERROR_NONE, ret);
185 }
186
187 TEST_F(UwbManagerTest, uwb_set_position_changed_cb_Negative)
188 {
189         int ret = UWB_ERROR_NONE;
190
191         ret = uwb_set_position_changed_cb(NULL, NULL);
192         ASSERT_EQ(UWB_ERROR_INVALID_PARAMETER, ret);
193 }
194
195 TEST_F(UwbManagerTest, uwb_unset_message_received_cb_Positive)
196 {
197         int ret = UWB_ERROR_NONE;
198
199         ret = uwb_unset_message_received_cb();
200
201         ASSERT_EQ(UWB_ERROR_NONE, ret);
202 }
203
204 TEST_F(UwbManagerTest, uwb_unset_position_changed_cb_Positive)
205 {
206         int ret = UWB_ERROR_NONE;
207
208         ret = uwb_unset_position_changed_cb();
209
210         ASSERT_EQ(UWB_ERROR_NONE, ret);
211 }
212
213 TEST_F(UwbManagerTest, uwb_get_own_node_Positive)
214 {
215         int ret = UWB_ERROR_NONE;
216         uwb_node_h own_node = NULL;
217
218         ret = uwb_get_own_node(&own_node);
219
220         if (own_node != NULL)
221                 uwb_node_destroy(own_node);
222
223         ASSERT_EQ(UWB_ERROR_NONE, ret);
224 }
225
226 TEST_F(UwbManagerTest, uwb_get_own_node_Negative1)
227 {
228         int ret = UWB_ERROR_NONE;
229
230         ret = uwb_deinitialize();
231         ASSERT_EQ(UWB_ERROR_NONE, ret);
232
233         ret = uwb_get_own_node(NULL);
234         EXPECT_EQ(UWB_ERROR_NOT_INITIALIZED, ret);
235
236         ret = uwb_initialize();
237         ASSERT_EQ(UWB_ERROR_NONE, ret);
238 }
239
240 TEST_F(UwbManagerTest, uwb_get_own_node_Negative2)
241 {
242         int ret = UWB_ERROR_NONE;
243
244         ret = uwb_get_own_node(NULL);
245         ASSERT_EQ(UWB_ERROR_INVALID_PARAMETER, ret);
246 }
247
248 GMainLoop *tc_loop;
249 uwb_network_h _network;
250
251 void __uwb_network_get_finished_cb(int result, uwb_network_h network, void *user_data)
252 {
253         uwb_network_clone(network, &_network);
254
255         uwb_network_destroy(network);
256
257         g_main_loop_quit(tc_loop);
258         tc_loop = NULL;
259 }
260
261 class UwbNetworkTest : public ::testing::Test {
262 protected:
263         void SetUp() override
264         {
265                 uwb_initialize();
266
267                 tc_loop = g_main_loop_new(NULL, FALSE);
268
269                 uwb_get_network(__uwb_network_get_finished_cb, NULL);
270
271                 g_main_loop_run(tc_loop);
272         }
273
274         void TearDown() override
275         {
276                 _network = NULL;
277
278                 uwb_deinitialize();
279         }
280
281 };
282
283 GMainLoop *tc_loop2;
284
285 void __uwb_network_get_finished_cb2(int result, uwb_network_h network, void *user_data)
286 {
287         g_main_loop_quit(tc_loop2);
288 }
289
290 TEST_F(UwbNetworkTest, uwb_network_get_Positive)
291 {
292         int ret = UWB_ERROR_NONE;
293
294         tc_loop2 = g_main_loop_new(NULL, FALSE);
295
296         ret = uwb_get_network(__uwb_network_get_finished_cb2, NULL);
297
298         g_main_loop_run(tc_loop2);
299
300         ASSERT_EQ(UWB_ERROR_NONE, ret);
301 }
302
303 TEST_F(UwbNetworkTest, uwb_network_get_Negative1)
304 {
305         int ret = UWB_ERROR_NONE;
306
307         ret = uwb_deinitialize();
308         ASSERT_EQ(UWB_ERROR_NONE, ret);
309
310         ret = uwb_get_network(NULL, NULL);
311         EXPECT_EQ(UWB_ERROR_NOT_INITIALIZED, ret);
312
313         ret = uwb_initialize();
314         ASSERT_EQ(UWB_ERROR_NONE, ret);
315 }
316
317 TEST_F(UwbNetworkTest, uwb_network_get_Negative2)
318 {
319         int ret = UWB_ERROR_NONE;
320
321         ret = uwb_get_network(NULL, NULL);
322         ASSERT_EQ(UWB_ERROR_INVALID_PARAMETER, ret);
323 }
324
325 TEST_F(UwbNetworkTest, uwb_network_clone_Positive)
326 {
327         int ret = UWB_ERROR_NONE;
328
329         uwb_node_h network = NULL;
330
331         ret = uwb_network_clone(_network, &network);
332         ASSERT_TRUE(network != NULL);
333
334         uwb_network_destroy(network);
335         ASSERT_EQ(UWB_ERROR_NONE, ret);
336 }
337
338 TEST_F(UwbNetworkTest, uwb_network_clone_Negative)
339 {
340         int ret = UWB_ERROR_NONE;
341
342         ret = uwb_network_clone(NULL, NULL);
343         ASSERT_EQ(UWB_ERROR_INVALID_PARAMETER, ret);
344 }
345
346 TEST_F(UwbNetworkTest, uwb_network_destroy_Positive)
347 {
348         int ret = UWB_ERROR_NONE;
349
350         uwb_node_h network = NULL;
351
352         uwb_network_clone(_network, &network);
353         ASSERT_TRUE(network != NULL);
354
355         ret = uwb_network_destroy(network);
356         ASSERT_EQ(UWB_ERROR_NONE, ret);
357 }
358
359 TEST_F(UwbNetworkTest, uwb_network_destroy_Negative)
360 {
361         int ret = UWB_ERROR_NONE;
362
363         ret = uwb_network_destroy(NULL);
364         ASSERT_EQ(UWB_ERROR_INVALID_PARAMETER, ret);
365 }
366
367 TEST_F(UwbNetworkTest, uwb_network_get_pan_id_Positive)
368 {
369         int ret = UWB_ERROR_NONE;
370         uint64_t pan_id;
371
372         ret = uwb_network_get_pan_id(_network, &pan_id);
373
374         ASSERT_EQ(UWB_ERROR_NONE, ret);
375 }
376
377 TEST_F(UwbNetworkTest, uwb_network_get_pan_id_Negative)
378 {
379         int ret = UWB_ERROR_NONE;
380
381         ret = uwb_network_get_pan_id(NULL, NULL);
382         ASSERT_EQ(UWB_ERROR_INVALID_PARAMETER, ret);
383 }
384
385 TEST_F(UwbNetworkTest, uwb_network_get_remote_node_count_Positive)
386 {
387         int ret = UWB_ERROR_NONE;
388         int remote_node_count = 0;
389
390         ret = uwb_network_get_remote_node_count(_network, &remote_node_count);
391
392         ASSERT_EQ(UWB_ERROR_NONE, ret);
393 }
394
395 TEST_F(UwbNetworkTest, uwb_network_get_remote_node_count_Negative)
396 {
397         int ret = UWB_ERROR_NONE;
398
399         ret = uwb_network_get_remote_node_count(NULL, NULL);
400         ASSERT_EQ(UWB_ERROR_INVALID_PARAMETER, ret);
401 }
402
403 bool __uwb_network_foreach_remote_node_cb(uwb_node_h remote_node, void *user_data)
404 {
405         return true;
406 }
407
408 TEST_F(UwbNetworkTest, uwb_network_foreach_remote_node_Positive)
409 {
410         int ret = UWB_ERROR_NONE;
411
412         ret = uwb_network_foreach_remote_node(_network, __uwb_network_foreach_remote_node_cb, NULL);
413
414         ASSERT_EQ(UWB_ERROR_NONE, ret);
415 }
416
417 TEST_F(UwbNetworkTest, uwb_network_foreach_remote_node_Negative)
418 {
419         int ret = UWB_ERROR_NONE;
420
421         ret = uwb_network_foreach_remote_node(NULL, NULL, NULL);
422         ASSERT_EQ(UWB_ERROR_INVALID_PARAMETER, ret);
423 }
424
425 class UwbNodeTest : public ::testing::Test {
426 protected:
427         void SetUp() override
428         {
429                 uwb_initialize();
430
431                 uwb_get_own_node(&_node);
432
433                 strncpy(_key_int32, "TEMP", sizeof(_key_int32));
434                 strncpy(_key_int64, "NETWORK_TIMEOUT", sizeof(_key_int64));
435                 strncpy(_key_string, "MODE", sizeof(_key_string));
436         }
437
438         void TearDown() override
439         {
440                 uwb_deinitialize();
441         }
442
443         char _key_int32[1024] = {0,};
444         char _key_int64[1024] = {0,};
445         char _key_string[1024] = {0,};
446         uwb_node_h _node;
447 };
448
449 TEST_F(UwbNodeTest, uwb_node_clone_Positive)
450 {
451         int ret = UWB_ERROR_NONE;
452         uwb_node_h node = NULL;
453
454         ret = uwb_node_clone(_node, &node);
455         ASSERT_TRUE(node != NULL);
456
457         uwb_node_destroy(node);
458         ASSERT_EQ(UWB_ERROR_NONE, ret);
459 }
460
461 TEST_F(UwbNodeTest, uwb_node_clone_Negative)
462 {
463         int ret = UWB_ERROR_NONE;
464
465         ret = uwb_node_clone(NULL, NULL);
466         ASSERT_EQ(UWB_ERROR_INVALID_PARAMETER, ret);
467 }
468
469 TEST_F(UwbNodeTest, uwb_node_destroy_Positive)
470 {
471         int ret = UWB_ERROR_NONE;
472         uwb_node_h node = NULL;
473
474         uwb_get_own_node(&node);
475         ASSERT_TRUE(node != NULL);
476
477         ret = uwb_node_destroy(node);
478         ASSERT_EQ(UWB_ERROR_NONE, ret);
479 }
480
481 TEST_F(UwbNodeTest, uwb_node_destroy_Negative)
482 {
483         int ret = UWB_ERROR_NONE;
484
485         ret = uwb_node_destroy(NULL);
486         ASSERT_EQ(UWB_ERROR_INVALID_PARAMETER, ret);
487 }
488
489 TEST_F(UwbNodeTest, uwb_node_get_distance_Positive)
490 {
491         int ret = UWB_ERROR_NONE;
492         uint64_t distance;
493
494         ret = uwb_node_get_distance(_node, &distance);
495         ASSERT_EQ(UWB_ERROR_NONE, ret);
496 }
497
498 TEST_F(UwbNodeTest, uwb_node_get_distance_Negative)
499 {
500         int ret = UWB_ERROR_NONE;
501
502         ret = uwb_node_get_distance(NULL, NULL);
503         ASSERT_EQ(UWB_ERROR_INVALID_PARAMETER, ret);
504 }
505
506 TEST_F(UwbNodeTest, uwb_node_get_node_id_Positive)
507 {
508         int ret = UWB_ERROR_NONE;
509         uint64_t node_id = 0;
510
511         ret = uwb_node_get_node_id(_node, &node_id);
512         ASSERT_EQ(UWB_ERROR_NONE, ret);
513 }
514
515 TEST_F(UwbNodeTest, uwb_node_get_node_id_Negative)
516 {
517         int ret = UWB_ERROR_NONE;
518
519         ret = uwb_node_get_node_id(NULL, NULL);
520         ASSERT_EQ(UWB_ERROR_INVALID_PARAMETER, ret);
521 }
522
523 TEST_F(UwbNodeTest, uwb_node_get_pan_id_Positive)
524 {
525         int ret = UWB_ERROR_NONE;
526         uint64_t pan_id;
527
528         ret = uwb_node_get_pan_id(_node, &pan_id);
529         ASSERT_EQ(UWB_ERROR_NONE, ret);
530 }
531
532 TEST_F(UwbNodeTest, uwb_node_get_pan_id_Negative)
533 {
534         int ret = UWB_ERROR_NONE;
535
536         ret = uwb_node_get_pan_id(NULL, NULL);
537         ASSERT_EQ(UWB_ERROR_INVALID_PARAMETER, ret);
538 }
539
540 TEST_F(UwbNodeTest, uwb_node_get_is_remote_Positive)
541 {
542         int ret = UWB_ERROR_NONE;
543         bool is_remote = false;
544
545         ret = uwb_node_get_is_remote(_node, &is_remote);
546         ASSERT_EQ(UWB_ERROR_NONE, ret);
547 }
548
549 TEST_F(UwbNodeTest, uwb_node_get_is_remote_Negative)
550 {
551         int ret = UWB_ERROR_NONE;
552
553         ret = uwb_node_get_is_remote(NULL, NULL);
554         ASSERT_EQ(UWB_ERROR_INVALID_PARAMETER, ret);
555 }
556
557 TEST_F(UwbNodeTest, uwb_node_get_position_Positive)
558 {
559         int ret = UWB_ERROR_NONE;
560         int x = 0;
561         int y = 0;
562         int z = 0;
563
564         ret = uwb_node_get_position(_node, &x, &y, &z);
565
566         ASSERT_EQ(UWB_ERROR_NONE, ret);
567 }
568
569 TEST_F(UwbNodeTest, uwb_node_get_position_Negative)
570 {
571         int ret = UWB_ERROR_NONE;
572
573         ret = uwb_node_get_position(NULL, NULL, NULL, NULL);
574         ASSERT_EQ(UWB_ERROR_INVALID_PARAMETER, ret);
575 }
576
577 TEST_F(UwbNodeTest, uwb_node_set_position_Positive)
578 {
579         int ret = UWB_ERROR_NONE;
580
581         ret = uwb_node_set_position(_node, 1, 2, 3);
582
583         ASSERT_EQ(UWB_ERROR_NONE, ret);
584 }
585
586 TEST_F(UwbNodeTest, uwb_node_set_position_Negative1)
587 {
588         int ret = UWB_ERROR_NONE;
589
590         ret = uwb_deinitialize();
591         ASSERT_EQ(UWB_ERROR_NONE, ret);
592
593         ret = uwb_node_set_position(NULL, 0, 0, 0);
594         EXPECT_EQ(UWB_ERROR_NOT_INITIALIZED, ret);
595
596         ret = uwb_initialize();
597         ASSERT_EQ(UWB_ERROR_NONE, ret);
598 }
599
600 TEST_F(UwbNodeTest, uwb_node_set_position_Negative2)
601 {
602         int ret = UWB_ERROR_NONE;
603
604         ret = uwb_node_set_position(NULL, 0, 0, 0);
605         ASSERT_EQ(UWB_ERROR_INVALID_PARAMETER, ret);
606 }
607
608 TEST_F(UwbNodeTest, uwb_node_send_message_Positive)
609 {
610         int ret = UWB_ERROR_NONE;
611         const unsigned char message[1024] = {0x00, 0x01, 0x02};
612
613         ret = uwb_node_send_message(message, sizeof(message));
614
615         ASSERT_EQ(UWB_ERROR_NONE, ret);
616 }
617
618 TEST_F(UwbNodeTest, uwb_node_send_message_Negative1)
619 {
620         int ret = UWB_ERROR_NONE;
621
622         ret = uwb_deinitialize();
623         ASSERT_EQ(UWB_ERROR_NONE, ret);
624
625         ret = uwb_node_send_message(NULL, 0);
626         EXPECT_EQ(UWB_ERROR_NOT_INITIALIZED, ret);
627
628         ret = uwb_initialize();
629         ASSERT_EQ(UWB_ERROR_NONE, ret);
630 }
631
632 TEST_F(UwbNodeTest, uwb_node_send_message_Negative2)
633 {
634         int ret = UWB_ERROR_NONE;
635
636         ret = uwb_node_send_message(NULL, 0);
637         ASSERT_EQ(UWB_ERROR_INVALID_PARAMETER, ret);
638 }
639
640 TEST_F(UwbNodeTest, uwb_node_send_message_to_Positive)
641 {
642         int ret = UWB_ERROR_NONE;
643         const unsigned char message[1024] = {0x00, 0x01, 0x02};
644
645         ret = uwb_node_send_message_to(_node, message, sizeof(message));
646
647         ASSERT_EQ(UWB_ERROR_NONE, ret);
648 }
649
650 TEST_F(UwbNodeTest, uwb_node_send_message_to_Negative1)
651 {
652         int ret = UWB_ERROR_NONE;
653
654         ret = uwb_deinitialize();
655         ASSERT_EQ(UWB_ERROR_NONE, ret);
656
657         ret = uwb_node_send_message_to(NULL, NULL, 0);
658         EXPECT_EQ(UWB_ERROR_NOT_INITIALIZED, ret);
659
660         ret = uwb_initialize();
661         ASSERT_EQ(UWB_ERROR_NONE, ret);
662 }
663
664 TEST_F(UwbNodeTest, uwb_node_send_message_to_Negative2)
665 {
666         int ret = UWB_ERROR_NONE;
667
668         ret = uwb_node_send_message_to(NULL, NULL, 0);
669         ASSERT_EQ(UWB_ERROR_INVALID_PARAMETER, ret);
670 }
671
672 TEST_F(UwbNodeTest, uwb_node_get_configuration_int32_Positive)
673 {
674         int ret = UWB_ERROR_NONE;
675
676         int value;
677
678         ret = uwb_node_get_configuration_int32(_node, _key_int32, &value);
679
680         ASSERT_EQ(UWB_ERROR_NONE, ret);
681 }
682
683 TEST_F(UwbNodeTest, uwb_node_get_configuration_int32_Negative1)
684 {
685         int ret = UWB_ERROR_NONE;
686
687         ret = uwb_deinitialize();
688         ASSERT_EQ(UWB_ERROR_NONE, ret);
689
690         ret = uwb_node_get_configuration_int32(NULL, NULL, NULL);
691         EXPECT_EQ(UWB_ERROR_NOT_INITIALIZED, ret);
692
693         ret = uwb_initialize();
694         ASSERT_EQ(UWB_ERROR_NONE, ret);
695 }
696
697 TEST_F(UwbNodeTest, uwb_node_get_configuration_int32_Negative2)
698 {
699         int ret = UWB_ERROR_NONE;
700
701         ret = uwb_node_get_configuration_int32(NULL, NULL, NULL);
702         ASSERT_EQ(UWB_ERROR_INVALID_PARAMETER, ret);
703 }
704
705 TEST_F(UwbNodeTest, uwb_node_set_configuration_int32_Positive)
706 {
707         int ret = UWB_ERROR_NONE;
708
709         ret = uwb_node_set_configuration_int32(_node, _key_int32, 0);
710
711         ASSERT_EQ(UWB_ERROR_NONE, ret);
712 }
713
714 TEST_F(UwbNodeTest, uwb_node_set_configuration_int32_Negative1)
715 {
716         int ret = UWB_ERROR_NONE;
717
718         ret = uwb_deinitialize();
719         ASSERT_EQ(UWB_ERROR_NONE, ret);
720
721         ret = uwb_node_set_configuration_int32(NULL, NULL, 0);
722         EXPECT_EQ(UWB_ERROR_NOT_INITIALIZED, ret);
723
724         ret = uwb_initialize();
725         ASSERT_EQ(UWB_ERROR_NONE, ret);
726 }
727
728 TEST_F(UwbNodeTest, uwb_node_set_configuration_int32_Negative2)
729 {
730         int ret = UWB_ERROR_NONE;
731
732         ret = uwb_node_set_configuration_int32(NULL, NULL, 0);
733         ASSERT_EQ(UWB_ERROR_INVALID_PARAMETER, ret);
734 }
735
736 TEST_F(UwbNodeTest, uwb_node_get_configuration_int64_Positive)
737 {
738         int ret = UWB_ERROR_NONE;
739         int64_t value = 0;
740
741         ret = uwb_node_get_configuration_int64(_node, _key_int64, &value);
742
743         ASSERT_EQ(UWB_ERROR_NONE, ret);
744 }
745
746 TEST_F(UwbNodeTest, uwb_node_get_configuration_int64_Negative1)
747 {
748         int ret = UWB_ERROR_NONE;
749
750         ret = uwb_deinitialize();
751         ASSERT_EQ(UWB_ERROR_NONE, ret);
752
753         ret = uwb_node_get_configuration_int64(NULL, NULL, NULL);
754         EXPECT_EQ(UWB_ERROR_NOT_INITIALIZED, ret);
755
756         ret = uwb_initialize();
757         ASSERT_EQ(UWB_ERROR_NONE, ret);
758 }
759
760 TEST_F(UwbNodeTest, uwb_node_get_configuration_int64_Negative2)
761 {
762         int ret = UWB_ERROR_NONE;
763
764         ret = uwb_node_get_configuration_int64(NULL, NULL, NULL);
765         ASSERT_EQ(UWB_ERROR_INVALID_PARAMETER, ret);
766 }
767
768 TEST_F(UwbNodeTest, uwb_node_set_configuration_int64_Positive)
769 {
770         int ret = UWB_ERROR_NONE;
771
772         ret = uwb_node_set_configuration_int64(_node, _key_int64, 0);
773
774         ASSERT_EQ(UWB_ERROR_NONE, ret);
775 }
776
777 TEST_F(UwbNodeTest, uwb_node_set_configuration_int64_Negative1)
778 {
779         int ret = UWB_ERROR_NONE;
780
781         ret = uwb_deinitialize();
782         ASSERT_EQ(UWB_ERROR_NONE, ret);
783
784         ret = uwb_node_set_configuration_int64(NULL, NULL, 0);
785         EXPECT_EQ(UWB_ERROR_NOT_INITIALIZED, ret);
786
787         ret = uwb_initialize();
788         ASSERT_EQ(UWB_ERROR_NONE, ret);
789 }
790
791 TEST_F(UwbNodeTest, uwb_node_set_configuration_int64_Negative2)
792 {
793         int ret = UWB_ERROR_NONE;
794
795         ret = uwb_node_set_configuration_int64(NULL, NULL, 0);
796         ASSERT_EQ(UWB_ERROR_INVALID_PARAMETER, ret);
797 }
798
799 TEST_F(UwbNodeTest, uwb_node_get_configuration_string_Positive)
800 {
801         int ret = UWB_ERROR_NONE;
802         char *value = NULL;
803
804         ret = uwb_node_get_configuration_string(_node, _key_string, &value);
805
806         if (value != NULL)
807                 free(value);
808
809         ASSERT_EQ(UWB_ERROR_NONE, ret);
810 }
811
812 TEST_F(UwbNodeTest, uwb_node_get_configuration_string_Negative1)
813 {
814         int ret = UWB_ERROR_NONE;
815
816         ret = uwb_deinitialize();
817         ASSERT_EQ(UWB_ERROR_NONE, ret);
818
819         ret = uwb_node_get_configuration_string(NULL, NULL, NULL);
820         EXPECT_EQ(UWB_ERROR_NOT_INITIALIZED, ret);
821
822         ret = uwb_initialize();
823         ASSERT_EQ(UWB_ERROR_NONE, ret);
824 }
825
826 TEST_F(UwbNodeTest, uwb_node_get_configuration_string_Negative2)
827 {
828         int ret = UWB_ERROR_NONE;
829
830         ret = uwb_node_get_configuration_string(NULL, NULL, NULL);
831         ASSERT_EQ(UWB_ERROR_INVALID_PARAMETER, ret);
832 }
833
834 TEST_F(UwbNodeTest, uwb_node_set_configuration_string_Positive)
835 {
836         int ret = UWB_ERROR_NONE;
837         char conf_str[1024] = {0,};
838
839         strncpy(conf_str, "HELLO", sizeof(conf_str));
840
841         ret = uwb_node_set_configuration_string(_node, _key_string, (const char *)conf_str);
842
843         ASSERT_EQ(UWB_ERROR_NONE, ret);
844 }
845
846 TEST_F(UwbNodeTest, uwb_node_set_configuration_string_Negative1)
847 {
848         int ret = UWB_ERROR_NONE;
849
850         ret = uwb_deinitialize();
851         ASSERT_EQ(UWB_ERROR_NONE, ret);
852
853         ret = uwb_node_set_configuration_string(NULL, NULL, NULL);
854         EXPECT_EQ(UWB_ERROR_NOT_INITIALIZED, ret);
855
856         ret = uwb_initialize();
857         ASSERT_EQ(UWB_ERROR_NONE, ret);
858 }
859
860 TEST_F(UwbNodeTest, uwb_node_set_configuration_string_Negative2)
861 {
862         int ret = UWB_ERROR_NONE;
863
864         ret = uwb_node_set_configuration_string(NULL, NULL, NULL);
865         ASSERT_EQ(UWB_ERROR_INVALID_PARAMETER, ret);
866 }
867
868 int main(int argc, char **argv)
869 {
870         ::testing::InitGoogleTest(&argc, argv);
871         return RUN_ALL_TESTS();
872 }