X-Git-Url: http://plrg.eecs.uci.edu/git/?a=blobdiff_plain;f=folly%2Ftest%2FGroupVarintTest.cpp;h=b224674d78ebce8397d520281d9a89cdcb0d95f6;hb=520e20a8baebc98a5ec84d67865da4cf9819f88a;hp=cdc693bca77e439d4e68ddc24eff6bab349a705e;hpb=27494a20393fa45072e7d526d358835f3abe312a;p=folly.git diff --git a/folly/test/GroupVarintTest.cpp b/folly/test/GroupVarintTest.cpp index cdc693bc..b224674d 100644 --- a/folly/test/GroupVarintTest.cpp +++ b/folly/test/GroupVarintTest.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2012 Facebook, Inc. + * Copyright 2017 Facebook, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,10 +14,15 @@ * limitations under the License. */ -#include -#include "folly/GroupVarint.h" +#include -#include +#include +#include + +// On platforms where it's not supported, GroupVarint will be compiled out. +#if HAVE_GROUP_VARINT + +#include using namespace folly; @@ -35,8 +40,6 @@ class StringAppender { typedef GroupVarintEncoder GroupVarint32Encoder; typedef GroupVarintEncoder GroupVarint64Encoder; -typedef GroupVarintDecoder GroupVarint32Decoder; -typedef GroupVarintDecoder GroupVarint64Decoder; // Expected bytes follow, terminate with -1 void testGroupVarint32(uint32_t a, uint32_t b, uint32_t c, uint32_t d, ...) { @@ -53,7 +56,10 @@ void testGroupVarint32(uint32_t a, uint32_t b, uint32_t c, uint32_t d, ...) { EXPECT_EQ(expectedBytes.size(), size); std::vector foundBytes; - foundBytes.resize(size + 4); + + // ssse3 decoding requires that the source buffer have length >= 17, + // so that it can read 128 bits from &start[1] via _mm_loadu_si128. + foundBytes.resize(std::max(size + 4, 17UL)); char* start = &(foundBytes.front()); char* p = GroupVarint32::encode(start, a, b, c, d); EXPECT_EQ((void*)(start + size), (void*)p); @@ -259,3 +265,4 @@ TEST(GroupVarint, GroupVarintDecoder) { } } +#endif