30 #if defined(unix) || defined(__unix__) || defined(__unix) 32 #ifdef _POSIX_MAPPED_FILES 37 class Platform :
public PerfTest {
39 virtual void SetUp() {
43 temp_ = (
char *)malloc(length_ + 1);
44 memcpy(temp_, json_, length_);
45 checkSum_ = CheckSum();
50 for (
size_t i = 0; i < length_; ++i)
55 virtual void TearDown() {
65 TEST_F(Platform, CheckSum) {
66 for (
int i = 0; i < kTrialCount; i++)
67 EXPECT_EQ(checkSum_, CheckSum());
71 for (
int i = 0; i < kTrialCount; i++) {
72 size_t l = strlen(json_);
73 EXPECT_EQ(length_, l);
78 for (
int i = 0; i < kTrialCount; i++) {
79 EXPECT_EQ(0, memcmp(temp_, json_, length_));
85 for (
int i = 0; i < kTrialCount * kTrialCount; i++)
86 sum += pow(10.0, i & 255);
90 TEST_F(Platform, Whitespace_strlen) {
91 for (
int i = 0; i < kTrialCount; i++) {
92 size_t l = strlen(whitespace_);
93 EXPECT_GT(l, whitespace_length_);
97 TEST_F(Platform, Whitespace_strspn) {
98 for (
int i = 0; i < kTrialCount; i++) {
99 size_t l = strspn(whitespace_,
" \n\r\t");
100 EXPECT_EQ(whitespace_length_, l);
105 for (
int i = 0; i < kTrialCount; i++) {
106 FILE *fp = fopen(filename_,
"rb");
107 ASSERT_EQ(length_, fread(temp_, 1, length_, fp));
108 EXPECT_EQ(checkSum_, CheckSum());
115 for (
int i = 0; i < kTrialCount; i++) {
116 int fd = _open(filename_, _O_BINARY | _O_RDONLY);
118 ASSERT_EQ(length_, _read(fd, temp_, length_));
119 EXPECT_EQ(checkSum_, CheckSum());
125 for (
int i = 0; i < kTrialCount; i++) {
126 int fd = open(filename_, O_RDONLY);
128 ASSERT_EQ(length_, read(fd, temp_, length_));
129 EXPECT_EQ(checkSum_, CheckSum());
136 TEST_F(Platform, MapViewOfFile) {
137 for (
int i = 0; i < kTrialCount; i++) {
138 HANDLE file = CreateFile(filename_, GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
139 ASSERT_NE(INVALID_HANDLE_VALUE, file);
140 HANDLE mapObject = CreateFileMapping(file, NULL, PAGE_READONLY, 0, length_, NULL);
141 ASSERT_NE(INVALID_HANDLE_VALUE, mapObject);
142 void *p = MapViewOfFile(mapObject, FILE_MAP_READ, 0, 0, length_);
143 ASSERT_TRUE(p != NULL);
144 EXPECT_EQ(checkSum_, CheckSum());
145 ASSERT_TRUE(UnmapViewOfFile(p) == TRUE);
146 ASSERT_TRUE(CloseHandle(mapObject) == TRUE);
147 ASSERT_TRUE(CloseHandle(file) == TRUE);
152 #ifdef _POSIX_MAPPED_FILES 154 for (
int i = 0; i < kTrialCount; i++) {
155 int fd = open(filename_, O_RDONLY);
157 void *p = mmap(NULL, length_, PROT_READ, MAP_PRIVATE, fd, 0);
158 ASSERT_TRUE(p != NULL);
159 EXPECT_EQ(checkSum_, CheckSum());
166 #endif // TEST_PLATFORM
TEST_F(RapidJson, SIMD_SUFFIX(ReaderParseInsitu_DummyHandler))