Repository: celix Updated Branches: refs/heads/develop ffbe2271e -> ea11a7851
CELIX-410: Fixed doubling of spaces and tabs when loading properties. Extended unit test for properties. Project: http://git-wip-us.apache.org/repos/asf/celix/repo Commit: http://git-wip-us.apache.org/repos/asf/celix/commit/ea11a785 Tree: http://git-wip-us.apache.org/repos/asf/celix/tree/ea11a785 Diff: http://git-wip-us.apache.org/repos/asf/celix/diff/ea11a785 Branch: refs/heads/develop Commit: ea11a7851482b4ae3ecde10a3684fc2f05ea2a3d Parents: ffbe227 Author: gricciardi <[email protected]> Authored: Fri Jun 16 12:39:01 2017 +0200 Committer: gricciardi <[email protected]> Committed: Fri Jun 16 12:39:01 2017 +0200 ---------------------------------------------------------------------- utils/private/resources-test/properties.txt | 10 ++++++++-- utils/private/src/properties.c | 4 ---- utils/private/test/properties_test.cpp | 14 ++++++++++---- 3 files changed, 18 insertions(+), 10 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/celix/blob/ea11a785/utils/private/resources-test/properties.txt ---------------------------------------------------------------------- diff --git a/utils/private/resources-test/properties.txt b/utils/private/resources-test/properties.txt index 30f3c79..116aebb 100644 --- a/utils/private/resources-test/properties.txt +++ b/utils/private/resources-test/properties.txt @@ -14,7 +14,13 @@ # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. + +# Simple case a=b -b=c +# Simple case, but with members nicely separated +nice_a = nice_b +# Case with value containing 2 spaces and one tab +b=c d + // == \\ # 5 \0 \= - #line to check possible special characters \ No newline at end of file + #line to check possible special characters http://git-wip-us.apache.org/repos/asf/celix/blob/ea11a785/utils/private/src/properties.c ---------------------------------------------------------------------- diff --git a/utils/private/src/properties.c b/utils/private/src/properties.c index c162711..0bd6dc3 100644 --- a/utils/private/src/properties.c +++ b/utils/private/src/properties.c @@ -232,10 +232,6 @@ static void parseLine(const char* line, properties_pt props) { linePos += 1; continue; } - else { - output[outputPos++] = line[linePos]; - updateBuffers(&key, &value, &output, outputPos, &key_len, &value_len); - } } else { if (output == NULL) { http://git-wip-us.apache.org/repos/asf/celix/blob/ea11a785/utils/private/test/properties_test.cpp ---------------------------------------------------------------------- diff --git a/utils/private/test/properties_test.cpp b/utils/private/test/properties_test.cpp index 3124fe7..6dfb3ba 100644 --- a/utils/private/test/properties_test.cpp +++ b/utils/private/test/properties_test.cpp @@ -61,13 +61,19 @@ TEST(properties, create) { TEST(properties, load) { char propertiesFile[] = "resources-test/properties.txt"; properties = properties_load(propertiesFile); - LONGS_EQUAL(3, hashMap_size(properties)); + LONGS_EQUAL(4, hashMap_size(properties)); const char keyA[] = "a"; const char *valueA = properties_get(properties, keyA); STRCMP_EQUAL("b", valueA); + + const char keyNiceA[] = "nice_a"; + const char *valueNiceA = properties_get(properties, keyNiceA); + STRCMP_EQUAL("nice_b", valueNiceA); + const char keyB[] = "b"; - STRCMP_EQUAL("c", properties_get(properties, keyB)); + const char *valueB = properties_get(properties, keyB); + STRCMP_EQUAL("c \t d", valueB); properties_destroy(properties); } @@ -90,7 +96,7 @@ TEST(properties, copy) { properties_pt copy; char propertiesFile[] = "resources-test/properties.txt"; properties = properties_load(propertiesFile); - LONGS_EQUAL(3, hashMap_size(properties)); + LONGS_EQUAL(4, hashMap_size(properties)); properties_copy(properties, ©); @@ -98,7 +104,7 @@ TEST(properties, copy) { const char *valueA = properties_get(copy, keyA); STRCMP_EQUAL("b", valueA); const char keyB[] = "b"; - STRCMP_EQUAL("c", properties_get(copy, keyB)); + STRCMP_EQUAL("c \t d", properties_get(copy, keyB)); properties_destroy(properties); properties_destroy(copy);
