Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
2c3eb5b8
Commit
2c3eb5b8
authored
Sep 07, 2019
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test/TestUriRelative: new unit test
parent
58363cf4
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
53 additions
and
0 deletions
+53
-0
TestUriRelative.cxx
test/TestUriRelative.cxx
+52
-0
meson.build
test/meson.build
+1
-0
No files found.
test/TestUriRelative.cxx
0 → 100644
View file @
2c3eb5b8
/*
* Unit tests for src/util/UriRelative.hxx
*/
#include "util/UriRelative.hxx"
#include <gtest/gtest.h>
TEST
(
UriRelative
,
IsChild
)
{
static
constexpr
struct
{
const
char
*
parent
;
const
char
*
child
;
bool
is_child
;
bool
is_child_or_same
;
}
tests
[]
=
{
{
"/foo"
,
"/foo"
,
false
,
true
},
{
"/foo"
,
"/foo/bar"
,
true
,
true
},
{
"/foo/"
,
"/foo/bar"
,
true
,
true
},
{
"/foo/"
,
"/foo/"
,
false
,
true
},
{
"/foo/"
,
"/foo"
,
false
,
false
},
{
"/bar"
,
"/foo"
,
false
,
false
},
{
"/foo"
,
"/foobar"
,
false
,
false
},
};
for
(
const
auto
&
i
:
tests
)
{
EXPECT_EQ
(
uri_is_child
(
i
.
parent
,
i
.
child
),
i
.
is_child
);
EXPECT_EQ
(
uri_is_child_or_same
(
i
.
parent
,
i
.
child
),
i
.
is_child_or_same
);
}
}
TEST
(
UriRelative
,
ApplyBase
)
{
static
constexpr
struct
{
const
char
*
uri
;
const
char
*
base
;
const
char
*
result
;
}
tests
[]
=
{
{
"foo"
,
"bar"
,
"bar/foo"
},
{
"foo"
,
"/bar"
,
"/bar/foo"
},
{
"/foo"
,
"/bar"
,
"/foo"
},
{
"/foo"
,
"bar"
,
"/foo"
},
{
"/foo"
,
"http://localhost/bar"
,
"http://localhost/foo"
},
{
"/foo"
,
"http://localhost/"
,
"http://localhost/foo"
},
{
"/foo"
,
"http://localhost"
,
"http://localhost/foo"
},
};
for
(
const
auto
&
i
:
tests
)
{
EXPECT_STREQ
(
uri_apply_base
(
i
.
uri
,
i
.
base
).
c_str
(),
i
.
result
);
}
}
test/meson.build
View file @
2c3eb5b8
...
...
@@ -39,6 +39,7 @@ test('TestUtil', executable(
'TestSplitString.cxx',
'TestUriExtract.cxx',
'TestUriQueryParser.cxx',
'TestUriRelative.cxx',
'TestUriUtil.cxx',
'test_byte_reverse.cxx',
include_directories: inc,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment