Files
carbon-lang/explorer/syntax/parse_test.cpp
T
Geoff Romer e3d3122f1d Move tests to the namespace of the code under test (#3244)
Rationale: this convention avoids forcing closely-related code to be far
apart in the namespace hierarchy, and vice versa. By the same token, it
makes the namespace hierarchy more consistent with the directory
hierarchy.
2023-09-18 22:05:14 +00:00

35 lines
810 B
C++

// Part of the Carbon Language project, under the Apache License v2.0 with LLVM
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
#include "explorer/syntax/parse.h"
#include <gmock/gmock.h>
#include <gtest/gtest.h>
#include <string>
#include <variant>
#include "explorer/base/arena.h"
namespace Carbon {
namespace {
static constexpr std::string_view FileContents = R"(
package ExplorerTest api;
fn Foo() {}
)";
TEST(ParseTest, ParseFromString) {
Arena arena;
ErrorOr<AST> parse_result =
ParseFromString(&arena, "file.carbon", FileKind::Main, FileContents,
/*parser_debug=*/false);
ASSERT_TRUE(parse_result.ok());
EXPECT_EQ(parse_result->declarations.size(), 1);
}
} // namespace
} // namespace Carbon