@@ -411,67 +411,22 @@ void main() {
411411 expect (read.flexObject, isNull);
412412 });
413413
414- test ('put and get string value' , () {
415- final entity = FlexValueEntity (flexDynamic: 'hello world' );
416- final id = box.put (entity);
417-
418- final read = box.get (id)! ;
419- expect (read.flexDynamic, 'hello world' );
420- });
421-
422- test ('put and get int value' , () {
423- final entity = FlexValueEntity (flexDynamic: 42 );
424- final id = box.put (entity);
425-
426- final read = box.get (id)! ;
427- expect (read.flexDynamic, 42 );
428- });
429-
430- test ('put and get double value' , () {
431- final entity = FlexValueEntity (flexDynamic: 3.14159 );
432- final id = box.put (entity);
433-
434- final read = box.get (id)! ;
435- expect (read.flexDynamic, closeTo (3.14159 , 0.00001 ));
436- });
437-
438- test ('put and get bool value' , () {
439- final entity = FlexValueEntity (flexDynamic: true );
440- final id = box.put (entity);
441-
442- final read = box.get (id)! ;
443- expect (read.flexDynamic, true );
444- });
445-
446- test ('put and get list value' , () {
447- final entity = FlexValueEntity (flexDynamic: [1 , 'two' , 3.0 ]);
448- final id = box.put (entity);
449-
450- final read = box.get (id)! ;
451- expect (read.flexDynamic, isA <List >());
452- expect ((read.flexDynamic as List )[0 ], 1 );
453- expect ((read.flexDynamic as List )[1 ], 'two' );
454- expect ((read.flexDynamic as List )[2 ], 3.0 );
455- });
456-
457- test ('put and get map value' , () {
458- final entity = FlexValueEntity (
459- flexDynamic: {'key' : 'value' , 'number' : 42 },
460- );
461- final id = box.put (entity);
462-
463- final read = box.get (id)! ;
464- expect (read.flexDynamic, isA <Map >());
465- expect ((read.flexDynamic as Map )['key' ], 'value' );
466- expect ((read.flexDynamic as Map )['number' ], 42 );
467- });
468-
469- test ('Object? works the same as dynamic' , () {
470- final entity = FlexValueEntity (flexObject: 'test string' );
471- final id = box.put (entity);
414+ test ('put and get value with various types' , () {
415+ assertPutAndGet <V >(V value) {
416+ final entity = FlexValueEntity (flexDynamic: value, flexObject: value);
417+ final id = box.put (entity);
418+
419+ final read = box.get (id)! ;
420+ expect (read.flexDynamic, value);
421+ expect (read.flexObject, value);
422+ }
472423
473- final read = box.get (id)! ;
474- expect (read.flexObject, 'test string' );
424+ assertPutAndGet ('hello world' );
425+ assertPutAndGet (42 );
426+ assertPutAndGet (3.14159 );
427+ assertPutAndGet (true );
428+ assertPutAndGet ([1 , 'two' , 3.0 ]);
429+ assertPutAndGet ({'key' : 'value' , 'number' : 42 , 'nullable' : null });
475430 });
476431
477432 test ('update value type' , () {
0 commit comments