/**************************************************************************** * Copyright (C) from 2009 to Present EPAM Systems. * * This file is part of Indigo toolkit. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. ***************************************************************************/ #include #include #include #include #include #include #include using namespace indigo_cpp; namespace { constexpr int THREAD_COUNT = 16; constexpr const std::array choices = {"C", "CC", "CCC", "CCCC", "CCCCC", "CCCCCC"}; thread_local std::random_device rd; thread_local std::mt19937 rng(rd()); thread_local std::uniform_int_distribution uni(0, 5); std::string randomSmiles() { return choices.at(uni(rng)); } void testRender() { const auto& smiles = randomSmiles(); auto session_1 = IndigoSession::create(); auto session_2 = IndigoSession::create(); const auto& renderer_1 = IndigoRenderer(session_1); const auto& renderer_2 = IndigoRenderer(session_2); session_1->setOption("render-svg-unique-id", false); session_2->setOption("render-svg-unique-id", false); const auto& m_1 = session_1->loadMolecule(smiles); const auto& m_2 = session_2->loadMolecule(smiles); const auto& result_svg_1 = renderer_1.svg(m_1); const auto& result_svg_2 = renderer_2.svg(m_2); ASSERT_EQ(result_svg_1, result_svg_2); const auto& result_png_1 = renderer_1.png(m_1); const auto& result_png_2 = renderer_2.png(m_2); ASSERT_EQ(result_png_1, result_png_2); } } // namespace TEST(RenderingThreads, Basic) { std::vector threads; threads.reserve(THREAD_COUNT); for (auto i = 0; i < THREAD_COUNT; i++) { threads.emplace_back(testRender); } for (auto& thread : threads) { thread.join(); } }