2024-07-28 16:08:37 +08:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <test/includes.hpp>
|
|
|
|
|
|
|
|
namespace test {
|
|
|
|
namespace ndarray_basic {
|
|
|
|
void test_calc_size_from_shape_normal() {
|
|
|
|
// Test shapes with normal values
|
|
|
|
BEGIN_TEST();
|
|
|
|
|
2024-08-07 15:13:53 +08:00
|
|
|
int64_t shape[4] = {2, 3, 5, 7};
|
2024-07-28 16:08:37 +08:00
|
|
|
assert_values_match(
|
2024-08-07 15:13:53 +08:00
|
|
|
210L, ndarray::basic::util::calc_size_from_shape<int64_t>(4, shape));
|
2024-07-28 16:08:37 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void test_calc_size_from_shape_has_zero() {
|
|
|
|
// Test shapes with 0 in them
|
|
|
|
BEGIN_TEST();
|
|
|
|
|
2024-08-07 15:13:53 +08:00
|
|
|
int64_t shape[4] = {2, 0, 5, 7};
|
2024-07-28 16:08:37 +08:00
|
|
|
assert_values_match(
|
2024-08-07 15:13:53 +08:00
|
|
|
0L, ndarray::basic::util::calc_size_from_shape<int64_t>(4, shape));
|
2024-07-28 16:08:37 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void run() {
|
|
|
|
test_calc_size_from_shape_normal();
|
|
|
|
test_calc_size_from_shape_has_zero();
|
|
|
|
}
|
|
|
|
} // namespace ndarray_basic
|
|
|
|
} // namespace test
|