diff --git a/unit_tests/data/Test_Spikegen.cpp b/unit_tests/data/Test_Spikegen.cpp index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..06f33197d15116466e38df424dfa4a53b5775930 100644 --- a/unit_tests/data/Test_Spikegen.cpp +++ b/unit_tests/data/Test_Spikegen.cpp @@ -0,0 +1,42 @@ +/******************************************************************************** + * Copyright (c) 2025 CEA-List + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * SPDX-License-Identifier: EPL-2.0 + * + ********************************************************************************/ + +#include <cstdint> // std::uint8_t, std::uint16_t, std::int32_t +#include <vector> // std::vector + +#include <catch2/catch_test_macros.hpp> + +#include "aidge/data/Spikegen.hpp" +#include "aidge/data/Tensor.hpp" +#include "aidge/utils/ArrayHelpers.hpp" +#include "aidge/utils/TensorUtils.hpp" + + +namespace Aidge +{ +TEST_CASE("[core/data] SpikeGen zeros", "[SpikeGen]") { + auto input = Tensor(Array1D<float, 3>({0,0,0})); + auto expectedOutput = Tensor(Array2D<float, 3, 3>({{{0,0,0}, {0,0,0}, {0,0,0}}})); + + auto spikes = spikegenRate(std::make_shared<Tensor>(input), 3); + + REQUIRE(approxEq<float>(spikes, expectedOutput)); +} + +TEST_CASE("[core/data] SpikeGen ones", "[SpikeGen]") { + auto input = Tensor(Array1D<float, 3>({1,1,1})); + auto expectedOutput = Tensor(Array2D<float, 3, 3>({{{1,1,1}, {1,1,1}, {1,1,1}}})); + + auto spikes = spikegenRate(std::make_shared<Tensor>(input), 3); + + REQUIRE(approxEq<float>(spikes, expectedOutput)); +} +} // namespace Aidge