30 #include "unittest-support.h"
38 static const gchar *suitename =
"/qof/kvp_frame";
39 void test_suite_kvp_frame (
void );
48 setup(
Fixture *fixture, gconstpointer pData )
51 fixture->hdlrs = NULL;
55 teardown(
Fixture *fixture, gconstpointer pData )
58 g_slist_free_full (fixture->hdlrs, test_free_log_handler);
59 test_clear_error_list ();
62 static gchar* glist_to_string(
const GList *list )
70 extern KvpFrame* ( *p_get_trailer_make )(
KvpFrame *frame,
const char *key_path,
char **end_key );
72 extern const KvpFrame* ( *p_kvp_frame_get_frame_or_null_slash_trash )(
const KvpFrame *frame,
char *key_path );
73 extern const KvpFrame* ( *p_get_trailer_or_null )(
const KvpFrame * frame,
const char * key_path,
char **end_key );
75 extern void init_static_test_pointers(
void );
78 setup_static(
Fixture *fixture, gconstpointer pData )
81 fixture->hdlrs = NULL;
82 init_static_test_pointers();
83 g_assert( p_get_trailer_make && p_get_or_make && p_get_trailer_or_null &&
84 p_kvp_frame_get_frame_or_null_slash_trash );
88 teardown_static(
Fixture *fixture, gconstpointer pData )
91 g_slist_free_full (fixture->hdlrs, test_free_log_handler);
92 test_clear_error_list ();
93 p_get_trailer_make = NULL;
95 p_kvp_frame_get_frame_or_null_slash_trash = NULL;
96 p_get_trailer_or_null = NULL;
110 g_date_set_dmy (&gdate, 26, 1, 1957);
117 kvp_frame_set_guid( frame,
"guid-type", guid );
121 list = g_list_prepend (list, kvp_value_new_guid (guid));
122 list = g_list_prepend (list, kvp_value_new_string (
"qrstuvwxyz"));
123 list = g_list_prepend (list, kvp_value_new_timespec (ts));
124 list = g_list_prepend (list, kvp_value_new_numeric (gnc_numeric_create (256, 120)));
125 list = g_list_prepend (list, kvp_value_new_double (0.4342944819));
126 list = g_list_prepend (list, kvp_value_new_gint64 (0x1f2e3d4c5b6a79LL));
133 test_kvp_frame_new_delete(
void )
142 guid = populate_frame (frame);
152 test_kvp_frame_copy(
Fixture *fixture, gconstpointer pData )
155 gint64 test_gint64, copy_gint64;
156 double test_double, copy_double;
159 const char* test_str, *copy_str;
160 GncGUID *test_guid, *copy_guid;
166 test_gnc_numeric = gnc_numeric_zero();
169 test_str =
"abcdefghijklmnop";
173 g_assert( fixture->frame );
179 kvp_frame_set_guid( fixture->frame,
"guid-type", test_guid );
180 kvp_frame_set_frame( fixture->frame,
"frame-type", test_frame );
183 g_test_message(
"Test frame copy" );
187 g_assert( to_copy != fixture->frame );
190 copy_gint64 = kvp_frame_get_gint64( to_copy,
"gint64-type" );
191 g_assert( ©_gint64 != &test_gint64 );
192 g_assert_cmpint( copy_gint64, == , test_gint64 );
193 copy_double = kvp_frame_get_double( to_copy,
"double-type" );
194 g_assert( ©_double != &test_double );
195 g_assert_cmpfloat( copy_double, == , test_double );
196 copy_gnc_numeric = kvp_frame_get_numeric( to_copy,
"numeric-type" );
197 g_assert( ©_gnc_numeric != &test_gnc_numeric );
198 g_assert_cmpfloat( copy_gnc_numeric.num, == , test_gnc_numeric.num );
199 g_assert_cmpfloat( copy_gnc_numeric.denom, == , test_gnc_numeric.denom );
200 copy_ts = kvp_frame_get_timespec( to_copy,
"timespec-type" );
201 g_assert( ©_ts != &test_ts );
202 g_assert_cmpfloat( copy_ts.tv_sec, == , test_ts.tv_sec );
203 g_assert_cmpfloat( copy_ts.tv_nsec, == , test_ts.tv_nsec );
204 copy_str = kvp_frame_get_string( to_copy,
"string-type" );
205 g_assert( copy_str != test_str );
206 g_assert_cmpstr( copy_str, == , test_str );
207 copy_guid = kvp_frame_get_guid( to_copy,
"guid-type" );
208 g_assert( copy_guid != test_guid );
209 g_assert(
guid_equal( copy_guid, test_guid ) );
211 g_assert( copy_frame );
213 g_assert( copy_frame != test_frame );
217 guid_free( test_guid );
221 test_kvp_frame_set_foo(
Fixture *fixture, gconstpointer pData )
225 GncGUID *test_guid, *copy_guid;
227 test_gnc_numeric = gnc_numeric_zero();
232 g_assert( fixture->frame );
235 g_test_message(
"Test gint64 setup and replace, test frame is created" );
239 g_assert_cmpint( kvp_frame_get_gint64( fixture->frame,
"/test/gint64" ), == , 1 );
241 g_assert_cmpint( kvp_frame_get_gint64( fixture->frame,
"/test/gint64" ), == , 5 );
243 g_test_message(
"Test double setup and replace, test2 frame is created" );
247 g_assert_cmpfloat( kvp_frame_get_double( fixture->frame,
"/test2/double" ), == , 1.1 );
249 g_assert_cmpfloat( kvp_frame_get_double( fixture->frame,
"/test2/double" ), == , 5.5 );
251 g_test_message(
"Test double setup and replace, test3 frame is created" );
255 copy_gnc_numeric = kvp_frame_get_numeric( fixture->frame,
"/test3/numeric" );
256 g_assert_cmpint( copy_gnc_numeric.num, == , 0 );
257 g_assert_cmpint( copy_gnc_numeric.denom, == , 1 );
258 test_gnc_numeric.num = 2;
259 test_gnc_numeric.denom = 3;
261 copy_gnc_numeric = kvp_frame_get_numeric( fixture->frame,
"/test3/numeric" );
262 g_assert_cmpint( copy_gnc_numeric.num, == , 2 );
263 g_assert_cmpint( copy_gnc_numeric.denom, == , 3 );
265 g_test_message(
"Test timespec setup and replace, test4 frame is created" );
269 copy_ts = kvp_frame_get_timespec( fixture->frame,
"/test4/timespec" );
270 g_assert_cmpint( copy_ts.tv_sec, == , 1 );
271 g_assert_cmpint( copy_ts.tv_nsec, == , 1 );
273 test_ts.tv_nsec = 13;
275 copy_ts = kvp_frame_get_timespec( fixture->frame,
"/test4/timespec" );
276 g_assert_cmpint( copy_ts.tv_sec, == , 7 );
277 g_assert_cmpint( copy_ts.tv_nsec, == , 13 );
279 g_test_message(
"Test string setup and replace, test5 frame is created" );
283 g_assert_cmpstr( kvp_frame_get_string( fixture->frame,
"/test5/string" ), == ,
"one string" );
285 g_assert_cmpstr( kvp_frame_get_string( fixture->frame,
"/test5/string" ), == ,
"another string" );
287 g_test_message(
"Test guid setup and replace, test6 frame is created" );
289 kvp_frame_set_guid( fixture->frame,
"/test6/guid", test_guid );
291 copy_guid = kvp_frame_get_guid( fixture->frame,
"/test6/guid" );
292 g_assert(
guid_equal( copy_guid, test_guid ) );
293 kvp_frame_set_guid( fixture->frame,
"/test6/guid",
guid_null() );
294 copy_guid = kvp_frame_get_guid( fixture->frame,
"/test6/guid" );
297 g_test_message(
"Test frame setup and replace, test7 frame is created" );
299 kvp_frame_set_frame( fixture->frame,
"/test7",
kvp_frame_new() );
301 kvp_frame_set_frame( fixture->frame,
"/test7", NULL );
306 test_kvp_frame_get_frame_slash(
Fixture *fixture, gconstpointer pData )
310 g_assert( fixture->frame );
312 g_test_message(
"Test path with one slash same frame should be returned" );
313 result_frame = kvp_frame_get_frame_slash( fixture->frame,
"/" );
314 g_assert( result_frame );
315 g_assert( result_frame == fixture->frame );
317 g_test_message(
"Test path with trailing slash same frame should be returned" );
318 result_frame = kvp_frame_get_frame_slash( fixture->frame,
"/////" );
319 g_assert( result_frame );
320 g_assert( result_frame == fixture->frame );
322 g_test_message(
"Test new frame is created" );
323 result_frame = kvp_frame_get_frame_slash( fixture->frame,
"/test" );
324 g_assert( result_frame );
325 g_assert( result_frame != fixture->frame );
328 g_test_message(
"Test trailing slashes are ignored and frame created" );
329 result_frame = kvp_frame_get_frame_slash( fixture->frame,
"////test2/////" );
330 g_assert( result_frame );
331 g_assert( result_frame != fixture->frame );
335 g_test_message(
"Test frames are created along the path if not exist and last frame is returned" );
336 result_frame = kvp_frame_get_frame_slash( fixture->frame,
"////test3/////test4//////" );
337 g_assert( result_frame );
338 g_assert( result_frame != fixture->frame );
345 g_test_message(
"Test existing frame is returned" );
346 g_assert( result_frame == kvp_frame_get_frame_slash( fixture->frame,
"////test3/////test4//////" ) );
350 test_kvp_frame_get_slot_path(
Fixture *fixture, gconstpointer pData )
354 g_assert( fixture->frame );
357 g_test_message(
"Test with non existing path should return NULL" );
359 g_assert( !result_value );
361 g_test_message(
"Test with existing value set to current frame" );
364 g_assert( result_value );
368 g_test_message(
"Test should return null as test is not a frame" );
371 g_assert( !result_value );
373 g_test_message(
"Test should return last value in the path" );
376 g_assert( result_value );
380 g_test_message(
"Test should return null as last value in the path does not exist" );
382 g_assert( !result_value );
386 test_kvp_frame_get_slot_path_gslist(
Fixture *fixture, gconstpointer pData )
389 GSList *path_list = NULL;
392 g_assert( fixture->frame );
395 g_test_message(
"Test with non existing path should return NULL" );
396 path_list = g_slist_append (path_list,
"test");
397 path_list = g_slist_append (path_list,
"test2");
399 g_assert( !result_value );
401 g_test_message(
"Test with existing value set to current frame" );
402 path_list = g_slist_remove( path_list,
"test2" );
405 g_assert( result_value );
409 g_test_message(
"Test should return null as test is not a frame" );
410 path_list = g_slist_append (path_list,
"test2");
413 g_assert( !result_value );
415 g_test_message(
"Test should return last value in the path" );
416 path_list = g_slist_remove( path_list,
"test" );
417 path_list = g_slist_append (path_list,
"test3");
420 g_assert( result_value );
424 g_test_message(
"Test should return null as last value in the path does not exist" );
425 path_list = g_slist_append (path_list,
"test4");
427 g_assert( !result_value );
428 g_slist_free( path_list );
432 test_kvp_frame_add_frame_nc(
Fixture *fixture, gconstpointer pData )
442 *result_frame = NULL;
444 GList *result_list = NULL;
446 g_assert( fixture->frame );
449 g_test_message(
"Test when path does not exist it is created" );
451 g_assert( !result_frame );
455 g_assert( result_frame );
456 g_assert( result_frame == test_frame );
458 g_assert( result_frame != test_frame );
460 g_assert( result_frame != test_frame );
462 g_test_message(
"Test when value exist on the path it's converted to bag and new value added" );
465 result_value = kvp_frame_get_value( fixture->frame,
"/test/test2/test3" );
467 g_assert( result_list );
468 g_assert_cmpint( g_list_length( result_list ), == , 2 );
469 result_value = g_list_first( result_list )->data;
470 g_assert( result_value );
473 result_value = g_list_next( result_list )->data;
474 g_assert( result_value );
478 g_test_message(
"Test when bag exists on the path new values are added to it" );
481 result_value = kvp_frame_get_value( fixture->frame,
"/test/test2/test3" );
483 g_assert_cmpint( g_list_length( result_list ), == , 3 );
484 result_value = g_list_first( result_list )->data;
485 g_assert( result_value );
488 result_value = g_list_next( result_list )->data;
489 g_assert( result_value );
492 result_value = g_list_last( result_list )->data;
493 g_assert( result_value );
499 test_kvp_value_copy(
void )
501 KvpValue *gint64_orig_value, *gint64_copy_value;
502 KvpValue *double_orig_value, *double_copy_value;
503 KvpValue *numeric_orig_value, *numeric_copy_value;
504 KvpValue *string_orig_value, *string_copy_value;
505 KvpValue *guid_orig_value, *guid_copy_value;
506 KvpValue *timespec_orig_value, *timespec_copy_value;
507 KvpValue *glist_orig_value, *glist_copy_value;
508 KvpValue *frame_orig_value, *frame_copy_value;
514 GList *list_orig, *list_copy;
517 gnc_numeric_orig = gnc_numeric_zero();
522 list_orig = g_list_append( list_orig, kvp_value_new_string(
"abcdefghijklmnop" ) );
525 g_test_message(
"Test creates original values and checks copies of them" );
526 gint64_orig_value = kvp_value_new_gint64( 2 );
527 double_orig_value = kvp_value_new_double( 3.3 );
529 string_orig_value = kvp_value_new_string(
"abcdefghijklmnop" );
530 guid_orig_value = kvp_value_new_guid( guid_orig );
531 timespec_orig_value = kvp_value_new_timespec( ts_orig );
533 frame_orig_value = kvp_value_new_frame( frame_orig );
534 g_assert( gint64_orig_value && double_orig_value && numeric_orig_value && string_orig_value
535 && guid_orig_value && timespec_orig_value && glist_orig_value && frame_orig_value );
539 g_assert( gint64_copy_value );
540 g_assert( gint64_copy_value != gint64_orig_value );
541 g_assert( kvp_value_get_type( gint64_copy_value ) ==
KVP_TYPE_GINT64 );
545 g_assert( double_copy_value );
546 g_assert( double_copy_value != double_orig_value );
547 g_assert( kvp_value_get_type( double_copy_value ) ==
KVP_TYPE_DOUBLE );
548 g_assert_cmpfloat( kvp_value_get_double( double_copy_value ), == , 3.3 );
551 g_assert( numeric_copy_value );
552 g_assert( numeric_copy_value != numeric_orig_value );
554 gnc_numeric_copy = kvp_value_get_numeric( numeric_copy_value );
555 g_assert_cmpfloat( gnc_numeric_copy.num, == , gnc_numeric_orig.num );
556 g_assert_cmpfloat( gnc_numeric_copy.denom, == , gnc_numeric_orig.denom );
559 g_assert( string_copy_value );
560 g_assert( string_copy_value != string_orig_value );
561 g_assert( kvp_value_get_type( string_copy_value ) ==
KVP_TYPE_STRING );
565 g_assert( guid_copy_value );
566 g_assert( guid_copy_value != guid_orig_value );
567 g_assert( kvp_value_get_type( guid_copy_value ) ==
KVP_TYPE_GUID );
569 g_assert( guid_orig != guid_copy );
570 g_assert(
guid_equal( guid_orig, guid_copy ) );
573 g_assert( timespec_copy_value );
574 g_assert( timespec_copy_value != timespec_orig_value );
576 ts_copy = kvp_value_get_timespec( timespec_copy_value );
577 g_assert_cmpfloat( ts_copy.tv_sec, == , ts_orig.tv_sec );
578 g_assert_cmpfloat( ts_copy.tv_nsec, == , ts_orig.tv_nsec );
581 g_assert( glist_copy_value );
582 g_assert( glist_copy_value != glist_orig_value );
583 g_assert( kvp_value_get_type( glist_copy_value ) ==
KVP_TYPE_GLIST );
585 g_assert( list_copy != list_orig );
586 g_assert_cmpint( g_list_length( list_copy ), == , g_list_length( list_orig ) );
587 g_assert_cmpint( kvp_glist_compare( list_orig, list_copy ), == , 0 );
590 g_assert( frame_copy_value );
591 g_assert( frame_copy_value != frame_orig_value );
592 g_assert( kvp_value_get_type( frame_copy_value ) ==
KVP_TYPE_FRAME );
617 test_kvp_glist_copy(
void )
619 GList *value_list = NULL, *copy_list = NULL, *lp1 = NULL, *lp2 = NULL;
635 gnc_numeric_orig = gnc_numeric_zero();
640 list_orig = g_list_append( list_orig, kvp_value_new_string(
"abcdefghijklmnop" ) );
643 gint64_value = kvp_value_new_gint64( 2 );
644 double_value = kvp_value_new_double( 3.3 );
646 string_value = kvp_value_new_string(
"abcdefghijklmnop" );
647 guid_value = kvp_value_new_guid( guid_orig );
648 timespec_value = kvp_value_new_timespec( ts_orig );
650 frame_value = kvp_value_new_frame( frame_orig );
652 value_list = g_list_append( value_list, gint64_value );
653 value_list = g_list_append( value_list, double_value );
654 value_list = g_list_append( value_list, numeric_value );
655 value_list = g_list_append( value_list, string_value );
656 value_list = g_list_append( value_list, guid_value );
657 value_list = g_list_append( value_list, timespec_value );
658 value_list = g_list_append( value_list, glist_value );
659 value_list = g_list_append( value_list, frame_value );
660 g_assert( value_list );
661 g_assert_cmpint( g_list_length( value_list ), == , 8 );
663 g_test_message(
"Test list and all values are copied to new list" );
665 g_assert( copy_list );
666 g_assert( copy_list != value_list );
667 g_assert_cmpint( g_list_length( copy_list ), == , 8 );
674 g_assert( v1 != v2 );
679 g_assert_cmpint( kvp_glist_compare( value_list, copy_list ), == , 0 );
687 test_kvp_glist_compare(
void )
689 GList *list1 = NULL, *list2 = NULL;
706 gnc_numeric_orig = gnc_numeric_zero();
711 list_orig = g_list_append( list_orig, kvp_value_new_string(
"abcdefghijklmnop" ) );
714 gint64_value = kvp_value_new_gint64( 2 );
715 double_value = kvp_value_new_double( 3.3 );
717 string_value = kvp_value_new_string(
"abcdefghijklmnop" );
718 guid_value = kvp_value_new_guid( guid_orig );
719 timespec_value = kvp_value_new_timespec( ts_orig );
721 frame_value = kvp_value_new_frame( frame_orig );
724 list1 = g_list_append( list1, gint64_value );
725 list1 = g_list_append( list1, double_value );
726 list1 = g_list_append( list1, numeric_value );
727 list1 = g_list_append( list1, string_value );
728 list1 = g_list_append( list1, guid_value );
729 list1 = g_list_append( list1, timespec_value );
730 list1 = g_list_append( list1, glist_value );
731 list1 = g_list_append( list1, frame_value );
733 g_assert_cmpint( g_list_length( list1 ), == , 8 );
735 g_test_message(
"Test when list is the same" );
737 g_assert_cmpint( kvp_glist_compare( list1, list2 ), == , 0 );
739 g_test_message(
"Test when list1 is null" );
740 g_assert_cmpint( kvp_glist_compare( NULL, list2 ), == , -1 );
742 g_test_message(
"Test when list2 is null" );
743 g_assert_cmpint( kvp_glist_compare( list1, NULL ), == , 1 );
745 g_test_message(
"Copy list and test they are equal" );
747 g_assert( list1 != list2 );
748 g_assert_cmpint( g_list_length( list1 ), == , g_list_length( list2 ) );
749 g_assert_cmpint( kvp_glist_compare( list1, list2 ), == , 0 );
751 g_test_message(
"Test when list 1 is shorter lists are not equal" );
752 list1 = g_list_remove( list1, frame_value );
753 g_assert_cmpint( g_list_length( list1 ), == , 7 );
754 g_assert_cmpint( g_list_length( list2 ), == , 8 );
755 g_assert_cmpint( kvp_glist_compare( list1, list2 ), == , -1 );
757 g_test_message(
"Test when list 2 is shorter lists are not equal" );
758 list1 = g_list_append( list1, frame_value );
759 list1 = g_list_append( list1, frame_value );
760 g_assert_cmpint( g_list_length( list1 ), == , 9 );
761 g_assert_cmpint( g_list_length( list2 ), == , 8 );
762 g_assert_cmpint( kvp_glist_compare( list1, list2 ), == , 1 );
764 g_test_message(
"Test when data is not equal lists are not equal" );
765 list1 = g_list_remove( list1, frame_value );
766 g_assert_cmpint( g_list_length( list1 ), == , g_list_length( list2 ) );
767 g_assert_cmpint( kvp_glist_compare( list1, list2 ), == , 0 );
768 list1 = g_list_remove( list1, gint64_value );
770 list1 = g_list_prepend( list1, kvp_value_new_gint64( 5 ) );
771 g_assert_cmpint( g_list_length( list1 ), == , g_list_length( list2 ) );
772 g_assert_cmpint( kvp_glist_compare( list1, list2 ), != , 0 );
780 test_kvp_value_compare(
void )
782 KvpValue *gint64_orig_value, *gint64_copy_value;
783 KvpValue *double_orig_value, *double_copy_value;
784 KvpValue *numeric_orig_value, *numeric_copy_value;
785 KvpValue *string_orig_value, *string_copy_value;
786 KvpValue *guid_orig_value, *guid_copy_value;
787 KvpValue *timespec_orig_value, *timespec_copy_value;
788 KvpValue *glist_orig_value, *glist_copy_value;
789 KvpValue *frame_orig_value, *frame_copy_value;
795 GList *list_orig, *list_copy;
798 gnc_numeric_orig = gnc_numeric_zero();
799 gnc_numeric_copy = gnc_numeric_zero();
807 list_orig = g_list_append( list_orig, kvp_value_new_string(
"abcdefghijklmnop" ) );
809 list_copy = g_list_append( list_copy, kvp_value_new_string(
"abcdefg" ) );
813 gint64_orig_value = kvp_value_new_gint64( 2 );
814 gint64_copy_value = kvp_value_new_gint64( 5 );
815 double_orig_value = kvp_value_new_double( 3.3 );
816 double_copy_value = kvp_value_new_double( 3.5 );
819 string_orig_value = kvp_value_new_string(
"abcdefghijklmnop" );
820 string_copy_value = kvp_value_new_string(
"abcdefghijklmnop" );
821 guid_orig_value = kvp_value_new_guid( guid_orig );
822 guid_copy_value = kvp_value_new_guid( guid_copy );
823 timespec_orig_value = kvp_value_new_timespec( ts_orig );
824 timespec_copy_value = kvp_value_new_timespec( ts_copy );
827 frame_orig_value = kvp_value_new_frame( frame_orig );
828 frame_copy_value = kvp_value_new_frame( frame_copy );
830 g_test_message(
"Test the same kvpvalue is equal" );
831 g_assert_cmpint(
kvp_value_compare( gint64_orig_value, gint64_orig_value ), == , 0 );
833 g_test_message(
"Test first value is null" );
836 g_test_message(
"Test second value is null" );
839 g_test_message(
"Test diffrent data types first is lesser" );
840 g_assert_cmpint(
kvp_value_compare( gint64_orig_value, double_orig_value ), == , -1 );
842 g_test_message(
"Test diffrent data types second is lesser" );
843 g_assert_cmpint(
kvp_value_compare( double_orig_value, gint64_orig_value ), == , 1 );
848 g_test_message(
"Test different kvpvalues of all the types" );
849 g_assert_cmpint(
kvp_value_compare( gint64_orig_value, gint64_copy_value ), == , -1 );
850 g_assert_cmpint(
kvp_value_compare( gint64_copy_value, gint64_orig_value ), == , 1 );
851 g_assert_cmpint(
kvp_value_compare( double_orig_value, double_copy_value ), == , -1 );
853 g_assert_cmpint(
kvp_value_compare( string_orig_value, string_copy_value ), == , strcmp(
"abcdefghijklmnop",
"abcdefghijklmnop" ) );
854 g_assert_cmpint(
kvp_value_compare( guid_orig_value, guid_copy_value ), == , guid_compare( guid_orig, guid_copy ) );
856 g_assert_cmpint(
kvp_value_compare( glist_orig_value, glist_copy_value ), == , kvp_glist_compare( list_orig, list_copy ) );
880 test_kvp_value_new_foo_nc(
void )
882 KvpValue *glist_value_nc, *frame_value_nc;
888 g_test_message(
"Test new glist is not copied" );
889 list = g_list_append( list, kvp_value_new_gint64( 2 ) );
890 g_assert_cmpint( g_list_length( list ), == , 1 );
892 g_assert( glist_value_nc );
893 g_assert( kvp_value_get_type( glist_value_nc ) ==
KVP_TYPE_GLIST );
896 g_test_message(
"Test new frame is not copied" );
899 g_assert( frame_value_nc );
900 g_assert( kvp_value_get_type( frame_value_nc ) ==
KVP_TYPE_FRAME );
908 test_kvp_frame_compare(
Fixture *fixture, gconstpointer pData )
913 g_assert( cmp_frame );
915 g_test_message(
"Test the same frame is equal with itself" );
918 g_test_message(
"Test first frame null second not null" );
921 g_test_message(
"Test first frame not null second null" );
924 g_test_message(
"Test first frame is empty second not empty" );
930 g_test_message(
"Test first frame is not empty second is empty" );
933 g_test_message(
"Test when frames are equal" );
938 g_test_message(
"Test when frames have equal data but second frame has additional slot set" );
942 g_test_message(
"Test when frames have equal data but first frame has additional slot set" );
945 g_test_message(
"Test when frames have equal number of slots second frame has different data in one slot" );
949 g_test_message(
"Test when frames have equal number of slots second frame has different data in one slot" );
956 test_kvp_value_to_string(
void )
959 gchar *str_tmp2, *str_tmp3;
976 gnc_numeric_orig = gnc_numeric_zero();
981 list_orig = g_list_append( list_orig, kvp_value_new_string(
"abcdefghijklmnop" ) );
984 gint64_value = kvp_value_new_gint64( 2 );
985 double_value = kvp_value_new_double( 3.3 );
987 string_value = kvp_value_new_string(
"abcdefghijklmnop" );
988 guid_value = kvp_value_new_guid( guid_orig );
989 timespec_value = kvp_value_new_timespec( ts_orig );
991 frame_value = kvp_value_new_frame( frame_orig );
993 g_test_message(
"Test value string representation with different data types" );
996 g_assert_cmpstr( result, == ,
"KVP_VALUE_GINT64(2)" );
1001 g_assert_cmpstr( result, == ,
"KVP_VALUE_DOUBLE(3.3)" );
1006 g_assert_cmpstr( result, == ,
"KVP_VALUE_NUMERIC(0/1)" );
1011 g_assert_cmpstr( result, == ,
"KVP_VALUE_STRING(abcdefghijklmnop)" );
1017 str_tmp2 = g_strdup_printf(
"KVP_VALUE_GUID(%s)", guidstr);
1018 g_assert_cmpstr( result, == , str_tmp2 );
1024 str_tmp2 = g_new0 (
char, 40);
1026 str_tmp3 = g_strdup_printf(
"KVP_VALUE_TIMESPEC(%s)", str_tmp2);
1027 g_assert_cmpstr( result, == , str_tmp3 );
1034 g_assert_cmpstr( result, == ,
"KVP_VALUE_GLIST([ KVP_VALUE_STRING(abcdefghijklmnop), ])" );
1039 g_assert_cmpstr( result, == ,
"KVP_VALUE_FRAME({\n}\n)" );
1053 test_kvp_frame_to_string(
Fixture *fixture, gconstpointer pData )
1061 test_gnc_numeric = gnc_numeric_zero();
1064 test_ts.tv_nsec = 1;
1067 g_assert( fixture->frame );
1070 g_test_message(
"Test empty frame" );
1072 g_assert_cmpstr( result, == ,
"{\n}\n" );
1078 g_test_message(
"Test with all data types and nested frames" );
1081 g_assert( g_strrstr( result,
" gint64-type => KVP_VALUE_GINT64(2),\n" ) != NULL );
1086 g_assert( g_strrstr( result,
" double-type => KVP_VALUE_DOUBLE(3.3),\n" ) != NULL );
1091 g_assert( g_strrstr( result,
" numeric-type => KVP_VALUE_NUMERIC(0/1),\n" ) != NULL );
1096 g_assert( g_strrstr( result,
" timespec-type => KVP_VALUE_TIMESPEC" ) != NULL );
1101 g_assert( g_strrstr( result,
" string-type => KVP_VALUE_STRING(abcdefghijklmnop),\n" ) != NULL );
1104 kvp_frame_set_guid( fixture->frame,
"/guid-type", test_guid );
1106 g_assert( g_strrstr( result,
" guid-type => KVP_VALUE_GUID" ) != NULL );
1109 kvp_frame_set_frame( fixture->frame,
"/nested/frame-type", test_frame );
1111 g_assert( g_strrstr( result,
" nested => KVP_VALUE_FRAME({\n frame-type => KVP_VALUE_FRAME({\n}\n),\n}\n),\n" ) != NULL );
1116 test_kvp_frame_set_slot_path(
Fixture *fixture, gconstpointer pData )
1118 KvpValue *input_value, *output_value;
1120 g_assert( fixture->frame );
1123 g_test_message(
"Test with a simple value added to the empty frame" );
1124 input_value = kvp_value_new_gint64( 2 );
1127 g_assert( output_value );
1128 g_assert( input_value != output_value );
1132 g_test_message(
"Test when value is being replaced" );
1133 input_value = kvp_value_new_double( 3.3 );
1136 g_assert( output_value );
1137 g_assert( input_value != output_value );
1141 g_test_message(
"Test when existing path elements are not frames" );
1142 input_value = kvp_value_new_string(
"abcdefghijklmnop" );
1148 g_test_message(
"Test frames are created along the path when needed" );
1149 input_value = kvp_value_new_string(
"abcdefghijklmnop" );
1152 g_assert( output_value );
1153 g_assert( kvp_value_get_type( output_value ) ==
KVP_TYPE_FRAME );
1155 g_assert( output_value );
1156 g_assert( input_value != output_value );
1162 test_kvp_frame_set_slot_path_gslist(
Fixture *fixture, gconstpointer pData )
1165 GSList *path_list = NULL;
1166 KvpValue *input_value, *output_value;
1168 g_assert( fixture->frame );
1171 g_test_message(
"Test with a simple value added to the empty frame" );
1172 path_list = g_slist_append( path_list,
"test" );
1173 input_value = kvp_value_new_gint64( 2 );
1176 g_assert( output_value );
1177 g_assert( input_value != output_value );
1181 g_test_message(
"Test when value is being replaced" );
1182 input_value = kvp_value_new_double( 3.3 );
1185 g_assert( output_value );
1186 g_assert( input_value != output_value );
1190 g_test_message(
"Test when existing path elements are not frames" );
1191 path_list = g_slist_append( path_list,
"test2");
1192 input_value = kvp_value_new_string(
"abcdefghijklmnop" );
1198 g_test_message(
"Test frames are created along the path when needed" );
1199 path_list = g_slist_remove( path_list,
"test" );
1200 path_list = g_slist_append( path_list,
"test3");
1201 input_value = kvp_value_new_string(
"abcdefghijklmnop" );
1204 g_assert( output_value );
1205 g_assert( kvp_value_get_type( output_value ) ==
KVP_TYPE_FRAME );
1207 g_assert( output_value );
1208 g_assert( input_value != output_value );
1212 g_slist_free( path_list );
1216 test_kvp_frame_replace_slot_nc(
Fixture *fixture, gconstpointer pData )
1218 KvpValue *orig_value, *orig_value2;
1221 g_assert( fixture->frame );
1224 g_test_message(
"Test when new value is created frame hash init and value stored in hash" );
1225 orig_value = kvp_value_new_gint64( 2 );
1230 g_assert( !keys[1] );
1231 g_assert( orig_value != kvp_frame_get_value( fixture->frame, keys[0] ) );
1232 g_assert_cmpint(
kvp_value_compare( kvp_frame_get_value( fixture->frame, keys[0] ), orig_value ), ==, 0 );
1235 g_test_message(
"Test when value is replaced" );
1236 orig_value2 = kvp_value_new_gint64( 5 );
1240 g_assert( !keys[1] );
1241 g_assert( orig_value != kvp_frame_get_value( fixture->frame, keys[0] ) );
1242 g_assert_cmpint(
kvp_value_compare( kvp_frame_get_value( fixture->frame, keys[0] ), orig_value2 ), ==, 0 );
1243 g_assert_cmpint(
kvp_value_compare( kvp_frame_get_value( fixture->frame, keys[0] ), orig_value ), !=, 0 );
1251 test_get_trailer_make(
Fixture *fixture, gconstpointer pData )
1253 char *last_key = NULL;
1255 KvpFrame *frame = NULL, *frame2 = NULL;
1257 g_test_message(
"Test null frame and empty string checks" );
1258 g_assert( p_get_trailer_make( NULL,
"test", &last_key ) == NULL );
1259 g_assert( !last_key );
1260 g_assert( p_get_trailer_make( fixture->frame, NULL, &last_key ) == NULL );
1261 g_assert( !last_key );
1262 g_assert( p_get_trailer_make( fixture->frame,
"", &last_key ) == NULL );
1263 g_assert( !last_key );
1265 g_test_message(
"Test single frame on the path with no slash" );
1266 g_assert( p_get_trailer_make( fixture->frame,
"test", &last_key ) == fixture->frame );
1267 g_assert_cmpstr( last_key, == ,
"test" );
1269 g_test_message(
"Test single frame on the path with slash" );
1271 g_assert( p_get_trailer_make( fixture->frame,
"/test", &last_key ) == fixture->frame );
1272 g_assert_cmpstr( last_key, == ,
"test" );
1274 g_test_message(
"Test path of trailing slash" );
1276 g_assert( p_get_trailer_make( fixture->frame,
"test/", &last_key ) == NULL );
1277 g_assert( !last_key );
1279 g_test_message(
"Test path of two entries: frame for test should be created" );
1285 frame = p_get_trailer_make( fixture->frame,
"/test/test2", &last_key );
1287 g_assert( frame != fixture->frame );
1288 frame_value = kvp_frame_get_slot( fixture->frame,
"test" );
1289 g_assert( frame_value );
1291 frame_value = kvp_frame_get_slot( frame,
"test2" );
1292 g_assert( !frame_value );
1293 g_assert_cmpstr( last_key, == ,
"test2" );
1295 g_test_message(
"Test path of two entries: test frame already exist" );
1299 g_assert( frame == p_get_trailer_make( fixture->frame,
"/test/test2", &last_key ) );
1300 g_assert_cmpstr( last_key, == ,
"test2" );
1302 g_test_message(
"Test path of three entries: neither frame exist" );
1308 frame = p_get_trailer_make( fixture->frame,
"/test3/test4/test5", &last_key );
1310 g_assert( frame != fixture->frame );
1311 frame_value = kvp_frame_get_slot( fixture->frame,
"test3" );
1312 g_assert( frame_value );
1314 g_assert( frame2 != frame );
1315 g_assert( frame2 != fixture->frame );
1316 frame_value = kvp_frame_get_slot( frame2,
"test4" );
1317 g_assert( frame_value );
1319 frame_value = kvp_frame_get_slot( frame,
"test5" );
1320 g_assert( !frame_value );
1321 g_assert_cmpstr( last_key, == ,
"test5" );
1325 test_kvp_value_glist_to_string(
Fixture *fixture, gconstpointer pData )
1330 GList *value_list = NULL;
1337 gnc_numeric_orig = gnc_numeric_zero();
1339 list_orig = g_list_append( list_orig, kvp_value_new_string(
"abcdefghijklmnop" ) );
1342 g_test_message(
"Test empty list" );
1343 result = glist_to_string( value_list );
1344 g_assert_cmpstr( result, == ,
"" );
1347 g_test_message(
"Test list with simple and complex values" );
1348 value_list = g_list_append( value_list, kvp_value_new_gint64( 2 ) );
1349 value_list = g_list_append( value_list, kvp_value_new_double( 3.3 ) );
1351 value_list = g_list_append( value_list, kvp_value_new_string(
"abcdefghijklmnop" ) );
1353 value_list = g_list_append( value_list, kvp_value_new_frame( frame_orig ) );
1354 g_assert( value_list );
1355 g_assert_cmpint( g_list_length( value_list ), == , 6 );
1356 result = glist_to_string( value_list );
1358 g_assert_cmpstr( result, == ,
"KVP_VALUE_GLIST([ KVP_VALUE_GINT64(2), KVP_VALUE_DOUBLE(3.3), KVP_VALUE_NUMERIC(0/1), KVP_VALUE_STRING(abcdefghijklmnop), KVP_VALUE_GLIST([ KVP_VALUE_STRING(abcdefghijklmnop), ]), KVP_VALUE_FRAME({\n}\n), ])" );
1365 test_get_or_make(
Fixture *fixture, gconstpointer pData )
1369 g_assert( fixture->frame );
1372 g_test_message(
"Test new frame is created" );
1373 test_frame = p_get_or_make( fixture->frame,
"test" );
1374 g_assert( test_frame );
1375 g_assert( test_frame != fixture->frame );
1378 g_test_message(
"Test existing frame is returned" );
1379 g_assert( test_frame == p_get_or_make( fixture->frame,
"test" ) );
1384 test_kvp_frame_get_frame_or_null_slash_trash(
Fixture *fixture, gconstpointer pData )
1386 g_test_message(
"Test null checks" );
1387 g_assert( p_kvp_frame_get_frame_or_null_slash_trash( NULL,
"test" ) == NULL );
1388 g_assert( p_kvp_frame_get_frame_or_null_slash_trash( fixture->frame, NULL ) == NULL );
1390 g_test_message(
"Test single slash and trailing slash path" );
1391 g_assert( p_kvp_frame_get_frame_or_null_slash_trash( fixture->frame,
"/" ) == fixture->frame );
1392 g_assert( p_kvp_frame_get_frame_or_null_slash_trash( fixture->frame,
"////" ) == fixture->frame );
1394 g_test_message(
"Test non existing path" );
1395 g_assert( p_kvp_frame_get_frame_or_null_slash_trash( fixture->frame,
"/test" ) == NULL );
1397 g_test_message(
"Test existing path when value is not frame" );
1399 g_assert( p_kvp_frame_get_frame_or_null_slash_trash( fixture->frame,
"/test" ) == NULL );
1401 g_test_message(
"Test existing path when value is frame" );
1402 kvp_frame_set_frame( fixture->frame,
"/test2",
kvp_frame_new() );
1403 g_assert( p_kvp_frame_get_frame_or_null_slash_trash( fixture->frame,
"/test2" ) != NULL );
1407 test_get_trailer_or_null(
Fixture *fixture, gconstpointer pData )
1409 char *last_key = NULL;
1413 g_test_message(
"Test null frame and empty string checks" );
1414 g_assert( p_get_trailer_or_null( NULL,
"test", &last_key ) == NULL );
1415 g_assert( !last_key );
1416 g_assert( p_get_trailer_or_null( fixture->frame, NULL, &last_key ) == NULL );
1417 g_assert( !last_key );
1418 g_assert( p_get_trailer_or_null( fixture->frame,
"", &last_key ) == NULL );
1419 g_assert( !last_key );
1421 g_test_message(
"Test single frame on the path with no slash" );
1422 g_assert( p_get_trailer_or_null( fixture->frame,
"test", &last_key ) == fixture->frame );
1423 g_assert_cmpstr( last_key, == ,
"test" );
1425 g_test_message(
"Test single frame on the path with slash" );
1427 g_assert( p_get_trailer_or_null( fixture->frame,
"/test", &last_key ) == fixture->frame );
1428 g_assert_cmpstr( last_key, == ,
"test" );
1430 g_test_message(
"Test path of trailing slash" );
1432 g_assert( p_get_trailer_or_null( fixture->frame,
"test/", &last_key ) == NULL );
1433 g_assert( !last_key );
1435 g_test_message(
"Test with non existing path" );
1437 g_assert( p_get_trailer_or_null( fixture->frame,
"/test/test2", &last_key ) == NULL );
1438 g_assert_cmpstr( last_key, == ,
"test2" );
1440 g_test_message(
"Test with existing path" );
1443 kvp_frame_set_frame( fixture->frame,
"/test/test2", frame );
1444 frame2 = p_get_trailer_or_null( fixture->frame,
"/test/test2", &last_key );
1446 g_assert_cmpstr( last_key, == ,
"test2" );
1450 test_kvp_frame_get_gvalue (
Fixture *fixture, gconstpointer pData)
1455 GncGUID *guid = populate_frame (frame);
1457 gchar *log_domain =
"qof.kvp";
1458 gint log_level = G_LOG_LEVEL_WARNING | G_LOG_FLAG_FATAL;
1459 gchar *msg1 =
"[gvalue_from_kvp_value()] Error! Attempt to transfer KvpFrame!";
1460 gchar *msg2 =
"[gvalue_from_kvp_value()] Error! Invalid KVP Transfer Request!";
1462 TestErrorStruct *check1 = test_error_struct_new (log_domain, log_level,
1464 TestErrorStruct *check2 = test_error_struct_new (log_domain, log_level,
1466 fixture->hdlrs = test_log_set_fatal_handler (fixture->hdlrs, check1,
1467 (GLogFunc)test_list_handler);
1468 test_add_error (check1);
1469 test_add_error (check2);
1471 g_date_clear (&date, 1);
1472 g_date_set_dmy (&date, 26, 1, 1957);
1475 g_assert (value != NULL);
1476 g_assert (G_VALUE_HOLDS_INT64 (value));
1477 g_assert_cmpint (g_value_get_int64 (value), ==, 100);
1481 g_assert (value != NULL);
1482 g_assert (G_VALUE_HOLDS_DOUBLE (value));
1483 g_assert_cmpfloat (g_value_get_double (value), ==, 3.14159);
1487 g_assert (value != NULL);
1488 g_assert_cmpint (G_VALUE_TYPE (value), ==, GNC_TYPE_NUMERIC);
1493 g_assert (value != NULL);
1494 g_assert_cmpint (G_VALUE_TYPE (value), ==, GNC_TYPE_TIMESPEC);
1499 g_assert (value != NULL);
1500 g_assert (G_VALUE_HOLDS_STRING (value));
1501 g_assert_cmpstr (g_value_get_string (value), ==,
"abcdefghijklmnop");
1505 g_assert (value != NULL);
1506 g_assert_cmpint (G_VALUE_TYPE (value), ==, GNC_TYPE_GUID);
1511 g_assert (value != NULL);
1512 g_assert_cmpint (G_VALUE_TYPE (value), ==, G_TYPE_DATE);
1513 g_assert_cmpint (g_date_compare (&date, (GDate*)g_value_get_boxed (value)), ==, 0);
1517 g_assert (value == NULL);
1518 g_assert_cmpint (check1->hits, ==, 1);
1519 g_assert_cmpint (check2->hits, ==, 1);
1522 g_assert (value != NULL);
1523 g_assert_cmpint (G_VALUE_TYPE (value), ==, GNC_TYPE_VALUE_LIST);
1525 GList *list = (GList*)g_value_get_boxed (value);
1526 GValue *value = NULL;
1528 value = (GValue*)(list->data);
1529 g_assert (G_VALUE_HOLDS_INT64 (value));
1530 g_assert (g_value_get_int64 (value) == 0x1f2e3d4c5b6a79LL);
1531 list = g_list_next (list);
1533 value = (GValue*)(list->data);
1534 g_assert (G_VALUE_HOLDS_DOUBLE (value));
1535 g_assert_cmpfloat (g_value_get_double (value), ==, 0.4342944819);
1536 list = g_list_next (list);
1538 value = (GValue*)(list->data);
1539 g_assert_cmpint (G_VALUE_TYPE (value), ==, GNC_TYPE_NUMERIC);
1541 gnc_numeric_create (256, 120)));
1542 list = g_list_next (list);
1544 value = (GValue*)(list->data);
1545 g_assert_cmpint (G_VALUE_TYPE (value), ==, GNC_TYPE_TIMESPEC);
1547 list = g_list_next (list);
1549 value = (GValue*)(list->data);
1550 g_assert (G_VALUE_HOLDS_STRING (value));
1551 g_assert_cmpstr (g_value_get_string (value), ==,
"qrstuvwxyz");
1552 list = g_list_next (list);
1554 value = (GValue*)(list->data);
1555 g_assert_cmpint (G_VALUE_TYPE (value), ==, GNC_TYPE_GUID);
1557 list = g_list_next (list);
1559 g_assert (list == NULL);
1566 test_kvp_frame_set_gvalue (
Fixture *fixture, gconstpointer pData)
1571 KvpFrame *o_frame = fixture->frame;
1574 GList *o_list, *n_list;
1576 populate_frame (o_frame);
1579 g_assert (value != NULL);
1581 g_assert_cmpint (kvp_frame_get_gint64 (o_frame,
"gint64-type"), ==,
1582 kvp_frame_get_gint64 (n_frame,
"gint64-type"));
1585 g_assert (value != NULL);
1587 g_assert_cmpint (kvp_frame_get_double (o_frame,
"double-type"), ==,
1588 kvp_frame_get_double (n_frame,
"double-type"));
1591 g_assert (value != NULL);
1594 kvp_frame_get_numeric (n_frame,
"numeric-type")));
1597 g_assert (value != NULL);
1600 Timespec o_ts = kvp_frame_get_timespec (o_frame,
"timespec-type");
1601 Timespec n_ts = kvp_frame_get_timespec (n_frame,
"timespec-type");
1606 g_assert (value != NULL);
1608 g_assert_cmpstr (kvp_frame_get_string (o_frame,
"string-type"), ==,
1609 kvp_frame_get_string (n_frame,
"string-type"));
1612 g_assert (value != NULL);
1619 g_assert_cmpint (g_date_compare (&o_date, &n_date), ==, 0);
1623 g_assert (value != NULL);
1625 g_assert (
guid_equal (kvp_frame_get_guid (o_frame,
"guid-type"),
1626 kvp_frame_get_guid (n_frame,
"guid-type")));
1629 g_assert (value != NULL);
1634 g_assert_cmpint (g_list_length (o_list), ==, g_list_length (n_list));
1635 while (o_list && n_list)
1639 o_list = g_list_next (o_list);
1640 n_list = g_list_next (n_list);
1646 test_kvp_frame_get_keys(
void )
1649 const char * key1 =
"number one";
1650 const char * key2 =
"number one/number two";
1651 const char * key3 =
"number three";
1652 const char * val1 =
"Value1";
1653 const char * val2 =
"Value2";
1654 const char * val3 =
"Value3";
1655 unsigned int spot = 0;
1663 g_assert(keys[spot]);
1664 g_assert(strcmp(keys[spot++], val1));
1665 g_assert(keys[spot]);
1666 g_assert(strcmp(keys[spot++], val3));
1667 g_assert(!keys[spot]);
1674 test_suite_kvp_frame(
void )
1676 GNC_TEST_ADD_FUNC( suitename,
"kvp frame new and delete", test_kvp_frame_new_delete );
1677 GNC_TEST_ADD( suitename,
"kvp frame copy",
Fixture, NULL, setup, test_kvp_frame_copy, teardown );
1678 GNC_TEST_ADD( suitename,
"kvp frame set foo",
Fixture, NULL, setup, test_kvp_frame_set_foo, teardown );
1679 GNC_TEST_ADD( suitename,
"kvp frame get frame slash",
Fixture, NULL, setup, test_kvp_frame_get_frame_slash, teardown );
1680 GNC_TEST_ADD( suitename,
"kvp frame get slot path",
Fixture, NULL, setup, test_kvp_frame_get_slot_path, teardown );
1681 GNC_TEST_ADD( suitename,
"kvp frame get slot path gslist",
Fixture, NULL, setup, test_kvp_frame_get_slot_path_gslist, teardown );
1682 GNC_TEST_ADD( suitename,
"kvp frame add frame nc",
Fixture, NULL, setup, test_kvp_frame_add_frame_nc, teardown );
1683 GNC_TEST_ADD_FUNC( suitename,
"kvp value copy", test_kvp_value_copy );
1684 GNC_TEST_ADD_FUNC( suitename,
"kvp glist copy", test_kvp_glist_copy );
1685 GNC_TEST_ADD_FUNC( suitename,
"kvp glist compare", test_kvp_glist_compare );
1686 GNC_TEST_ADD_FUNC( suitename,
"kvp value compare", test_kvp_value_compare );
1687 GNC_TEST_ADD_FUNC( suitename,
"kvp value new foo no copy", test_kvp_value_new_foo_nc );
1688 GNC_TEST_ADD( suitename,
"kvp frame compare",
Fixture, NULL, setup, test_kvp_frame_compare, teardown );
1689 GNC_TEST_ADD_FUNC( suitename,
"kvp value to string", test_kvp_value_to_string );
1690 GNC_TEST_ADD( suitename,
"kvp frame to string",
Fixture, NULL, setup, test_kvp_frame_to_string, teardown );
1691 GNC_TEST_ADD( suitename,
"kvp frame set slot path",
Fixture, NULL, setup, test_kvp_frame_set_slot_path, teardown );
1692 GNC_TEST_ADD( suitename,
"kvp frame set slot path gslist",
Fixture, NULL, setup, test_kvp_frame_set_slot_path_gslist, teardown );
1693 GNC_TEST_ADD( suitename,
"kvp frame replace slot nc",
Fixture, NULL, setup, test_kvp_frame_replace_slot_nc, teardown );
1694 GNC_TEST_ADD_FUNC( suitename,
"kvp frame get keys", test_kvp_frame_get_keys );
1695 GNC_TEST_ADD( suitename,
"get trailer make",
Fixture, NULL, setup_static, test_get_trailer_make, teardown_static );
1696 GNC_TEST_ADD( suitename,
"kvp value glist to string",
Fixture, NULL, setup_static, test_kvp_value_glist_to_string, teardown_static );
1697 GNC_TEST_ADD( suitename,
"get or make",
Fixture, NULL, setup_static, test_get_or_make, teardown_static );
1698 GNC_TEST_ADD( suitename,
"kvp frame get frame or null slash trash",
Fixture, NULL, setup_static, test_kvp_frame_get_frame_or_null_slash_trash, teardown_static );
1699 GNC_TEST_ADD( suitename,
"get trailer or null",
Fixture, NULL, setup_static, test_get_trailer_or_null, teardown_static );
1700 GNC_TEST_ADD ( suitename,
"kvp frame get gvalue",
Fixture, NULL, setup, test_kvp_frame_get_gvalue, teardown);
1701 GNC_TEST_ADD ( suitename,
"kvp frame set gvalue",
Fixture, NULL, setup, test_kvp_frame_set_gvalue, teardown);
void kvp_frame_set_gvalue(KvpFrame *frame, const gchar *key, const GValue *value)
void kvp_frame_set_slot_path_gslist(KvpFrame *frame, KvpValue *value, GSList *key_path)
gboolean gnc_numeric_equal(gnc_numeric a, gnc_numeric b)
gchar * gnc_timespec_to_iso8601_buff(Timespec ts, gchar *buff)
void kvp_frame_set_slot(KvpFrame *frame, const gchar *key, KvpValue *value)
void kvp_frame_set_timespec(KvpFrame *frame, const gchar *path, Timespec ts)
GList * kvp_glist_copy(const GList *list)
gboolean kvp_frame_is_empty(const KvpFrame *frame)
GncGUID * guid_copy(const GncGUID *guid)
void kvp_frame_add_frame_nc(KvpFrame *frame, const gchar *path, KvpFrame *chld)
Store the given kvp_frame to the glist bag at the indicated path (non-copying)
gint kvp_frame_compare(const KvpFrame *fa, const KvpFrame *fb)
KvpFrame * kvp_frame_copy(const KvpFrame *frame)
gboolean timespec_equal(const Timespec *ta, const Timespec *tb)
Use a 64-bit unsigned int timespec.
void kvp_frame_set_gint64(KvpFrame *frame, const gchar *path, gint64 ival)
gboolean gnc_numeric_zero_p(gnc_numeric a)
gchar * guid_to_string_buff(const GncGUID *guid, gchar *buff)
gint gnc_numeric_compare(gnc_numeric a, gnc_numeric b)
KvpValue * kvp_value_new_frame_nc(KvpFrame *value)
KvpFrame * kvp_frame_set_value(KvpFrame *frame, const gchar *path, const KvpValue *value)
void kvp_frame_delete(KvpFrame *frame)
void kvp_frame_set_slot_path(KvpFrame *frame, KvpValue *value, const gchar *first_key,...)
gint64 kvp_value_get_gint64(const KvpValue *value)
void gnc_gvalue_free(GValue *value)
Convenience function to release the value in a GValue acquired by kvp_frame_get_gvalue and to free th...
gint timespec_cmp(const Timespec *ta, const Timespec *tb)
char * kvp_value_get_string(const KvpValue *value)
KvpValue * kvp_value_copy(const KvpValue *value)
gboolean guid_equal(const GncGUID *guid_1, const GncGUID *guid_2)
#define GUID_ENCODING_LENGTH
GValue * kvp_frame_get_gvalue(KvpFrame *frame, const gchar *key)
const char ** kvp_frame_get_keys(const KvpFrame *frame)
#define kvp_value_new_gnc_numeric
GList * kvp_value_get_glist(const KvpValue *value)
void kvp_frame_set_numeric(KvpFrame *frame, const gchar *path, gnc_numeric nval)
void kvp_glist_delete(GList *list)
GncGUID * kvp_value_get_guid(const KvpValue *value)
KvpValue * kvp_frame_get_slot_path(KvpFrame *frame, const gchar *first_key,...)
gchar * kvp_frame_to_string(const KvpFrame *frame)
gboolean gnc_numeric_eq(gnc_numeric a, gnc_numeric b)
KvpFrame * kvp_frame_set_value_nc(KvpFrame *frame, const gchar *path, KvpValue *value)
KvpValue * kvp_value_new_glist(const GList *value)
void kvp_frame_set_double(KvpFrame *frame, const gchar *path, double dval)
KvpValue * kvp_value_new_glist_nc(GList *lst)
const GncGUID * guid_null(void)
struct KvpFrameImpl KvpFrame
GDate kvp_value_get_gdate(const KvpValue *value)
KvpFrame * kvp_frame_new(void)
KvpFrame * kvp_value_get_frame(const KvpValue *value)
KvpFrame * kvp_frame_get_frame(const KvpFrame *frame, const gchar *path)
void kvp_value_delete(KvpValue *value)
gint kvp_value_compare(const KvpValue *va, const KvpValue *vb)
gchar * kvp_value_to_string(const KvpValue *val)
Debug version of kvp_value_to_string.
void kvp_frame_set_string(KvpFrame *frame, const gchar *path, const gchar *str)
Store a copy of the string at the indicated path.
struct KvpValueImpl KvpValue
KvpValue * kvp_frame_get_slot_path_gslist(KvpFrame *frame, const GSList *key_path)