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
a32d8b76
Commit
a32d8b76
authored
Apr 15, 2015
by
miloyip
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add SIMD SkipWhitespace() unit test which don't run in Valgrind
parent
fa32ec89
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
62 additions
and
1 deletion
+62
-1
CMakeLists.txt
test/unittest/CMakeLists.txt
+3
-1
simdtest.cpp
test/unittest/simdtest.cpp
+59
-0
No files found.
test/unittest/CMakeLists.txt
View file @
a32d8b76
...
@@ -10,6 +10,7 @@ set(UNITTEST_SOURCES
...
@@ -10,6 +10,7 @@ set(UNITTEST_SOURCES
namespacetest.cpp
namespacetest.cpp
prettywritertest.cpp
prettywritertest.cpp
readertest.cpp
readertest.cpp
simdtest.cpp
stringbuffertest.cpp
stringbuffertest.cpp
strtodtest.cpp
strtodtest.cpp
unittest.cpp
unittest.cpp
...
@@ -36,8 +37,9 @@ add_test(NAME unittest
...
@@ -36,8 +37,9 @@ add_test(NAME unittest
WORKING_DIRECTORY
${
CMAKE_SOURCE_DIR
}
/bin
)
WORKING_DIRECTORY
${
CMAKE_SOURCE_DIR
}
/bin
)
if
(
NOT MSVC
)
if
(
NOT MSVC
)
# Not running SIMD.* unit test cases for Valgrind
add_test
(
NAME valgrind_unittest
add_test
(
NAME valgrind_unittest
COMMAND valgrind --leak-check=full --error-exitcode=1
${
CMAKE_RUNTIME_OUTPUT_DIRECTORY
}
/unittest
COMMAND valgrind --leak-check=full --error-exitcode=1
${
CMAKE_RUNTIME_OUTPUT_DIRECTORY
}
/unittest
--gtest_filter=-SIMD.*
WORKING_DIRECTORY
${
CMAKE_SOURCE_DIR
}
/bin
)
WORKING_DIRECTORY
${
CMAKE_SOURCE_DIR
}
/bin
)
if
(
CMAKE_BUILD_TYPE STREQUAL
"Debug"
)
if
(
CMAKE_BUILD_TYPE STREQUAL
"Debug"
)
...
...
test/unittest/simdtest.cpp
0 → 100644
View file @
a32d8b76
// Copyright (C) 2011 Milo Yip
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
// Since Travis CI installs old Valgrind 3.7.0, which fails with some SSE4.2
// The unit tests prefix with SIMD should be skipped by Valgrind test
// __SSE2__ and __SSE4_2__ are recognized by gcc, clang, and the Intel compiler.
// We use -march=native with gmake to enable -msse2 and -msse4.2, if supported.
#if defined(__SSE4_2__)
# define RAPIDJSON_SSE42
#elif defined(__SSE2__)
# define RAPIDJSON_SSE2
#endif
#include "unittest.h"
#include "rapidjson/reader.h"
using
namespace
rapidjson
;
#ifdef RAPIDJSON_SSE2
#define SIMD_SUFFIX(name) name##_SSE2
#elif defined(RAPIDJSON_SSE42)
#define SIMD_SUFFIX(name) name##_SSE42
#else
#define SIMD_SUFFIX(name) name
#endif
TEST
(
SIMD
,
SIMD_SUFFIX
(
SkipWhitespace
))
{
char
buffer
[
258
];
for
(
size_t
i
=
0
;
i
<
256
;
i
++
)
buffer
[
i
]
=
"
\t\r\n
"
[
i
%
4
];
buffer
[
256
]
=
'X'
;
buffer
[
257
]
=
'\0'
;
// Try to start from different position, to test different memory alignments
for
(
size_t
i
=
0
;
i
<
256
;
i
++
)
{
StringStream
s
(
buffer
+
i
);
SkipWhitespace
(
s
);
EXPECT_EQ
(
'X'
,
s
.
Peek
());
}
}
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