/* * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ /** * @file * @brief test file for the BaseTrack class * @author Dominik Meyer * @date 2018-11-21 * @copyright 2018 no yet defined * @test testing conversion fromSimpleToByteArray and fromByteArrayToSimple */ #include #include #include #include #include #include int main() { std::vector testVector; // initialize random number generator std::srand(std::time(nullptr)); int numberRuns=100000; // start with BC::DataTypes::deviceIdType BC::DataTypes::deviceIdType dit = std::rand() % UINT32_MAX; BC::DataTypes::deviceIdType dit2; for(int i=0; i(testVector); if ( dit != dit2 ) { std::cout << "Test failed" << std::endl; return -1; } } // test fromSimpleVectorToByteArray and back std::vector data; std::vector data2; std::vector v; uint32_t nrElements = std::rand() % 100000 +1000; for(uint32_t i=0; i,uint32_t>(v); if (data.size() != data2.size()) { std::cout << "Convert of uint32_t vector failed. Sizes do not match" << std::endl; return -1; } // test if elements are the same if (!std::equal(data.begin(), data.end(), data2.begin())) { std::cout << "Convert of uint32_t vector failed. elements do not match" << std::endl; return -1; } //test vector of string conversion std::vector strings; std::vector strings2; for(uint32_t i=0; i<20; i++) { strings.push_back("hallo"); } v.clear(); v=BC::DataTypes::Convert::fromStringContainerToByteArray(strings); strings2=BC::DataTypes::Convert::fromByteArrayToStringContainer>(v); // test if elements are the same if (!std::equal(strings.begin(), strings.end(), strings2.begin())) { std::cout << "Convert of string vector failed. elements do not match" << std::endl; return -1; } return 0; }