/** * @file model_loader_test.cpp * @brief Model loader class testing. * @kaspersky_support Artiom N. * @date 23.10.2024 * @license Apache 2.0 * @copyright © 2024 AO Kaspersky Lab * * 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 #include #include #include TEST(FrameworkSuite, EmptyModelLoad) { namespace kt = knp::testing; knp::framework::Model model(std::move(knp::framework::Network())); knp::framework::BackendLoader backend_loader; knp::framework::ModelLoader mld(backend_loader.load(knp::testing::get_backend_path()), {}); EXPECT_NO_THROW(mld.load(model)); } TEST(FrameworkSuite, ModelWithIncorrectInputChannel) { namespace kt = knp::testing; auto input_gen = [](knp::core::Step step) -> knp::core::messaging::SpikeData { return {}; }; const knp::core::UID i_channel_uid; knp::framework::Model model(std::move(knp::framework::Network())); kt::BLIFATPopulation population{kt::neuron_generator, 1}; kt::DeltaProjection input_projection = kt::DeltaProjection{knp::core::UID(false), population.get_uid(), kt::synapse_generator, 1}; const auto proj_uid = input_projection.get_uid(); model.get_network().add_population(population); model.get_network().add_projection(input_projection); model.add_input_channel(i_channel_uid, proj_uid); knp::framework::BackendLoader backend_loader; // Incorrect channel UID. knp::framework::ModelLoader mld( backend_loader.load(knp::testing::get_backend_path()), {{knp::core::UID(), input_gen}}); EXPECT_THROW(mld.load(model), std::logic_error); //!OCLINT(False positive) }