// 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.

<%!
import vec_test_helpers
%>\
<%def name="test_opmvv_vred(template_helper, src2, src1, ref_vv)">
<%
src1 = vec_test_helpers.to_carr_str(src1)
src2 = vec_test_helpers.to_carr_str(src2)
ref_vv = vec_test_helpers.to_carr_str(ref_vv)
%>\
namespace softrvv_${template_helper.op_code}_test {
namespace {
${insert_variable_init(template_helper, src2, src1, ref_vv)}

class SoftRvv${template_helper.op_code.capitalize()}Test : public ::testing::Test {
 protected:
  void SetUp() override { memset(dest, 0, sizeof(dest)); }
};
${insert_test(template_helper)}\
}  // namespace
}  // namespace softrvv_${op}_test\
</%def>\

<%def name="insert_variable_init(template_helper, src2, src1, ref_vv)">
<%
  var_types = template_helper.get_var_types()
%>\
${var_types.src1_type} src1[] = {${src1}};
${var_types.src2_type} src2[] = {${src2}};
const int kAVL = sizeof(src1)/sizeof(src1[0]);
${var_types.dest_type} dest[kAVL];

${var_types.dest_type} ref_vv[kAVL] = {${ref_vv}};
</%def>\

<%def name="insert_test(template_helper)">
<%
var_types = template_helper.get_var_types()
datatypes = template_helper.get_softrvv_template_data_type()
%>\
TEST_F(SoftRvv${template_helper.op_code.capitalize()}Test, VS) {
  softrvv::${template_helper.op_code}_vs<${datatypes}>(dest, src2, src1, kAVL);\
  assert_vec_elem_eq<${var_types.dest_type}>(kAVL, dest, ref_vv);
}
</%def>\
