// 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 <stdio.h>
#include <stdlib.h>

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

namespace softrvv_vwsubu_test {
namespace {

uint16_t src1[] = {3, 4, 6, 8, 10};
uint16_t src2[] = {1, 2, 3, 4, 5};
uint16_t rs1 = 3;
const uint32_t AVL_CONST = sizeof(src1)/sizeof(src1[0]);
uint32_t dest[AVL_CONST];

uint32_t ref_vv[] = {2, 2, 3, 4, 5};
uint32_t ref_vx[] = {0, 1, 3, 5, 7};

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

TEST_F(SoftRvvVwsubuTest, VV) {
  softrvv::vwsub_vv<uint32_t, uint16_t>(dest, src1, src2, AVL_CONST);
  ASSERT_EQ(memcmp(dest, ref_vv, sizeof(dest)), 0);
}

TEST_F(SoftRvvVwsubuTest, VX) {
  softrvv::vwsub_vx<uint32_t, uint16_t>(dest, src1, &rs1, AVL_CONST);
  ASSERT_EQ(memcmp(dest, ref_vx, sizeof(dest)), 0);
}

}  // namespace
}  // namespace softrvv_vwsubu_test
