issue57 code

This commit is contained in:
lperron@google.com
2014-12-29 22:07:49 +00:00
parent bd415d01fe
commit 4c4cfe9aa8
2 changed files with 45 additions and 0 deletions

39
examples/tests/issue57.cc Normal file
View File

@@ -0,0 +1,39 @@
// Copyright 2011-2014 Google
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include "base/hash.h"
#include "base/map_util.h"
#include "base/stl_util.h"
#include "base/random.h"
#include "constraint_solver/constraint_solveri.h"
#include "constraint_solver/constraint_solver.h"
#include "util/string_array.h"
namespace operations_research {
void OverflowTest() {
// It works on mac-clang, but fails with gcc.
Solver solver("OverflowTest");
IntVar* const x = solver.MakeIntVar(kint64min, kint64max, "x");
IntVar* const y = solver.MakeIntVar(kint64min, kint64max, "y");
IntExpr* const z = solver.MakeDifference(x, y);
LOG(INFO) << z->DebugString();
Constraint* const ct = solver.MakeGreaterOrEqual(z, 10);
LOG(INFO) << ct->DebugString();
}
} // namespace operations_research
int main(int argc, char** argv) {
google::ParseCommandLineFlags(&argc, &argv, true);
operations_research::OverflowTest();
return 0;
}

View File

@@ -1398,6 +1398,12 @@ $(OBJ_DIR)/min_max_test.$O:$(EX_DIR)/tests/min_max_test.cc $(SRC_DIR)/constraint
$(BIN_DIR)/min_max_test$E: $(DYNAMIC_CP_DEPS) $(OBJ_DIR)/min_max_test.$O
$(CCC) $(CFLAGS) $(OBJ_DIR)/min_max_test.$O $(DYNAMIC_CP_LNK) $(DYNAMIC_LD_FLAGS) $(EXE_OUT)$(BIN_DIR)$Smin_max_test$E
$(OBJ_DIR)/issue57.$O:$(EX_DIR)/tests/issue57.cc $(SRC_DIR)/constraint_solver/constraint_solver.h
$(CCC) $(CFLAGS) -c $(EX_DIR)$Stests/issue57.cc $(OBJ_OUT)$(OBJ_DIR)$Sissue57.$O
$(BIN_DIR)/issue57$E: $(DYNAMIC_CP_DEPS) $(OBJ_DIR)/issue57.$O
$(CCC) $(CFLAGS) $(OBJ_DIR)/issue57.$O $(DYNAMIC_CP_LNK) $(DYNAMIC_LD_FLAGS) $(EXE_OUT)$(BIN_DIR)$Sissue57$E
$(OBJ_DIR)/visitor_test.$O:$(EX_DIR)/tests/visitor_test.cc $(SRC_DIR)/constraint_solver/constraint_solver.h
$(CCC) $(CFLAGS) -c $(EX_DIR)$Stests/visitor_test.cc $(OBJ_OUT)$(OBJ_DIR)$Svisitor_test.$O