summaryrefslogtreecommitdiff
path: root/test/test.cpp
diff options
context:
space:
mode:
authorJörg Frings-Fürst <debian@jff-webhsoting.net>2015-10-07 16:32:36 +0200
committerJörg Frings-Fürst <debian@jff-webhsoting.net>2015-10-07 16:32:36 +0200
commitd4ba486cc6aacbbed2be1e71ea77410052a22ac1 (patch)
treeae4dcb499fb8011cb8ab5c889f28c4859aa3dfc2 /test/test.cpp
parent37e3bea32e9078168cd2622dcc976d7d10739088 (diff)
Imported Upstream version 0.8.3upstream/0.8.3
Diffstat (limited to 'test/test.cpp')
-rw-r--r--test/test.cpp22
1 files changed, 18 insertions, 4 deletions
diff --git a/test/test.cpp b/test/test.cpp
index 777f233..670aa07 100644
--- a/test/test.cpp
+++ b/test/test.cpp
@@ -1786,22 +1786,29 @@ Rule | Example | hostSet | absPath | emptySeg
testEqualsHelper("//host:123");
}
- void testCompareRangeHelper(const char * a, const char * b, int expected) {
+ void testCompareRangeHelper(const char * a, const char * b, int expected, bool avoidNullRange = true) {
UriTextRangeA ra;
UriTextRangeA rb;
if (a) {
ra.first = a;
ra.afterLast = a + strlen(a);
+ } else {
+ ra.first = NULL;
+ ra.afterLast = NULL;
}
+
if (b) {
rb.first = b;
rb.afterLast = b + strlen(b);
+ } else {
+ rb.first = NULL;
+ rb.afterLast = NULL;
}
const int received = uriCompareRangeA(
- (a == NULL) ? NULL : &ra,
- (b == NULL) ? NULL : &rb);
+ ((a == NULL) && avoidNullRange) ? NULL : &ra,
+ ((b == NULL) && avoidNullRange) ? NULL : &rb);
if (received != expected) {
printf("Comparing <%s> to <%s> yields %d, expected %d.\n",
a, b, received, expected);
@@ -1825,11 +1832,18 @@ Rule | Example | hostSet | absPath | emptySeg
testCompareRangeHelper(NULL, "a", -1);
testCompareRangeHelper("a", NULL, 1);
testCompareRangeHelper(NULL, NULL, 0);
+
+ // Fixed with 0.8.3
+ const bool KEEP_NULL_RANGE = false;
+ const bool AVOID_NULL_RANGE = true;
+ testCompareRangeHelper(NULL, "", -1, AVOID_NULL_RANGE);
+ testCompareRangeHelper(NULL, "", -1, KEEP_NULL_RANGE);
+ testCompareRangeHelper("", NULL, 1, AVOID_NULL_RANGE);
+ testCompareRangeHelper("", NULL, 1, KEEP_NULL_RANGE);
}
};
-
int main() {
Suite suite;
suite.add(auto_ptr<Suite>(new UriSuite()));