Path: blob/main_old/src/tests/preprocessor_tests/comment_test.cpp
1693 views
//1// Copyright 2012 The ANGLE Project Authors. All rights reserved.2// Use of this source code is governed by a BSD-style license that can be3// found in the LICENSE file.4//56#include "PreprocessorTest.h"7#include "compiler/preprocessor/Token.h"89namespace angle10{1112class CommentTest : public SimplePreprocessorTest, public testing::WithParamInterface<const char *>13{};1415TEST_P(CommentTest, CommentIgnored)16{17const char *str = GetParam();1819pp::Token token;20lexSingleToken(str, &token);21EXPECT_EQ(pp::Token::LAST, token.type);22}2324INSTANTIATE_TEST_SUITE_P(LineComment,25CommentTest,26testing::Values("//foo\n", // With newline.27"//foo", // Without newline.28"//**/", // Nested block comment.29"////", // Nested line comment.30"//\"")); // Invalid character.3132INSTANTIATE_TEST_SUITE_P(BlockComment,33CommentTest,34testing::Values("/*foo*/",35"/*foo\n*/", // With newline.36"/*//*/", // Nested line comment.37"/*/**/", // Nested block comment.38"/***/", // With lone '*'.39"/*\"*/")); // Invalid character.4041class BlockCommentTest : public SimplePreprocessorTest42{};4344TEST_F(BlockCommentTest, CommentReplacedWithSpace)45{46const char *str = "/*foo*/bar";4748pp::Token token;49lexSingleToken(str, &token);50EXPECT_EQ(pp::Token::IDENTIFIER, token.type);51EXPECT_EQ("bar", token.text);52EXPECT_TRUE(token.hasLeadingSpace());53}5455TEST_F(BlockCommentTest, UnterminatedComment)56{57const char *str = "/*foo";5859using testing::_;60EXPECT_CALL(mDiagnostics, print(pp::Diagnostics::PP_EOF_IN_COMMENT, _, _));6162preprocess(str);63}6465} // namespace angle666768