17 lines
618 B
C++
17 lines
618 B
C++
#include "mdspan.hpp"
|
|||
|
|
#include <gtest/gtest.h>
|
||
|
|
|
||
|
|
TEST(Mdspan, MatrixElement) {
|
||
|
|
auto storage = cpp23::make_row_major_matrix(2, 3, 1);
|
||
|
|
const auto matrix = std::mdspan<const int, std::extents<int, std::dynamic_extent, std::dynamic_extent>>(
|
||
|
|
storage.data(), 2, 3);
|
||
|
|
EXPECT_EQ(cpp23::matrix_element(matrix, 1, 2), 1);
|
||
|
|
}
|
||
|
|
|
||
|
|
TEST(Mdspan, RowSums) {
|
||
|
|
std::vector<int> storage = {1, 2, 3, 4, 5, 6};
|
||
|
|
const auto matrix = std::mdspan<const int, std::extents<int, std::dynamic_extent, std::dynamic_extent>>(
|
||
|
|
storage.data(), 2, 3);
|
||
|
|
EXPECT_EQ(cpp23::row_sums(matrix), (std::vector<int>{6, 15}));
|
||
|
|
}
|