diff --git a/src/tint/symbol.cc b/src/tint/symbol.cc index 9adc1aaa37..32177f6860 100644 --- a/src/tint/symbol.cc +++ b/src/tint/symbol.cc @@ -42,6 +42,11 @@ bool Symbol::operator==(const Symbol& other) const { return val_ == other.val_; } +bool Symbol::operator!=(const Symbol& other) const { + TINT_ASSERT_PROGRAM_IDS_EQUAL_IF_VALID(Symbol, program_id_, other.program_id_); + return val_ != other.val_; +} + bool Symbol::operator<(const Symbol& other) const { TINT_ASSERT_PROGRAM_IDS_EQUAL_IF_VALID(Symbol, program_id_, other.program_id_); return val_ < other.val_; diff --git a/src/tint/symbol.h b/src/tint/symbol.h index fc0a0df56c..c09367351c 100644 --- a/src/tint/symbol.h +++ b/src/tint/symbol.h @@ -63,11 +63,16 @@ class Symbol { /// @returns teh symbol after doing the move Symbol& operator=(Symbol&& o); - /// Comparison operator + /// Equality operator /// @param o the other symbol /// @returns true if the symbols are the same bool operator==(const Symbol& o) const; + /// Inequality operator + /// @param o the other symbol + /// @returns true if the symbols are the different + bool operator!=(const Symbol& o) const; + /// Less-than operator /// @param o the other symbol /// @returns true if this symbol is ordered before symbol `o` diff --git a/src/tint/symbol_test.cc b/src/tint/symbol_test.cc index 22135b5665..db8e3216e9 100644 --- a/src/tint/symbol_test.cc +++ b/src/tint/symbol_test.cc @@ -43,8 +43,11 @@ TEST_F(SymbolTest, Comparison) { Symbol sym3(1, program_id); EXPECT_TRUE(sym1 == sym3); + EXPECT_FALSE(sym1 != sym3); EXPECT_FALSE(sym1 == sym2); + EXPECT_TRUE(sym1 != sym2); EXPECT_FALSE(sym3 == sym2); + EXPECT_TRUE(sym3 != sym2); } } // namespace