@@ -55,6 +55,7 @@ class MockPropertiesReader : public PropertiesReader {
55
55
d_map[" i_42" ] = bdld::Datum::createInteger (42 );
56
56
d_map[" i64_42" ] = bdld::Datum::createInteger64 (42 , allocator);
57
57
d_map[" s_foo" ] = bdld::Datum::createStringRef (" foo" , allocator);
58
+ d_map[" exists" ] = bdld::Datum::createInteger (42 );
58
59
}
59
60
// Destroy this object.
60
61
@@ -520,6 +521,18 @@ static void test3_evaluation()
520
521
{" i_0 != -9223372036854775807" , true }, // -(2 ** 63) + 1
521
522
{" i_0 != 9223372036854775807" , true }, // 2 ** 63 - 1
522
523
{" i_0 != -9223372036854775808" , true }, // -(2 ** 63)
524
+
525
+ // exists
526
+ // Note that we allow to set a message property with name `exists`.
527
+ // In this case the usage context defines whether it's a function call
528
+ // or a property value.
529
+ {" exists(i_42)" , true },
530
+ {" exists(non_existing_property)" , false },
531
+ {" !exists(non_existing_property) || non_existing_property > 41" , true },
532
+ {" exists(i_42) && i_42 > 41" , true },
533
+ {" exists(non_existing_property) && non_existing_property > 41" , false },
534
+ {" exists == 42" , true },
535
+ {" exists(exists)" , true },
523
536
};
524
537
const TestParameters* testParametersEnd = testParameters +
525
538
sizeof (testParameters) /
0 commit comments