Skip to content

Commit

Permalink
Fixed: Uri always has at least one empty segment
Browse files Browse the repository at this point in the history
  • Loading branch information
skyjake committed Nov 19, 2012
1 parent b0701b2 commit a4cb244
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions doomsday/engine/src/uri.cpp
Expand Up @@ -194,7 +194,12 @@ struct Uri::Instance
segmentCount = 0;
extraSegments.clear();

if(path.isEmpty()) return; // Nothing to do.
if(path.isEmpty())
{
// There always has to be at least one segment.
allocSegment("", "");
return;
}

char const* segBegin = path.utf8CStr();
char const* segEnd = segBegin + path.length() - 1;
Expand Down Expand Up @@ -634,10 +639,18 @@ LIBDENG_DEFINE_UNITTEST(Uri)
{
try
{
// Test emptiness.
{
Uri u;
DENG_ASSERT(u.isEmpty());
DENG_ASSERT(u.segmentCount() == 1);
}

// Test a zero-length path.
{
Uri u("", RC_NULL);
DENG_ASSERT(u.segmentCount() == 0);
DENG_ASSERT(u.isEmpty());
DENG_ASSERT(u.segmentCount() == 1);
}

// Equality and copying.
Expand Down

0 comments on commit a4cb244

Please sign in to comment.