1cb93a386Sopenharmony_ci// Copyright 2020 The Tint Authors.
2cb93a386Sopenharmony_ci//
3cb93a386Sopenharmony_ci// Licensed under the Apache License, Version 2.0 (the "License");
4cb93a386Sopenharmony_ci// you may not use this file except in compliance with the License.
5cb93a386Sopenharmony_ci// You may obtain a copy of the License at
6cb93a386Sopenharmony_ci//
7cb93a386Sopenharmony_ci//     http://www.apache.org/licenses/LICENSE-2.0
8cb93a386Sopenharmony_ci//
9cb93a386Sopenharmony_ci// Unless required by applicable law or agreed to in writing, software
10cb93a386Sopenharmony_ci// distributed under the License is distributed on an "AS IS" BASIS,
11cb93a386Sopenharmony_ci// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12cb93a386Sopenharmony_ci// See the License for the specific language governing permissions and
13cb93a386Sopenharmony_ci// limitations under the License.
14cb93a386Sopenharmony_ci
15cb93a386Sopenharmony_ci#include "src/symbol.h"
16cb93a386Sopenharmony_ci
17cb93a386Sopenharmony_ci#include "gtest/gtest.h"
18cb93a386Sopenharmony_ci
19cb93a386Sopenharmony_cinamespace tint {
20cb93a386Sopenharmony_cinamespace {
21cb93a386Sopenharmony_ci
22cb93a386Sopenharmony_ciusing SymbolTest = testing::Test;
23cb93a386Sopenharmony_ci
24cb93a386Sopenharmony_ciTEST_F(SymbolTest, ToStr) {
25cb93a386Sopenharmony_ci  Symbol sym(1, ProgramID::New());
26cb93a386Sopenharmony_ci  EXPECT_EQ("$1", sym.to_str());
27cb93a386Sopenharmony_ci}
28cb93a386Sopenharmony_ci
29cb93a386Sopenharmony_ciTEST_F(SymbolTest, CopyAssign) {
30cb93a386Sopenharmony_ci  Symbol sym1(1, ProgramID::New());
31cb93a386Sopenharmony_ci  Symbol sym2;
32cb93a386Sopenharmony_ci
33cb93a386Sopenharmony_ci  EXPECT_FALSE(sym2.IsValid());
34cb93a386Sopenharmony_ci  sym2 = sym1;
35cb93a386Sopenharmony_ci  EXPECT_TRUE(sym2.IsValid());
36cb93a386Sopenharmony_ci  EXPECT_EQ(sym2, sym1);
37cb93a386Sopenharmony_ci}
38cb93a386Sopenharmony_ci
39cb93a386Sopenharmony_ciTEST_F(SymbolTest, Comparison) {
40cb93a386Sopenharmony_ci  auto program_id = ProgramID::New();
41cb93a386Sopenharmony_ci  Symbol sym1(1, program_id);
42cb93a386Sopenharmony_ci  Symbol sym2(2, program_id);
43cb93a386Sopenharmony_ci  Symbol sym3(1, program_id);
44cb93a386Sopenharmony_ci
45cb93a386Sopenharmony_ci  EXPECT_TRUE(sym1 == sym3);
46cb93a386Sopenharmony_ci  EXPECT_FALSE(sym1 == sym2);
47cb93a386Sopenharmony_ci  EXPECT_FALSE(sym3 == sym2);
48cb93a386Sopenharmony_ci}
49cb93a386Sopenharmony_ci
50cb93a386Sopenharmony_ci}  // namespace
51cb93a386Sopenharmony_ci}  // namespace tint
52