OR-Tools  9.6
pdtsp_parser_test.cc
Go to the documentation of this file.
1 // Copyright 2010-2022 Google LLC
2 // Licensed under the Apache License, Version 2.0 (the "License");
3 // you may not use this file except in compliance with the License.
4 // You may obtain a copy of the License at
5 //
6 // http://www.apache.org/licenses/LICENSE-2.0
7 //
8 // Unless required by applicable law or agreed to in writing, software
9 // distributed under the License is distributed on an "AS IS" BASIS,
10 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 // See the License for the specific language governing permissions and
12 // limitations under the License.
13 
15 
16 #include <functional>
17 #include <string>
18 
19 #include "absl/flags/flag.h"
20 #include "gtest/gtest.h"
21 #include "ortools/base/helpers.h"
23 #include "ortools/base/path.h"
24 
25 #if defined(_MSC_VER)
26 #define ROOT_DIR "../../../../../../../"
27 #else
28 #define ROOT_DIR
29 #endif // _MSC_VER
30 
31 ABSL_FLAG(std::string, test_srcdir, "", "REQUIRED: src dir");
32 
33 namespace operations_research {
34 namespace {
35 TEST(PdTspParserTest, LoadDataSet) {
36  for (const std::string& data : {
37  ROOT_DIR "ortools/routing/testdata/"
38  "pdtsp_prob10b.txt",
39  }) {
40  PdTspParser parser;
41  EXPECT_TRUE(parser.LoadFile(
42  file::JoinPath(absl::GetFlag(FLAGS_test_srcdir), data)));
43  EXPECT_EQ(0, parser.depot());
44  EXPECT_EQ(21, parser.Size());
45  EXPECT_FALSE(parser.IsPickup(0)); // depot
46  EXPECT_FALSE(parser.IsPickup(11)); // delivery
47  EXPECT_TRUE(parser.IsPickup(2)); // pickup
48  EXPECT_EQ(12, parser.DeliveryFromPickup(2));
49  std::function<int64_t(int, int)> distances = parser.Distances();
50  for (int i = 0; i < parser.Size(); ++i) {
51  EXPECT_EQ(0, distances(i, i));
52  }
53  EXPECT_EQ(557, distances(1, 20));
54  }
55 }
56 } // namespace
57 } // namespace operations_research
std::string JoinPath(absl::string_view path1, absl::string_view path2)
Definition: path.cc:25
Collection of objects used to extend the Constraint Solver library.
TEST(LinearAssignmentTest, NullMatrix)
#define ROOT_DIR
ABSL_FLAG(std::string, test_srcdir, "", "REQUIRED: src dir")