// Copyright 2023 Google LLC
//
// 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 <springbok.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>

#include "pw_unit_test/framework.h"
#include "softrvv.h"

namespace softrvv_vmaxu_test {
namespace {

// common to all tests
int32_t src1[] = {1, 2, 3, 4, 5};

// vector test
int32_t src2[] = {5, 4, 3, 2, 1};

// scalar register tests
int32_t rs1[] = {1, 3, 5};

};  // namespace
const int32_t kAVL = sizeof(src1) / sizeof(src1[0]);
int32_t dest[kAVL];

int32_t ref_vv[] = {5, 4, 3, 4, 5};

int32_t ref_vx[3][kAVL] = {{1, 2, 3, 4, 5}, {3, 3, 3, 4, 5}, {5, 5, 5, 5, 5}};

class SoftRvvVmaxuTest : public ::testing::Test {
 protected:
  void SetUp() override { memset(dest, 0, sizeof(dest)); }
};

TEST_F(SoftRvvVmaxuTest, VV) {
  softrvv::vmax_vv<int32_t>(dest, src1, src2, kAVL);
  ASSERT_EQ(memcmp(dest, ref_vv, sizeof(dest)), 0);
}

TEST_F(SoftRvvVmaxuTest, VX) {
  const int32_t num_vx_tests = sizeof(rs1) / sizeof(rs1[0]);
  for (int32_t i = 0; i < num_vx_tests; i++) {
    softrvv::vmax_vx<int32_t>(dest, src1, &rs1[i], kAVL);
    ASSERT_EQ(memcmp(dest, &ref_vx[i], sizeof(dest)), 0);
  }
}

}  // namespace softrvv_vmaxu_test
