Index: tools/gn/operators_unittest.cc |
diff --git a/tools/gn/operators_unittest.cc b/tools/gn/operators_unittest.cc |
index fa163a1775823498d5677cbafab6a60c7e530928..4c9c670a133d514cfa2d01f5da5a87f12147bc64 100644 |
--- a/tools/gn/operators_unittest.cc |
+++ b/tools/gn/operators_unittest.cc |
@@ -237,6 +237,34 @@ TEST(Operators, ListRemove) { |
EXPECT_EQ("bar", new_value->list_value()[0].string_value()); |
} |
+TEST(Operators, IntegerAdd) { |
+ Err err; |
+ TestWithScope setup; |
+ |
+ TestBinaryOpNode node(Token::PLUS, "+"); |
+ node.SetLeftToValue(Value(nullptr, static_cast<int64_t>(123))); |
+ node.SetRightToValue(Value(nullptr, static_cast<int64_t>(456))); |
+ Value ret = ExecuteBinaryOperator(setup.scope(), &node, node.left(), |
+ node.right(), &err); |
+ ASSERT_FALSE(err.has_error()); |
+ ASSERT_EQ(Value::INTEGER, ret.type()); |
+ EXPECT_EQ(579, ret.int_value()); |
+} |
+ |
+TEST(Operators, IntegerSubtract) { |
+ Err err; |
+ TestWithScope setup; |
+ |
+ TestBinaryOpNode node(Token::MINUS, "-"); |
+ node.SetLeftToValue(Value(nullptr, static_cast<int64_t>(123))); |
+ node.SetRightToValue(Value(nullptr, static_cast<int64_t>(456))); |
+ Value ret = ExecuteBinaryOperator(setup.scope(), &node, node.left(), |
+ node.right(), &err); |
+ ASSERT_FALSE(err.has_error()); |
+ ASSERT_EQ(Value::INTEGER, ret.type()); |
+ EXPECT_EQ(-333, ret.int_value()); |
+} |
+ |
TEST(Operators, ShortCircuitAnd) { |
Err err; |
TestWithScope setup; |