• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2021 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/texture.h"
16 
17 #include "src/ast/alias.h"
18 #include "src/ast/array.h"
19 #include "src/ast/bool.h"
20 #include "src/ast/f32.h"
21 #include "src/ast/i32.h"
22 #include "src/ast/matrix.h"
23 #include "src/ast/pointer.h"
24 #include "src/ast/sampler.h"
25 #include "src/ast/struct.h"
26 #include "src/ast/test_helper.h"
27 #include "src/ast/u32.h"
28 #include "src/ast/vector.h"
29 
30 namespace tint {
31 namespace ast {
32 namespace {
33 
34 using AstTextureTypeTest = TestHelper;
35 
TEST_F(AstTextureTypeTest,IsTextureArray)36 TEST_F(AstTextureTypeTest, IsTextureArray) {
37   EXPECT_EQ(false, IsTextureArray(TextureDimension::kNone));
38   EXPECT_EQ(false, IsTextureArray(TextureDimension::k1d));
39   EXPECT_EQ(false, IsTextureArray(TextureDimension::k2d));
40   EXPECT_EQ(true, IsTextureArray(TextureDimension::k2dArray));
41   EXPECT_EQ(false, IsTextureArray(TextureDimension::k3d));
42   EXPECT_EQ(false, IsTextureArray(TextureDimension::kCube));
43   EXPECT_EQ(true, IsTextureArray(TextureDimension::kCubeArray));
44 }
45 
TEST_F(AstTextureTypeTest,NumCoordinateAxes)46 TEST_F(AstTextureTypeTest, NumCoordinateAxes) {
47   EXPECT_EQ(0, NumCoordinateAxes(TextureDimension::kNone));
48   EXPECT_EQ(1, NumCoordinateAxes(TextureDimension::k1d));
49   EXPECT_EQ(2, NumCoordinateAxes(TextureDimension::k2d));
50   EXPECT_EQ(2, NumCoordinateAxes(TextureDimension::k2dArray));
51   EXPECT_EQ(3, NumCoordinateAxes(TextureDimension::k3d));
52   EXPECT_EQ(3, NumCoordinateAxes(TextureDimension::kCube));
53   EXPECT_EQ(3, NumCoordinateAxes(TextureDimension::kCubeArray));
54 }
55 
56 }  // namespace
57 }  // namespace ast
58 }  // namespace tint
59