Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
R
rapidjson
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
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
rapidjson
Commits
af17f196
Commit
af17f196
authored
Dec 10, 2018
by
ylavic
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Unit test for Pointer::operator<().
parent
055f1fa6
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
67 additions
and
0 deletions
+67
-0
pointertest.cpp
test/unittest/pointertest.cpp
+67
-0
No files found.
test/unittest/pointertest.cpp
View file @
af17f196
...
...
@@ -15,7 +15,9 @@
#include "unittest.h"
#include "rapidjson/pointer.h"
#include "rapidjson/stringbuffer.h"
#include "rapidjson/ostreamwrapper.h"
#include <sstream>
#include <set>
using
namespace
rapidjson
;
...
...
@@ -1493,6 +1495,71 @@ TEST(Pointer, Ambiguity) {
}
}
TEST
(
Pointer
,
LessThan
)
{
static
const
char
*
pointers
[]
=
{
"/a/b"
,
"/a/c"
,
"/a"
,
"/d/1"
,
"/d/2/z"
,
"/d/2/3"
,
"/d/2"
,
"/d/2/zz"
,
"/d/1"
,
"/d/2/z"
,
"/e/f~g"
,
"/e/f~0g"
,
"/e/f~1g"
,
"/e/f~~g"
,
"#/e/f%2fg"
,
"/e/f.g"
,
""
};
static
struct
{
const
char
*
string
;
bool
valid
;
}
ordered_pointers
[]
=
{
{
""
,
true
},
{
"/a"
,
true
},
{
"/a/b"
,
true
},
{
"/a/c"
,
true
},
{
"/d/1"
,
true
},
{
"/d/1"
,
true
},
{
"/d/2"
,
true
},
{
"/d/2/3"
,
true
},
{
"/d/2/z"
,
true
},
{
"/d/2/z"
,
true
},
{
"/d/2/zz"
,
true
},
{
"/e/f.g"
,
true
},
{
"/e/f~1g"
,
true
},
{
"/e/f~1g"
,
true
},
// was "#/e/f%2fg"
{
"/e/f~0g"
,
true
},
{
"/e/f~g"
,
false
},
{
"/e/f~~g"
,
false
}
};
MemoryPoolAllocator
<>
allocator
;
typedef
GenericPointer
<
Value
,
MemoryPoolAllocator
<>
>
PooledPointer
;
std
::
multiset
<
PooledPointer
>
set
;
size_t
i
;
for
(
i
=
0
;
i
<
sizeof
(
pointers
)
/
sizeof
(
*
pointers
);
++
i
)
{
set
.
insert
(
PooledPointer
(
pointers
[
i
],
&
allocator
));
}
i
=
0
;
for
(
std
::
set
<
PooledPointer
>::
iterator
it
=
set
.
begin
();
it
!=
set
.
end
();
++
it
)
{
EXPECT_TRUE
(
i
<
sizeof
(
ordered_pointers
)
/
sizeof
(
*
ordered_pointers
));
EXPECT_EQ
(
it
->
IsValid
(),
ordered_pointers
[
i
].
valid
);
if
(
it
->
IsValid
())
{
std
::
stringstream
ss
;
OStreamWrapper
os
(
ss
);
EXPECT_TRUE
(
it
->
Stringify
(
os
));
EXPECT_EQ
(
ss
.
str
(),
ordered_pointers
[
i
].
string
);
}
i
++
;
}
}
// https://github.com/Tencent/rapidjson/issues/483
namespace
myjson
{
...
...
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