49359df and e5204ba to ensure that ValueWithDefault objects can be set to non-default empty strings
| @@ -49,7 +49,7 @@ protected: | |||||
| props.add (new ChoicePropertyComponent (architectureTypeValue, "Architecture", | props.add (new ChoicePropertyComponent (architectureTypeValue, "Architecture", | ||||
| { "<None>", "Native", "32-bit (-m32)", "64-bit (-m64)", "ARM v6", "ARM v7" }, | { "<None>", "Native", "32-bit (-m32)", "64-bit (-m64)", "ARM v6", "ARM v7" }, | ||||
| { "none" , "-march=native", "-m32", "-m64", "-march=armv6", "-march=armv7" }), | |||||
| { { String() }, "-march=native", "-m32", "-m64", "-march=armv6", "-march=armv7" }), | |||||
| "Specifies the 32/64-bit architecture to use."); | "Specifies the 32/64-bit architecture to use."); | ||||
| } | } | ||||
| @@ -70,15 +70,7 @@ protected: | |||||
| return "${JUCE_ARCH_LABEL}"; | return "${JUCE_ARCH_LABEL}"; | ||||
| } | } | ||||
| String getArchitectureTypeString() const | |||||
| { | |||||
| auto archString = architectureTypeValue.get(); | |||||
| if (archString == "none") | |||||
| return {}; | |||||
| return archString; | |||||
| } | |||||
| String getArchitectureTypeString() const { return architectureTypeValue.get(); } | |||||
| //============================================================================== | //============================================================================== | ||||
| ValueWithDefault architectureTypeValue; | ValueWithDefault architectureTypeValue; | ||||
| @@ -52,17 +52,6 @@ public: | |||||
| expectEquals (vwd.get().toString(), String ("default")); | expectEquals (vwd.get().toString(), String ("default")); | ||||
| } | } | ||||
| beginTest ("empty property"); | |||||
| { | |||||
| ValueTree t ("root"); | |||||
| t.setProperty ("testKey", {}, nullptr); | |||||
| ValueWithDefault vwd (t, "testKey", nullptr, "default"); | |||||
| expect (vwd.isUsingDefault()); | |||||
| expectEquals (vwd.get().toString(), String ("default")); | |||||
| } | |||||
| beginTest ("non-empty property"); | beginTest ("non-empty property"); | ||||
| { | { | ||||
| ValueTree t ("root"); | ValueTree t ("root"); | ||||
| @@ -77,7 +66,6 @@ public: | |||||
| beginTest ("set default"); | beginTest ("set default"); | ||||
| { | { | ||||
| ValueTree t ("root"); | ValueTree t ("root"); | ||||
| t.setProperty ("testkey", {}, nullptr); | |||||
| ValueWithDefault vwd (t, "testkey", nullptr); | ValueWithDefault vwd (t, "testkey", nullptr); | ||||
| vwd.setDefault ("default"); | vwd.setDefault ("default"); | ||||
| @@ -121,10 +121,10 @@ public: | |||||
| } | } | ||||
| } | } | ||||
| /** Returns true if the property does not exist or is empty. */ | |||||
| /** Returns true if the property does not exist in the referenced ValueTree. */ | |||||
| bool isUsingDefault() const | bool isUsingDefault() const | ||||
| { | { | ||||
| return ! targetTree.hasProperty (targetProperty) || targetTree.getProperty (targetProperty).toString().isEmpty(); | |||||
| return ! targetTree.hasProperty (targetProperty); | |||||
| } | } | ||||
| /** Removes the property from the referenced ValueTree. */ | /** Removes the property from the referenced ValueTree. */ | ||||