launch_daemon: Empty conditions are now NULL.

* Instead of an empty and-condition.
This commit is contained in:
Axel Dörfler
2015-07-22 20:45:06 +02:00
parent 95d93d2ea9
commit d54bb194d7
3 changed files with 16 additions and 4 deletions
+3 -3
View File
@@ -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)
+12 -1
View File
@@ -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();