Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d68121f6 authored by Tom Cherry's avatar Tom Cherry Committed by Gerrit Code Review
Browse files

Merge "init: always allow clearing a property"

parents 792fb8e2 20965588
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -29,6 +29,11 @@ namespace android {
namespace init {

bool CheckType(const std::string& type_string, const std::string& value) {
    // Always allow clearing a property such that the default value when it is not set takes over.
    if (value.empty()) {
        return true;
    }

    auto type_strings = Split(type_string, " ");
    if (type_strings.empty()) {
        return false;
+5 −5
Original line number Diff line number Diff line
@@ -32,7 +32,7 @@ TEST(property_type, CheckType_string) {
}

TEST(property_type, CheckType_int) {
    EXPECT_FALSE(CheckType("int", ""));
    EXPECT_TRUE(CheckType("int", ""));
    EXPECT_FALSE(CheckType("int", "abc"));
    EXPECT_FALSE(CheckType("int", "-abc"));
    EXPECT_TRUE(CheckType("int", "0"));
@@ -43,7 +43,7 @@ TEST(property_type, CheckType_int) {
}

TEST(property_type, CheckType_uint) {
    EXPECT_FALSE(CheckType("uint", ""));
    EXPECT_TRUE(CheckType("uint", ""));
    EXPECT_FALSE(CheckType("uint", "abc"));
    EXPECT_FALSE(CheckType("uint", "-abc"));
    EXPECT_TRUE(CheckType("uint", "0"));
@@ -53,7 +53,7 @@ TEST(property_type, CheckType_uint) {
}

TEST(property_type, CheckType_double) {
    EXPECT_FALSE(CheckType("double", ""));
    EXPECT_TRUE(CheckType("double", ""));
    EXPECT_FALSE(CheckType("double", "abc"));
    EXPECT_FALSE(CheckType("double", "-abc"));
    EXPECT_TRUE(CheckType("double", "0.0"));
@@ -64,7 +64,7 @@ TEST(property_type, CheckType_double) {
}

TEST(property_type, CheckType_size) {
    EXPECT_FALSE(CheckType("size", ""));
    EXPECT_TRUE(CheckType("size", ""));
    EXPECT_FALSE(CheckType("size", "ab"));
    EXPECT_FALSE(CheckType("size", "abcd"));
    EXPECT_FALSE(CheckType("size", "0"));
@@ -80,7 +80,7 @@ TEST(property_type, CheckType_size) {
}

TEST(property_type, CheckType_enum) {
    EXPECT_FALSE(CheckType("enum abc", ""));
    EXPECT_TRUE(CheckType("enum abc", ""));
    EXPECT_FALSE(CheckType("enum abc", "ab"));
    EXPECT_FALSE(CheckType("enum abc", "abcd"));
    EXPECT_FALSE(CheckType("enum 123 456 789", "0"));