31#include <gtest/gtest.h>
44using std::numeric_limits;
57 in = std::get<0>(GetParam());
67 make_tuple(0, 0, 0), make_tuple(0, 10, 0), make_tuple(10, 0, 10),
68 make_tuple(10, 10, 10), make_tuple(10, 1, 10), make_tuple(10, 2, 10),
69 make_tuple(10, 3, 9), make_tuple(10, 4, 8), make_tuple(10, 5, 10),
70 make_tuple(10, 6, 6), make_tuple(10, 7, 7), make_tuple(10, 8, 8),
71 make_tuple(10, 9, 9), make_tuple(10, 11, 0), make_tuple(10, 12, 0),
77 ASSERT_EQ(
roundDown(in, multiple), expected);
81class RoundUpTest :
public ::testing::TestWithParam<RoundUpType> {
85 in = std::get<0>(GetParam());
95 make_tuple(0, 0, 0), make_tuple(0, 10, 0), make_tuple(10, 0, 10),
96 make_tuple(10, 10, 10), make_tuple(10, 1, 10), make_tuple(10, 2, 10),
97 make_tuple(10, 3, 12), make_tuple(10, 4, 12), make_tuple(10, 5, 10),
98 make_tuple(10, 6, 12), make_tuple(10, 7, 14), make_tuple(10, 8, 16),
99 make_tuple(10, 9, 18), make_tuple(10, 11, 11), make_tuple(10, 12, 12),
108 :
public ::testing::TestWithParam<roundUpDivisionSafeType> {
112 in = std::get<0>(GetParam());
113 divider = std::get<1>(GetParam());
122 make_tuple(0, 10, 0),
123 make_tuple(10, 10, 1),
124 make_tuple(10, 1, 10),
125 make_tuple(10, 2, 5),
126 make_tuple(10, 3, 4),
127 make_tuple(10, 4, 3),
128 make_tuple(10, 5, 2),
129 make_tuple(10, 6, 2),
130 make_tuple(10, 7, 2),
131 make_tuple(10, 8, 2),
132 make_tuple(10, 9, 2),
135 make_tuple(numeric_limits<uint64_t>::max() - 1, 1,
136 numeric_limits<uint64_t>::max() - 1),
137 make_tuple(numeric_limits<uint64_t>::max(), 1,
138 numeric_limits<uint64_t>::max()),
139 make_tuple(0, numeric_limits<uint64_t>::max() - 1, 0),
140 make_tuple(1, numeric_limits<uint64_t>::max() - 1, 1),
141 make_tuple(numeric_limits<uint64_t>::max() - 1,
142 numeric_limits<uint64_t>::max() - 1, 1),
143 make_tuple(numeric_limits<uint64_t>::max(),
144 numeric_limits<uint64_t>::max() - 1, 2),
145 make_tuple(0, numeric_limits<uint64_t>::max(), 0),
146 make_tuple(1, numeric_limits<uint64_t>::max(), 1),
147 make_tuple(numeric_limits<uint64_t>::max() - 1,
148 numeric_limits<uint64_t>::max(), 1),
149 make_tuple(numeric_limits<uint64_t>::max(), numeric_limits<uint64_t>::max(),
164 value = std::get<0>(GetParam());
172 ::testing::Combine(::testing::Range(0, 32),
173 ::testing::Range(0, 32)));
179class IsInTest :
public ::testing::TestWithParam<IsInType> {
183 in = std::get<0>(GetParam());
192 make_tuple(
"foo",
true), make_tuple(
"foo2",
true),
193 make_tuple(
"bar",
true), make_tuple(
"baz",
true),
194 make_tuple(
"foo1",
false), make_tuple(
"bar2",
false),
195 make_tuple(
"baz-1",
false), make_tuple(
"quz",
false),
200 ASSERT_EQ(
isIn(in, {
"foo",
"foo2",
"bar",
"baz"}), expected);
208 in = std::get<0>(GetParam());
209 out = std::get<1>(GetParam());
217#define STR "fo2o 3,24 b5a#r"
218 make_tuple(
"foo",
"foo"),
221 make_tuple(
"\t" STR,
STR),
222 make_tuple(
" \t " STR,
STR),
224 make_tuple(
STR "\t",
STR),
225 make_tuple(
STR " \t ",
STR),
226 make_tuple(
" " STR " ",
STR),
227 make_tuple(
"\t" STR "\t",
STR),
228 make_tuple(
" \t " STR " \t ",
STR),
230 make_tuple(
" \t",
""),
231 make_tuple(
" \t ",
""),
232 make_tuple(
"\t ",
""),
244 in = std::get<0>(GetParam());
245 sep = std::get<1>(GetParam());
246 out = std::get<2>(GetParam());
254 make_tuple(
"",
' ', vector<string>({})),
255 make_tuple(
" ",
' ', vector<string>({})),
256 make_tuple(
" ini mi,ni moe ",
' ',
257 vector<string>({
"ini",
"mi,ni",
"moe"})),
258 make_tuple(
" 412, 542,732 , ",
',',
259 vector<string>({
" 412",
" 542",
"732 ",
" "})),
260 make_tuple(
"\0 412, 542,732 , ",
',', vector<string>({})),
261 make_tuple(
" 412, 542\0,732 , ",
',', vector<string>({
" 412",
" 542"})),
268 ASSERT_EQ(split.size(), out.size());
269 ASSERT_TRUE(std::equal(split.begin(), split.end(), out.begin()));
274 auto s = std::make_unique<int>(0);
278 auto s = std::make_unique<int>(314);
291 height = std::get<3>(GetParam());
326 testing::Combine(testing::Range(1, 4, 1),
327 testing::Range(1, 4, 1),
328 testing::Range(1, 4, 1),
329 testing::Range(1, 4, 1)));
void copyPixels(std::byte *destPtr, int dstPitch, const std::byte *srcPtr, int srcPitch, int rowSize, int height)
constexpr uint64_t RAWSPEED_READNONE roundUpDivisionSafe(uint64_t value, uint64_t div)
std::string trimSpaces(std::string_view str)
constexpr uint64_t RAWSPEED_READNONE roundDown(uint64_t value, uint64_t multiple)
bool RAWSPEED_READONLY isIn(const T value, const std::initializer_list< T2 > &list)
constexpr RAWSPEED_READNONE bool isAligned(T value, size_t multiple)
std::vector< std::string > splitString(const std::string &input, char c=' ')
INSTANTIATE_TEST_SUITE_P(MD5Test, MD5Test, ::testing::ValuesIn(testCases))
TEST_P(MD5Test, CheckTestCaseSet)
constexpr uint64_t RAWSPEED_READNONE roundUp(uint64_t value, uint64_t multiple)
assert(dim.area() >=area)
static constexpr uint8_t newVal
static constexpr uint8_t origVal
SplitStringTest()=default
roundUpDivisionSafeTest()=default
std::tuple< uint64_t, uint64_t, uint64_t > RoundDownType
std::tuple< uint64_t, uint64_t, uint64_t > roundUpDivisionSafeType
TEST(MakeUniqueTest, Test)
std::tuple< uint64_t, uint64_t, uint64_t > RoundUpType
std::tuple< string, string > TrimSpacesType
std::tuple< int, int > IsAlignedType
const RoundUpType RoundUpValues[]
const IsInType IsInValues[]
std::tuple< string, char, vector< string > > splitStringType
const roundUpDivisionSafeType roundUpDivisionSafeValues[]
std::tuple< int, int, int, int > copyPixelsType
const splitStringType splitStringValues[]
const RoundDownType RoundDownValues[]
const TrimSpacesType TrimSpacesValues[]
std::tuple< string, bool > IsInType
constexpr uint64_t RAWSPEED_READNONE roundUpDivisionSafe(uint64_t value, uint64_t div)
constexpr uint64_t RAWSPEED_READNONE roundUp(uint64_t value, uint64_t multiple)
std::string trimSpaces(std::string_view str)
void copyPixels(std::byte *destPtr, int dstPitch, const std::byte *srcPtr, int srcPitch, int rowSize, int height)
constexpr uint64_t RAWSPEED_READNONE roundDown(uint64_t value, uint64_t multiple)
constexpr bool RAWSPEED_READNONE isPowerOfTwo(T val)
bool RAWSPEED_READONLY isIn(const T value, const std::initializer_list< T2 > &list)
constexpr RAWSPEED_READNONE bool isAligned(T value, size_t multiple)
std::vector< std::string > splitString(const std::string &input, char c=' ')