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