diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index d58e85e038..391c999a69 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -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 diff --git a/src/ast/nop_statement_test.cc b/src/ast/nop_statement_test.cc new file mode 100644 index 0000000000..7f47b28928 --- /dev/null +++ b/src/ast/nop_statement_test.cc @@ -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 + +#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