mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-07-30 17:05:48 +00:00
Once a `Decoration` has been parsed, it'll be placed into a `DecorationList` and validated later in the parse. In order to create error diagnostics that refer back to the decoration, we need to know its source. Bug: tint:282 Bug: tint:291 Change-Id: I38de708adbd041601b61d7e0a4d0402e9a2fe526 Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/31722 Commit-Queue: Ben Clayton <bclayton@google.com> Reviewed-by: dan sinclair <dsinclair@chromium.org>
76 lines
1.9 KiB
C++
76 lines
1.9 KiB
C++
// 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/workgroup_decoration.h"
|
|
|
|
#include <sstream>
|
|
|
|
#include "gtest/gtest.h"
|
|
|
|
namespace tint {
|
|
namespace ast {
|
|
namespace {
|
|
|
|
using WorkgroupDecorationTest = testing::Test;
|
|
|
|
TEST_F(WorkgroupDecorationTest, Creation_1param) {
|
|
WorkgroupDecoration d{2, Source{}};
|
|
uint32_t x = 0;
|
|
uint32_t y = 0;
|
|
uint32_t z = 0;
|
|
std::tie(x, y, z) = d.values();
|
|
EXPECT_EQ(x, 2u);
|
|
EXPECT_EQ(y, 1u);
|
|
EXPECT_EQ(z, 1u);
|
|
}
|
|
TEST_F(WorkgroupDecorationTest, Creation_2param) {
|
|
WorkgroupDecoration d{2, 4, Source{}};
|
|
uint32_t x = 0;
|
|
uint32_t y = 0;
|
|
uint32_t z = 0;
|
|
std::tie(x, y, z) = d.values();
|
|
EXPECT_EQ(x, 2u);
|
|
EXPECT_EQ(y, 4u);
|
|
EXPECT_EQ(z, 1u);
|
|
}
|
|
|
|
TEST_F(WorkgroupDecorationTest, Creation_3param) {
|
|
WorkgroupDecoration d{2, 4, 6, Source{}};
|
|
uint32_t x = 0;
|
|
uint32_t y = 0;
|
|
uint32_t z = 0;
|
|
std::tie(x, y, z) = d.values();
|
|
EXPECT_EQ(x, 2u);
|
|
EXPECT_EQ(y, 4u);
|
|
EXPECT_EQ(z, 6u);
|
|
}
|
|
|
|
TEST_F(WorkgroupDecorationTest, Is) {
|
|
WorkgroupDecoration d{2, 4, 6, Source{}};
|
|
EXPECT_TRUE(d.IsWorkgroup());
|
|
EXPECT_FALSE(d.IsStage());
|
|
}
|
|
|
|
TEST_F(WorkgroupDecorationTest, ToStr) {
|
|
WorkgroupDecoration d{2, 4, 6, Source{}};
|
|
std::ostringstream out;
|
|
d.to_str(out);
|
|
EXPECT_EQ(out.str(), R"(WorkgroupDecoration{2 4 6}
|
|
)");
|
|
}
|
|
|
|
} // namespace
|
|
} // namespace ast
|
|
} // namespace tint
|