forked from substrait-io/substrait-cpp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPlanLoaderTest.cpp
More file actions
43 lines (32 loc) · 1.14 KB
/
PlanLoaderTest.cpp
File metadata and controls
43 lines (32 loc) · 1.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/* SPDX-License-Identifier: Apache-2.0 */
#include "../planloader.h"
#include <gmock/gmock-matchers.h>
#include <gtest/gtest.h>
#include <substrait/proto/plan.pb.h>
#include "substrait/common/Io.h"
namespace io::substrait::textplan {
namespace {
TEST(PlanLoaderTest, LoadAndSave) {
auto serializedPlan = load_substrait_plan("data/q6_first_stage.json");
ASSERT_EQ(serializedPlan->error_message, nullptr);
::substrait::proto::Plan plan;
bool parseStatus =
plan.ParseFromArray(serializedPlan->buffer, serializedPlan->size);
ASSERT_TRUE(parseStatus) << "Failed to parse the plan.";
const char* saveStatus = save_substrait_plan(
serializedPlan->buffer,
serializedPlan->size,
"outfile.splan",
PlanFileFormat::kText);
ASSERT_EQ(saveStatus, nullptr);
free_substrait_plan(serializedPlan);
}
TEST(PlanLoaderTest, LoadMissingFile) {
auto serializedPlan = load_substrait_plan("no_such_file.json");
ASSERT_THAT(
serializedPlan->error_message,
::testing::StartsWith("Failed to open file no_such_file.json"));
free_substrait_plan(serializedPlan);
}
} // namespace
} // namespace io::substrait::textplan