// Copyright (C) 2018-2024 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//

#include "openvino/op/bitwise_or.hpp"

#include <gtest/gtest.h>

#include "bitwise.hpp"

using namespace ov;

namespace reference_tests {
namespace BitwiseOpsRefTestDefinitions {
namespace {

std::vector<RefBitwiseParams> generateBitwiseParams() {
    std::vector<RefBitwiseParams> bitwiseParams{
        Builder{}
            .opType(BitwiseTypes::BITWISE_OR)
            .inputs({{{2, 2}, element::boolean, std::vector<char>{true, false, true, false}},
                     {{2, 2}, element::boolean, std::vector<char>{true, false, false, true}}})
            .expected({{2, 2}, element::boolean, std::vector<char>{true, false, true, true}}),
        Builder{}
            .opType(BitwiseTypes::BITWISE_OR)
            .inputs(
                {{{3, 5},
                  element::u8,
                  std::vector<
                      uint8_t>{0xff, 0xff, 0xff, 0xff, 0xff, 0x0, 0x0, 0x0, 0x0, 0x1, 0x1, 0x1, 0x8, 0x8, 0xbf}},
                 {{3, 5},
                  element::u8,
                  std::vector<
                      uint8_t>{0x0, 0x1, 0x8, 0xbf, 0x3f, 0x1, 0x8, 0xbf, 0x3f, 0x8, 0xbf, 0x3f, 0xbf, 0x3f, 0x3f}}})
            .expected(
                {{3, 5},
                 element::u8,
                 std::vector<
                     uint8_t>{0xff, 0xff, 0xff, 0xff, 0xff, 0x1, 0x8, 0xbf, 0x3f, 0x9, 0xbf, 0x3f, 0xbf, 0x3f, 0xbf}}),
        Builder{}
            .opType(BitwiseTypes::BITWISE_OR)
            .inputs({{{3, 5},
                      element::u16,
                      std::vector<uint16_t>{0xffff,
                                            0xffff,
                                            0xffff,
                                            0xffff,
                                            0xffff,
                                            0x0,
                                            0x0,
                                            0x0,
                                            0x0,
                                            0x1,
                                            0x1,
                                            0x1,
                                            0x8,
                                            0x8,
                                            0xbfff}},
                     {{3, 5},
                      element::u16,
                      std::vector<uint16_t>{0x0,
                                            0x1,
                                            0x8,
                                            0xbfff,
                                            0x3fff,
                                            0x1,
                                            0x8,
                                            0xbfff,
                                            0x3fff,
                                            0x8,
                                            0xbfff,
                                            0x3fff,
                                            0xbfff,
                                            0x3fff,
                                            0x3fff}}})
            .expected({{3, 5},
                       element::u16,
                       std::vector<uint16_t>{0xffff,
                                             0xffff,
                                             0xffff,
                                             0xffff,
                                             0xffff,
                                             0x1,
                                             0x8,
                                             0xbfff,
                                             0x3fff,
                                             0x9,
                                             0xbfff,
                                             0x3fff,
                                             0xbfff,
                                             0x3fff,
                                             0xbfff}}),
        Builder{}
            .opType(BitwiseTypes::BITWISE_OR)
            .inputs({{{3, 5},
                      element::u32,
                      std::vector<uint32_t>{0xffffffff,
                                            0xffffffff,
                                            0xffffffff,
                                            0xffffffff,
                                            0xffffffff,
                                            0x0,
                                            0x0,
                                            0x0,
                                            0x0,
                                            0x1,
                                            0x1,
                                            0x1,
                                            0x8,
                                            0x8,
                                            0xbfffffff}},
                     {{3, 5},
                      element::u32,
                      std::vector<uint32_t>{0x0,
                                            0x1,
                                            0x8,
                                            0xbfffffff,
                                            0x3fffffff,
                                            0x1,
                                            0x8,
                                            0xbfffffff,
                                            0x3fffffff,
                                            0x8,
                                            0xbfffffff,
                                            0x3fffffff,
                                            0xbfffffff,
                                            0x3fffffff,
                                            0x3fffffff}}})
            .expected({{3, 5},
                       element::u32,
                       std::vector<uint32_t>{0xffffffff,
                                             0xffffffff,
                                             0xffffffff,
                                             0xffffffff,
                                             0xffffffff,
                                             0x1,
                                             0x8,
                                             0xbfffffff,
                                             0x3fffffff,
                                             0x9,
                                             0xbfffffff,
                                             0x3fffffff,
                                             0xbfffffff,
                                             0x3fffffff,
                                             0xbfffffff}}),
        Builder{}
            .opType(BitwiseTypes::BITWISE_OR)
            .inputs({{{3, 5},
                      element::u64,
                      std::vector<uint64_t>{0x0,
                                            0x0,
                                            0x0,
                                            0x0,
                                            0x0,
                                            0x1,
                                            0x1,
                                            0x1,
                                            0x1,
                                            0x4000000000000000,
                                            0x4000000000000000,
                                            0x4000000000000000,
                                            0xc000000000000000,
                                            0xc000000000000000,
                                            0xffffffffffffffff}},
                     {{3, 5},
                      element::u64,
                      std::vector<uint64_t>{0x1,
                                            0x4000000000000000,
                                            0xc000000000000000,
                                            0xffffffffffffffff,
                                            0x8,
                                            0x4000000000000000,
                                            0xc000000000000000,
                                            0xffffffffffffffff,
                                            0x8,
                                            0xc000000000000000,
                                            0xffffffffffffffff,
                                            0x8,
                                            0xffffffffffffffff,
                                            0x8,
                                            0x8}}})
            .expected({{3, 5},
                       element::u64,
                       std::vector<uint64_t>{0x1,
                                             0x4000000000000000,
                                             0xc000000000000000,
                                             0xffffffffffffffff,
                                             0x8,
                                             0x4000000000000001,
                                             0xc000000000000001,
                                             0xffffffffffffffff,
                                             0x9,
                                             0xc000000000000000,
                                             0xffffffffffffffff,
                                             0x4000000000000008,
                                             0xffffffffffffffff,
                                             0xc000000000000008,
                                             0xffffffffffffffff}}),
        Builder{}
            .opType(BitwiseTypes::BITWISE_OR)
            .inputs(
                {{{3, 5},
                  element::i8,
                  std::vector<
                      uint8_t>{0xff, 0xff, 0xff, 0xff, 0xff, 0x0, 0x0, 0x0, 0x0, 0x1, 0x1, 0x1, 0x8, 0x8, 0xbf}},
                 {{3, 5},
                  element::i8,
                  std::vector<
                      uint8_t>{0x0, 0x1, 0x8, 0xbf, 0x3f, 0x1, 0x8, 0xbf, 0x3f, 0x8, 0xbf, 0x3f, 0xbf, 0x3f, 0x3f}}})
            .expected(
                {{3, 5},
                 element::i8,
                 std::vector<
                     uint8_t>{0xff, 0xff, 0xff, 0xff, 0xff, 0x1, 0x8, 0xbf, 0x3f, 0x9, 0xbf, 0x3f, 0xbf, 0x3f, 0xbf}}),
        Builder{}
            .opType(BitwiseTypes::BITWISE_OR)
            .inputs({{{3, 5},
                      element::i16,
                      std::vector<uint16_t>{0xffff,
                                            0xffff,
                                            0xffff,
                                            0xffff,
                                            0xffff,
                                            0x0,
                                            0x0,
                                            0x0,
                                            0x0,
                                            0x1,
                                            0x1,
                                            0x1,
                                            0x8,
                                            0x8,
                                            0xbfff}},
                     {{3, 5},
                      element::i16,
                      std::vector<uint16_t>{0x0,
                                            0x1,
                                            0x8,
                                            0xbfff,
                                            0x3fff,
                                            0x1,
                                            0x8,
                                            0xbfff,
                                            0x3fff,
                                            0x8,
                                            0xbfff,
                                            0x3fff,
                                            0xbfff,
                                            0x3fff,
                                            0x3fff}}})
            .expected({{3, 5},
                       element::i16,
                       std::vector<uint16_t>{0xffff,
                                             0xffff,
                                             0xffff,
                                             0xffff,
                                             0xffff,
                                             0x1,
                                             0x8,
                                             0xbfff,
                                             0x3fff,
                                             0x9,
                                             0xbfff,
                                             0x3fff,
                                             0xbfff,
                                             0x3fff,
                                             0xbfff}}),
        Builder{}
            .opType(BitwiseTypes::BITWISE_OR)
            .inputs({{{3, 5},
                      element::i32,
                      std::vector<uint32_t>{0xffffffff,
                                            0xffffffff,
                                            0xffffffff,
                                            0xffffffff,
                                            0xffffffff,
                                            0x0,
                                            0x0,
                                            0x0,
                                            0x0,
                                            0x1,
                                            0x1,
                                            0x1,
                                            0x8,
                                            0x8,
                                            0xbfffffff}},
                     {{3, 5},
                      element::i32,
                      std::vector<uint32_t>{0x0,
                                            0x1,
                                            0x8,
                                            0xbfffffff,
                                            0x3fffffff,
                                            0x1,
                                            0x8,
                                            0xbfffffff,
                                            0x3fffffff,
                                            0x8,
                                            0xbfffffff,
                                            0x3fffffff,
                                            0xbfffffff,
                                            0x3fffffff,
                                            0x3fffffff}}})
            .expected({{3, 5},
                       element::i32,
                       std::vector<uint32_t>{0xffffffff,
                                             0xffffffff,
                                             0xffffffff,
                                             0xffffffff,
                                             0xffffffff,
                                             0x1,
                                             0x8,
                                             0xbfffffff,
                                             0x3fffffff,
                                             0x9,
                                             0xbfffffff,
                                             0x3fffffff,
                                             0xbfffffff,
                                             0x3fffffff,
                                             0xbfffffff}}),
        Builder{}
            .opType(BitwiseTypes::BITWISE_OR)
            .inputs({{{3, 5},
                      element::i64,
                      std::vector<uint64_t>{0x0,
                                            0x0,
                                            0x0,
                                            0x0,
                                            0x0,
                                            0x1,
                                            0x1,
                                            0x1,
                                            0x1,
                                            0x4000000000000000,
                                            0x4000000000000000,
                                            0x4000000000000000,
                                            0xc000000000000000,
                                            0xc000000000000000,
                                            0xffffffffffffffff}},
                     {{3, 5},
                      element::i64,
                      std::vector<uint64_t>{0x1,
                                            0x4000000000000000,
                                            0xc000000000000000,
                                            0xffffffffffffffff,
                                            0x8,
                                            0x4000000000000000,
                                            0xc000000000000000,
                                            0xffffffffffffffff,
                                            0x8,
                                            0xc000000000000000,
                                            0xffffffffffffffff,
                                            0x8,
                                            0xffffffffffffffff,
                                            0x8,
                                            0x8}}})
            .expected({{3, 5},
                       element::i64,
                       std::vector<uint64_t>{0x1,
                                             0x4000000000000000,
                                             0xc000000000000000,
                                             0xffffffffffffffff,
                                             0x8,
                                             0x4000000000000001,
                                             0xc000000000000001,
                                             0xffffffffffffffff,
                                             0x9,
                                             0xc000000000000000,
                                             0xffffffffffffffff,
                                             0x4000000000000008,
                                             0xffffffffffffffff,
                                             0xc000000000000008,
                                             0xffffffffffffffff}}),
    };
    return bitwiseParams;
}

INSTANTIATE_TEST_SUITE_P(smoke_BitwiseAnd_With_Hardcoded_Refs,
                         ReferenceBitwiseLayerTest,
                         ::testing::ValuesIn(generateBitwiseParams()),
                         ReferenceBitwiseLayerTest::getTestCaseName);

}  // namespace
}  // namespace BitwiseOpsRefTestDefinitions
}  // namespace reference_tests
