@@ -451,3 +451,37 @@ TEST(IntegerRelationTest, mergeAndAlignCommonSuffixSymbols) {
451
451
EXPECT_EQ (otherSpace.getId (VarKind::Range, 1 ),
452
452
Identifier (&otherIdentifiers[3 ]));
453
453
}
454
+
455
+ TEST (IntegerRelationTest, setId) {
456
+ IntegerRelation rel = parseRelationFromSet (
457
+ " (x, y, z)[A, B, C, D] : (x + A - C - y + D - z >= 0)" , 2 );
458
+ PresburgerSpace space = PresburgerSpace::getRelationSpace (2 , 1 , 4 , 0 );
459
+ space.resetIds ();
460
+
461
+ // Attach identifiers.
462
+ int identifiers[7 ] = {' x' , ' y' , ' z' , ' A' , ' B' , ' C' , ' D' };
463
+ space.getId (VarKind::Domain, 0 ) = Identifier (&identifiers[0 ]);
464
+ space.getId (VarKind::Domain, 1 ) = Identifier (&identifiers[1 ]);
465
+ space.getId (VarKind::Range, 0 ) = Identifier (&identifiers[2 ]);
466
+ space.getId (VarKind::Symbol, 0 ) = Identifier (&identifiers[3 ]);
467
+ space.getId (VarKind::Symbol, 1 ) = Identifier (&identifiers[4 ]);
468
+ space.getId (VarKind::Symbol, 2 ) = Identifier (&identifiers[5 ]);
469
+ space.getId (VarKind::Symbol, 3 ) = Identifier (&identifiers[6 ]);
470
+ rel.setSpace (space);
471
+
472
+ int newIdentifiers[3 ] = {1 , 2 , 3 };
473
+ rel.setId (VarKind::Domain, 1 , Identifier (&newIdentifiers[0 ]));
474
+ rel.setId (VarKind::Range, 0 , Identifier (&newIdentifiers[1 ]));
475
+ rel.setId (VarKind::Symbol, 2 , Identifier (&newIdentifiers[2 ]));
476
+
477
+ space = rel.getSpace ();
478
+ // Check that new identifiers are set correctly.
479
+ EXPECT_EQ (space.getId (VarKind::Domain, 1 ), Identifier (&newIdentifiers[0 ]));
480
+ EXPECT_EQ (space.getId (VarKind::Range, 0 ), Identifier (&newIdentifiers[1 ]));
481
+ EXPECT_EQ (space.getId (VarKind::Symbol, 2 ), Identifier (&newIdentifiers[2 ]));
482
+ // Check that old identifier are not changed.
483
+ EXPECT_EQ (space.getId (VarKind::Domain, 0 ), Identifier (&identifiers[0 ]));
484
+ EXPECT_EQ (space.getId (VarKind::Symbol, 0 ), Identifier (&identifiers[3 ]));
485
+ EXPECT_EQ (space.getId (VarKind::Symbol, 1 ), Identifier (&identifiers[4 ]));
486
+ EXPECT_EQ (space.getId (VarKind::Symbol, 3 ), Identifier (&identifiers[6 ]));
487
+ }
0 commit comments