// Copyright 2017-2020 The Verible Authors.
//
// 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 "verilog/CST/numbers.h"

#include <sstream>
#include <utility>

#include "absl/strings/string_view.h"
#include "gtest/gtest.h"

namespace verilog {
namespace analysis {
namespace {

struct BasedNumberTestCase {
  absl::string_view base;
  absl::string_view digits;
  BasedNumber expected;
};

// Tests that BasedNumber literals are parsed correctly.
TEST(BasedNumberTest, ParseLiteral) {
  const BasedNumberTestCase test_cases[] = {
      {"\'b", "1", {'b', false, "1"}},
      {"\'b", "1101", {'b', false, "1101"}},
      {"\'b", "_1_1_0_1_", {'b', false, "1101"}},
      {"\'sb", "1100_0011", {'b', true, "11000011"}},
      {"\'b", "1101", {'b', false, "1101"}},
      {"\'b", "xz01", {'b', false, "xz01"}},
      {"\'B", "0", {'b', false, "0"}},
      {"\'sB", "1", {'b', true, "1"}},
      {"\'SB", "0_0", {'b', true, "00"}},
      {"\'d", "12", {'d', false, "12"}},
      {"\'D", "12", {'d', false, "12"}},
      {"\'o", "66", {'o', false, "66"}},
      {"\'O", "44", {'o', false, "44"}},
      {"\'sO", "44", {'o', true, "44"}},
      {"\'h", "F00D", {'h', false, "F00D"}},
      {"\'H", "FEED_face", {'h', false, "FEEDface"}},
      {"\'sh", "ADee", {'h', true, "ADee"}},
  };
  for (const auto& test : test_cases) {
    const BasedNumber actual(test.base, test.digits);
    EXPECT_TRUE(actual.ok);
    EXPECT_EQ(test.expected, actual);
  }
}

// Tests that invalid inputs are marked as not OK.
TEST(BasedNumberTest, ParseInvalidLiterals) {
  const std::pair<absl::string_view, absl::string_view> test_cases[] = {
      {"", ""},
      {"xx", ""},
      {"", "96"},
      {"1'b", "1"},  // valid literals start with '
  };
  for (const auto& test : test_cases) {
    const BasedNumber actual(test.first, test.second);
    EXPECT_FALSE(actual.ok);
  }
}

// Tests that human-readable representation of BasedNumber looks right.
TEST(BasedNumberTest, PrintString) {
  const BasedNumber test({'b', false, "1"});
  std::ostringstream stream;
  stream << test;
  EXPECT_EQ(stream.str(), "base:b signed:0 literal:1");
}

// Tests an invalid BasedNumber is printed as such.
TEST(BasedNumberTest, PrintStringInvalid) {
  const BasedNumber test("xx", "");
  std::ostringstream stream;
  stream << test;
  EXPECT_EQ(stream.str(), "<invalid>");
}

}  // namespace
}  // namespace analysis
}  // namespace verilog
