@@ -451,6 +451,155 @@ SCENARIO(
451
451
}
452
452
}
453
453
}
454
+ GIVEN (" adding a value-set of intervals and constants with a constant" )
455
+ {
456
+ auto interval12 = constant_interval_exprt (val1, val2);
457
+ auto interval23 = constant_interval_exprt (val2, val3);
458
+ auto interval34 = constant_interval_exprt (val3, val4);
459
+ auto interval45 = constant_interval_exprt (val4, val5);
460
+
461
+ WHEN (" { [1,2] } + 2" )
462
+ {
463
+ auto op1 = make_value_set (interval12, environment, ns);
464
+ auto op2 = make_constant (val2, environment, ns);
465
+ auto result = add_as_value_set (op1, op2, environment, ns);
466
+
467
+ THEN (" = { [3,4] }" )
468
+ {
469
+ EXPECT (result, {interval34});
470
+ }
471
+ }
472
+ WHEN (" { [1,2], 3 } + 2" )
473
+ {
474
+ auto op1 = make_value_set ({interval12, val3}, environment, ns);
475
+ auto op2 = make_constant (val2, environment, ns);
476
+ auto result = add_as_value_set (op1, op2, environment, ns);
477
+
478
+ THEN (" = { [3,4], 5 }" )
479
+ {
480
+ EXPECT (result, {interval34, val5});
481
+ }
482
+ }
483
+ WHEN (" { [1,2], [2,3] } + 2" )
484
+ {
485
+ auto op1 = make_value_set ({interval12, interval23}, environment, ns);
486
+ auto op2 = make_constant (val2, environment, ns);
487
+ auto result = add_as_value_set (op1, op2, environment, ns);
488
+
489
+ THEN (" = { [3,4], [4,5] }" )
490
+ {
491
+ EXPECT (result, {interval34, interval45});
492
+ }
493
+ }
494
+ }
495
+ GIVEN (" adding a value-set of intervals and constants with an interval" )
496
+ {
497
+ auto interval12 = constant_interval_exprt (val1, val2);
498
+ auto interval23 = constant_interval_exprt (val2, val3);
499
+ auto interval34 = constant_interval_exprt (val3, val4);
500
+ auto interval45 = constant_interval_exprt (val4, val5);
501
+ auto interval24 = constant_interval_exprt (val2, val4);
502
+ auto interval35 = constant_interval_exprt (val3, val5);
503
+
504
+ WHEN (" { [1,2] } + [1,2]" )
505
+ {
506
+ auto op1 = make_value_set (interval12, environment, ns);
507
+ auto op2 = make_interval (interval12, environment, ns);
508
+ auto result = add_as_value_set (op1, op2, environment, ns);
509
+
510
+ THEN (" = { [2,4] }" )
511
+ {
512
+ EXPECT (result, {interval24});
513
+ }
514
+ }
515
+ WHEN (" { [1,2], 1 } + [1,2]" )
516
+ {
517
+ auto op1 = make_value_set ({interval12, val1}, environment, ns);
518
+ auto op2 = make_interval (interval12, environment, ns);
519
+ auto result = add_as_value_set (op1, op2, environment, ns);
520
+
521
+ THEN (" = { [2,4], [2,3] }" )
522
+ {
523
+ EXPECT (result, {interval24, interval23});
524
+ }
525
+ }
526
+ WHEN (" { [1,2], [2,3] } + [1,2]" )
527
+ {
528
+ auto op1 = make_value_set ({interval12, interval23}, environment, ns);
529
+ auto op2 = make_interval (interval12, environment, ns);
530
+ auto result = add_as_value_set (op1, op2, environment, ns);
531
+
532
+ THEN (" = { [2,4], [3,5] }" )
533
+ {
534
+ EXPECT (result, {interval24, interval35});
535
+ }
536
+ }
537
+ }
538
+ GIVEN (" adding a value-set of intervals and constants with a value-set" )
539
+ {
540
+ auto interval12 = constant_interval_exprt (val1, val2);
541
+ auto interval23 = constant_interval_exprt (val2, val3);
542
+ auto interval34 = constant_interval_exprt (val3, val4);
543
+ auto interval45 = constant_interval_exprt (val4, val5);
544
+ auto interval24 = constant_interval_exprt (val2, val4);
545
+ auto interval35 = constant_interval_exprt (val3, val5);
546
+
547
+ WHEN (" { [1,2] } + { 1, 2 }" )
548
+ {
549
+ auto op1 = make_value_set (interval12, environment, ns);
550
+ auto op2 = make_value_set ({val1, val2}, environment, ns);
551
+ auto result = add_as_value_set (op1, op2, environment, ns);
552
+
553
+ THEN (" = { [2,3], [3,4] }" )
554
+ {
555
+ EXPECT (result, {interval23, interval34});
556
+ }
557
+ }
558
+ WHEN (" { [1,2] } + { [1,2] }" )
559
+ {
560
+ auto op1 = make_value_set (interval12, environment, ns);
561
+ auto op2 = make_value_set (interval12, environment, ns);
562
+ auto result = add_as_value_set (op1, op2, environment, ns);
563
+
564
+ THEN (" = { [2,4] }" )
565
+ {
566
+ EXPECT (result, {interval24});
567
+ }
568
+ }
569
+ WHEN (" { [1,2], 1 } + { [1,2] }" )
570
+ {
571
+ auto op1 = make_value_set ({interval12, val1}, environment, ns);
572
+ auto op2 = make_value_set (interval12, environment, ns);
573
+ auto result = add_as_value_set (op1, op2, environment, ns);
574
+
575
+ THEN (" = { [2,4], [2,3] }" )
576
+ {
577
+ EXPECT (result, {interval24, interval23});
578
+ }
579
+ }
580
+ WHEN (" { [1,2], [2,3] } + { [1,2] }" )
581
+ {
582
+ auto op1 = make_value_set ({interval12, interval23}, environment, ns);
583
+ auto op2 = make_interval (interval12, environment, ns);
584
+ auto result = add_as_value_set (op1, op2, environment, ns);
585
+
586
+ THEN (" = { [2,4], [3,5] }" )
587
+ {
588
+ EXPECT (result, {interval24, interval35});
589
+ }
590
+ }
591
+ WHEN (" { [1,2], 1 } + { [1,2], 1 }" )
592
+ {
593
+ auto op1 = make_value_set ({interval12, val1}, environment, ns);
594
+ auto op2 = make_value_set ({interval12, val1}, environment, ns);
595
+ auto result = add_as_value_set (op1, op2, environment, ns);
596
+
597
+ THEN (" = { [2,4], [2,3], [2,3], 2 }" )
598
+ { // duplicate interval ok as first pass. Will be eliminated in due course.
599
+ EXPECT (result, {interval24, interval23, interval23, val2});
600
+ }
601
+ }
602
+ }
454
603
GIVEN (" multiple operands" )
455
604
{
456
605
WHEN (" { 1, 2, 3 } + 1 + 1" )
0 commit comments