OR-Tools  9.6
solomon_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 <memory>
17 #include <string>
18 
19 #include "absl/flags/flag.h"
20 #include "gtest/gtest.h"
22 #include "ortools/base/file.h"
24 #include "ortools/base/path.h"
25 
26 ABSL_FLAG(std::string, test_srcdir, "", "REQUIRED: src dir");
27 
28 ABSL_FLAG(std::string, solomon_test_archive,
29  "ortools/bench/solomon/"
30  "testdata/solomon.zip",
31  "Solomon: testing archive");
32 ABSL_FLAG(std::string, solomon_test_instance, "google2.txt",
33  "Solomon: testing instance");
34 
35 namespace operations_research {
36 namespace {
37 TEST(SolomonParserTest, LoadEmptyFileName) {
38  std::string empty_file_name;
39  SolomonParser parser;
40  EXPECT_FALSE(parser.LoadFile(empty_file_name));
41 }
42 
43 TEST(SolomonParserTest, LoadNonExistingFile) {
44  SolomonParser parser;
45  EXPECT_FALSE(parser.LoadFile(""));
46 }
47 
48 TEST(SolomonParserTest, LoadNonEmptyArchive) {
49  std::string empty_archive_name;
50  SolomonParser parser;
51  EXPECT_FALSE(parser.LoadFile(absl::GetFlag(FLAGS_solomon_test_instance),
52  empty_archive_name));
53 }
54 
55 TEST(SolomonParserTest, LoadNonExistingArchive) {
56  SolomonParser parser;
57  EXPECT_FALSE(parser.LoadFile(absl::GetFlag(FLAGS_solomon_test_instance), ""));
58 }
59 
60 TEST(SolomonParserTest, LoadNonExistingInstance) {
61  SolomonParser parser;
62  EXPECT_FALSE(parser.LoadFile(
63  "doesnotexist.txt",
64  file::JoinPath(absl::GetFlag(FLAGS_test_srcdir),
65  absl::GetFlag(FLAGS_solomon_test_archive))));
66 }
67 } // namespace
68 } // 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)
ABSL_FLAG(std::string, test_srcdir, "", "REQUIRED: src dir")