• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2020 The Tint Authors.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 //     http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #include "src/ast/sampled_texture.h"
16 
17 #include "src/ast/f32.h"
18 #include "src/ast/test_helper.h"
19 
20 namespace tint {
21 namespace ast {
22 namespace {
23 
24 using AstSampledTextureTest = TestHelper;
25 
TEST_F(AstSampledTextureTest,IsTexture)26 TEST_F(AstSampledTextureTest, IsTexture) {
27   auto* f32 = create<F32>();
28   Texture* ty = create<SampledTexture>(TextureDimension::kCube, f32);
29   EXPECT_FALSE(ty->Is<DepthTexture>());
30   EXPECT_TRUE(ty->Is<SampledTexture>());
31   EXPECT_FALSE(ty->Is<StorageTexture>());
32 }
33 
TEST_F(AstSampledTextureTest,Dim)34 TEST_F(AstSampledTextureTest, Dim) {
35   auto* f32 = create<F32>();
36   auto* s = create<SampledTexture>(TextureDimension::k3d, f32);
37   EXPECT_EQ(s->dim, TextureDimension::k3d);
38 }
39 
TEST_F(AstSampledTextureTest,Type)40 TEST_F(AstSampledTextureTest, Type) {
41   auto* f32 = create<F32>();
42   auto* s = create<SampledTexture>(TextureDimension::k3d, f32);
43   EXPECT_EQ(s->type, f32);
44 }
45 
TEST_F(AstSampledTextureTest,FriendlyName)46 TEST_F(AstSampledTextureTest, FriendlyName) {
47   auto* f32 = create<F32>();
48   auto* s = create<SampledTexture>(TextureDimension::k3d, f32);
49   EXPECT_EQ(s->FriendlyName(Symbols()), "texture_3d<f32>");
50 }
51 
52 }  // namespace
53 }  // namespace ast
54 }  // namespace tint
55