blob: 38d05b6d42775f022fa0568f74432dee35ba67d8 [file] [log] [blame]
// 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/type/alias_type.h"
#include "gtest/gtest.h"
#include "src/ast/type/i32_type.h"
#include "src/ast/type/u32_type.h"
namespace tint {
namespace ast {
namespace type {
namespace {
using AliasTypeTest = testing::Test;
TEST_F(AliasTypeTest, Create) {
U32Type u32;
AliasType a{"a_type", &u32};
EXPECT_EQ(a.name(), "a_type");
EXPECT_EQ(a.type(), &u32);
}
TEST_F(AliasTypeTest, Is) {
I32Type i32;
AliasType at{"a", &i32};
EXPECT_TRUE(at.IsAlias());
EXPECT_FALSE(at.IsArray());
EXPECT_FALSE(at.IsBool());
EXPECT_FALSE(at.IsF32());
EXPECT_FALSE(at.IsI32());
EXPECT_FALSE(at.IsMatrix());
EXPECT_FALSE(at.IsPointer());
EXPECT_FALSE(at.IsStruct());
EXPECT_FALSE(at.IsU32());
EXPECT_FALSE(at.IsVector());
}
TEST_F(AliasTypeTest, TypeName) {
I32Type i32;
AliasType at{"Particle", &i32};
EXPECT_EQ(at.type_name(), "__alias_Particle__i32");
}
} // namespace
} // namespace type
} // namespace ast
} // namespace tint