Add tests for NopStatement.

This CL adds tests for the NopStatement AST node.

Bug: tint:11
Change-Id: I890b7f6bc6347ba4f5a67334385feffd24079d5d
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/16665
Reviewed-by: Sarah Mashayekhi <sarahmashay@google.com>
This commit is contained in:
Dan Sinclair 2020-03-16 14:31:58 +00:00 committed by Sarah Mashayekhi
parent 3eaf827cc8
commit 9964846c98
2 changed files with 58 additions and 0 deletions

View File

@ -224,6 +224,7 @@ set(TINT_TEST_SRCS
ast/loop_statement_test.cc
ast/member_accessor_expression_test.cc
ast/module_test.cc
ast/nop_statement_test.cc
ast/set_decoration_test.cc
ast/struct_member_test.cc
ast/struct_member_offset_decoration_test.cc

View File

@ -0,0 +1,57 @@
// Copyright 2020 The Tint 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 "src/ast/nop_statement.h"
#include <sstream>
#include "gtest/gtest.h"
namespace tint {
namespace ast {
using NopStatementTest = testing::Test;
TEST_F(NopStatementTest, Creation) {
NopStatement n;
EXPECT_EQ(n.line(), 0);
EXPECT_EQ(n.column(), 0);
}
TEST_F(NopStatementTest, Creation_WithSource) {
NopStatement n(Source{20, 2});
EXPECT_EQ(n.line(), 20);
EXPECT_EQ(n.column(), 2);
}
TEST_F(NopStatementTest, IsNop) {
NopStatement n;
EXPECT_TRUE(n.IsNop());
}
TEST_F(NopStatementTest, IsValid) {
NopStatement n;
EXPECT_TRUE(n.IsValid());
}
TEST_F(NopStatementTest, ToStr) {
NopStatement n;
std::ostringstream out;
n.to_str(out, 2);
EXPECT_EQ(out.str(), R"( Nop{}
)");
}
} // namespace ast
} // namespace tint