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