dawn-cmake/src/ast/sint_literal_test.cc
Ben Clayton 91da97d6c3 Remove ast::NullLiteral
This isn't in the WGSL spec, nor is it generated by readers.
This was only used inside the SPIR-V writer, but this remaining usage was removed in the parent change.

Change-Id: I1bbfde67dc760b761af010a7a144dccb52369148
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/45343
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: David Neto <dneto@google.com>
2021-03-22 16:06:35 +00:00

56 lines
1.5 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/test_helper.h"
namespace tint {
namespace ast {
namespace {
using SintLiteralTest = TestHelper;
TEST_F(SintLiteralTest, Value) {
auto* i = create<SintLiteral>(ty.i32(), 47);
ASSERT_TRUE(i->Is<SintLiteral>());
EXPECT_EQ(i->value(), 47);
}
TEST_F(SintLiteralTest, Is) {
ast::Literal* l = create<SintLiteral>(ty.i32(), 42);
EXPECT_FALSE(l->Is<BoolLiteral>());
EXPECT_TRUE(l->Is<SintLiteral>());
EXPECT_FALSE(l->Is<FloatLiteral>());
EXPECT_FALSE(l->Is<UintLiteral>());
}
TEST_F(SintLiteralTest, ToStr) {
auto* i = create<SintLiteral>(ty.i32(), -42);
EXPECT_EQ(str(i), "-42");
}
TEST_F(SintLiteralTest, Name_I32) {
auto* i = create<SintLiteral>(ty.i32(), 2);
EXPECT_EQ("__sint__i32_2", i->name());
}
TEST_F(SintLiteralTest, Name_U32) {
type::U32 u32;
auto* i = create<SintLiteral>(&u32, 2);
EXPECT_EQ("__sint__u32_2", i->name());
}
} // namespace
} // namespace ast
} // namespace tint