Please note : This help page is not for the latest version of Enterprise Architect. The latest help can be found here.
Constraint Composition
A Constraint is typically composed using local and member variables in expressions, separated by operators to define one or more specific criteria that must be met. A constraint must evaluate as true to be considered as Passed. If a constraint evaluates as false, it is considered as Failed.
Any variables referenced within the constraint must be in scope at the position where the Testpoint or Breakpoint is evaluated.
General/Arithmetic Operators
Operator |
Description |
Example |
---|---|---|
+ |
Add |
a + b > 0
|
- |
Subtract |
a - b > 0
|
/ |
Divide |
a / b == 2
|
* |
Multiply |
a * b == c
|
% |
Modulus |
a % 2 == 1
|
( ) |
Parentheses - Used to define precedence in complex expressions. |
((a / b) * c) <= 100
|
[ ] |
Square Brackets - Used for accessing Arrays. |
Names[0].Surname == "Smith"
|
. |
Dot operator - Used to access member variables of a class. |
Station.Name == "Flinders"
|
-> |
Alternative notation for the Dot operator. |
Station->Name == "Flinders"
|
Comparison Operators
Operator |
Description |
Example |
---|---|---|
= |
Equal To |
a = b
|
== |
Equal To |
a == b
|
!= |
Not Equal To |
a != b
|
<> |
Not Equal To |
a <> b
|
> |
Greater Than |
a > b
|
>= |
Greater Than or Equal To |
a >= b
|
< |
Less Than |
a < b
|
<= |
Less Than or Equal To |
a <= b
|
Logical Operators
Operator |
Description |
Example |
---|---|---|
AND |
Logical AND |
(a >= 1) AND (a <= 10)
|
OR |
Logical OR |
(a == 1) OR (b == 1)
|
Bitwise Operators
Operator |
Description |
Example |
---|---|---|
& |
Bitwise AND |
(1 & 1) = 1 (1 & 0) = 0
|
| |
Bitwise OR |
(1 | 1) = 1 (1 | 0) = 1
|
^ |
Bitwise XOR (exclusive OR) |
(1 ^ 1) = 0 (1 ^ 0) = 1
|
Additional Examples
Example |
Description |
---|---|
(( m_nValue & 0xFFFF0000) == 0) |
Use a Bitwise AND operator (&) with a hexadecimal value as the right operand to test that no bits are set in high order bytes of the variable.
|
(( m_nValue & 0x0000FFFF) == 0) |
Use a Bitwise AND operator (&) with a hexadecimal value as the right operand to test that no bits are set in low order bytes of the variable.
|
m_value[0][1] = 2 |
Accessing a multi-dimensional array
|
a AND (b OR c) |
Combining AND and OR operators, using parentheses to ensure precedence. In this example, variable 'a' must be true, and either 'b' or 'c' must be true.
|
Notes
• | String comparisons are case-sensitive |
Learn more
Learning Center topics
• | (Alt+F1) | Enterprise Architect | Execution Analysis | Testpoints | About Constraints |