diff options
author | 2015-06-24 10:37:24 -0700 | |
---|---|---|
committer | 2015-06-24 10:37:32 -0700 | |
commit | d782ab69e0cad5e05c565fe1b297566ab5055c96 (patch) | |
tree | af843a59b83209072825e5be9e76a31fac36a867 /src | |
parent | aa6cf7b576eccb03b96cfe1b712f2a7262ea2f69 (diff) |
Added commented unit test
Diffstat (limited to 'src')
-rw-r--r-- | src/core/basetypes/MCIndexSet.cpp | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/src/core/basetypes/MCIndexSet.cpp b/src/core/basetypes/MCIndexSet.cpp index 7f7e1db3..9061c4da 100644 --- a/src/core/basetypes/MCIndexSet.cpp +++ b/src/core/basetypes/MCIndexSet.cpp @@ -435,3 +435,52 @@ INITIALIZE(IndexSet) { Object::registerObjectConstructor("mailcore::IndexSet", &createObject); } + +/* + +Unit test: + +String * uidsStr = MCSTR("129597-129662,129664,129667-129671,129673-129674,129678-129694,129696-129804"); +String * cachedUidsStr = MCSTR("129755-129804"); +IndexSet * uids = NULL; +IndexSet * cachedUids = NULL; + +{ + IndexSet * result = new IndexSet(); + Array * array = uidsStr->componentsSeparatedByString(MCSTR(",")); + mc_foreacharray(String, rangeStr, array) { + Array * rangeArray = rangeStr->componentsSeparatedByString(MCSTR("-")); + if (rangeArray->count() == 2) { + int left = ((String *) rangeArray->objectAtIndex(0))->intValue(); + int right = ((String *) rangeArray->objectAtIndex(1))->intValue(); + int length = right - left; + result->addRange(RangeMake(left, length)); + } + else { + result->addIndex(rangeStr->intValue()); + } + } + //fprintf(stderr, "%s\n", MCUTF8DESC(result)); + uids = result; +} +{ + IndexSet * result = new IndexSet(); + Array * array = cachedUidsStr->componentsSeparatedByString(MCSTR(",")); + mc_foreacharray(String, rangeStr, array) { + Array * rangeArray = rangeStr->componentsSeparatedByString(MCSTR("-")); + if (rangeArray->count() == 2) { + int left = ((String *) rangeArray->objectAtIndex(0))->intValue(); + int right = ((String *) rangeArray->objectAtIndex(1))->intValue(); + int length = right - left; + result->addRange(RangeMake(left, length)); + } + else { + result->addIndex(rangeStr->intValue()); + } + } + cachedUids = result; +} +fprintf(stderr, "|%s|\n", MCUTF8DESC(uids)); +uids->removeIndexSet(cachedUids); +fprintf(stderr, "|%s|\n", MCUTF8DESC(uids)); +*/ |