chromium/third_party/blink/renderer/platform/audio/vector_math_test.cc

// Copyright 2017 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifdef UNSAFE_BUFFERS_BUILD
// TODO(crbug.com/351564777): Remove this and convert code to safer constructs.
#pragma allow_unsafe_buffers
#endif

#include "third_party/blink/renderer/platform/audio/vector_math.h"

#include <cmath>
#include <limits>
#include <numeric>
#include <random>

#include "base/memory/raw_ptr.h"
#include "base/ranges/algorithm.h"
#include "build/build_config.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/blink/renderer/platform/wtf/allocator/allocator.h"
#include "third_party/blink/renderer/platform/wtf/math_extras.h"
#include "third_party/blink/renderer/platform/wtf/vector.h"

namespace blink::vector_math {
namespace {

struct MemoryLayout {};

// This is the minimum aligned needed by AVX on x86 family architectures.
constexpr size_t kMaxBitAlignment =;
constexpr size_t kMaxByteAlignment =;

constexpr size_t kMaxStride =;

constexpr MemoryLayout kMemoryLayouts[] =;
constexpr size_t kMemoryLayoutCount =;

// This is the minimum vector size in bytes needed for MSA instructions on
// MIPS.
constexpr size_t kMaxVectorSizeInBytes =;
constexpr size_t kVectorSizesInBytes[] =;
constexpr size_t kVectorSizeCount =;

// Compare two floats and consider all NaNs to be equal.
bool Equal(float a, float b) {}

// This represents a real source or destination vector which is aligned, can be
// non-contiguous and can be used as a source or destination vector for
// blink::vector_math functions.
template <typename T>
class TestVector {};

// Get primary input vectors with difference memory layout and size
// combinations.
template <typename T>
Vector<TestVector<const T>> GetPrimaryVectors(const T* base) {}

// Get secondary input or output vectors. As the size of a secondary vector
// must always be the same as the size of the primary input vector, there are
// only  two interesting secondary vectors:
//  - A vector with the same memory layout as the primary input vector has and
//    which therefore is aligned whenever the primary input vector is aligned.
//  - A vector with a different memory layout than the primary input vector has
//    and which therefore is not aligned when the primary input vector is
//    aligned.
template <typename T>
Vector<TestVector<T>> GetSecondaryVectors(
    T* base,
    const MemoryLayout* primary_memory_layout,
    size_t size) {}

template <typename T>
Vector<TestVector<T>> GetSecondaryVectors(
    T* base,
    const TestVector<const float>& primary_vector) {}

class VectorMathTest : public testing::Test {};

float VectorMathTest::destinations_[kDestinationCount][kFloatArraySize];
float VectorMathTest::sources_[kSourceCount][kFloatArraySize];

TEST_F(VectorMathTest, Conv) {}

TEST_F(VectorMathTest, Vadd) {}

TEST_F(VectorMathTest, Vsub) {}

TEST_F(VectorMathTest, Vclip) {}

TEST_F(VectorMathTest, Vmaxmgv) {}

TEST_F(VectorMathTest, Vmul) {}

TEST_F(VectorMathTest, Vsma) {}

TEST_F(VectorMathTest, Vsmul) {}

TEST_F(VectorMathTest, Vsadd) {}

TEST_F(VectorMathTest, Vsvesq) {}

TEST_F(VectorMathTest, Zvmul) {}

}  // namespace
}  // namespace blink::vector_math