launch_daemon: Empty conditions are now NULL.
* Instead of an empty and-condition.
This commit is contained in:
@@ -105,11 +105,11 @@ private:
|
||||
static Condition*
|
||||
create_condition(const char* name, const BMessage& args)
|
||||
{
|
||||
if (strcmp(name, "and") == 0)
|
||||
if (strcmp(name, "and") == 0 && !args.IsEmpty())
|
||||
return new AndCondition(args);
|
||||
if (strcmp(name, "or") == 0)
|
||||
if (strcmp(name, "or") == 0 && !args.IsEmpty())
|
||||
return new OrCondition(args);
|
||||
if (strcmp(name, "not") == 0)
|
||||
if (strcmp(name, "not") == 0 && !args.IsEmpty())
|
||||
return new NotCondition(args);
|
||||
|
||||
if (strcmp(name, "safemode") == 0)
|
||||
|
||||
@@ -40,6 +40,14 @@ ConditionsTest::~ConditionsTest()
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ConditionsTest::TestEmpty()
|
||||
{
|
||||
Condition* condition = _Condition("");
|
||||
CPPUNIT_ASSERT(condition == NULL);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ConditionsTest::TestSafemode()
|
||||
{
|
||||
@@ -176,6 +184,8 @@ ConditionsTest::AddTests(BTestSuite& parent)
|
||||
{
|
||||
CppUnit::TestSuite& suite = *new CppUnit::TestSuite("ConditionsTest");
|
||||
|
||||
suite.addTest(new CppUnit::TestCaller<ConditionsTest>(
|
||||
"ConditionsTest::TestEmpty", &ConditionsTest::TestEmpty));
|
||||
suite.addTest(new CppUnit::TestCaller<ConditionsTest>(
|
||||
"ConditionsTest::TestSafemode", &ConditionsTest::TestSafemode));
|
||||
suite.addTest(new CppUnit::TestCaller<ConditionsTest>(
|
||||
@@ -210,6 +220,7 @@ ConditionsTest::_Condition(const char* string)
|
||||
CPPUNIT_ASSERT_EQUAL(B_OK, job.FindMessage("if", &message));
|
||||
|
||||
Condition* condition = Conditions::FromMessage(message);
|
||||
CPPUNIT_ASSERT(condition != NULL);
|
||||
if (string[0] != '\0')
|
||||
CPPUNIT_ASSERT(condition != NULL);
|
||||
return condition;
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ public:
|
||||
ConditionsTest();
|
||||
virtual ~ConditionsTest();
|
||||
|
||||
void TestEmpty();
|
||||
void TestSafemode();
|
||||
void TestFileExists();
|
||||
void TestOr();
|
||||
|
||||
Reference in New Issue
Block a user