2 * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
4 * Contact: Kyungwook Tak <k.tak@samsung.com>
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License
18 * @file test_common.cpp
19 * @author Zofia Abramowska (z.abramowska@samsung.com)
23 #include <test_common.h>
30 RawBuffer createDefaultPass()
32 return createPass(0, RAW_PASS_SIZE);
35 RawBuffer createPass(std::size_t from, std::size_t to)
39 for (std::size_t i = from; i < to; i++)
40 raw.push_back(static_cast<unsigned char>(i));
45 RawBuffer createBigBlob(std::size_t size)
47 return createPass(0, size);
50 RawBuffer createRandom(std::size_t size)
52 static unsigned int seed = ::time(nullptr);
54 RawBuffer buf(size, 0x00);
55 for (size_t i = 0; i < size; ++i)
56 buf[i] = static_cast<RawBuffer::value_type>(::rand_r(&seed) % 256);
61 //raw to hex string conversion from SqlConnection
62 std::string rawToHexString(const RawBuffer &raw)
68 snprintf(buf, sizeof(buf), "%02x", (e & 0xff));
69 dump.push_back(buf[0]);
70 dump.push_back(buf[1]);