Frobby  0.9.5
LibStdProgramTest.cpp
Go to the documentation of this file.
1 /* Frobby: Software for monomial ideal computations.
2  Copyright (C) 2007 Bjarke Hammersholt Roune (www.broune.com)
3 
4  This program is free software; you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation; either version 2 of the License, or
7  (at your option) any later version.
8 
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with this program. If not, see http://www.gnu.org/licenses/.
16 */
17 #include "stdinc.h"
18 
19 #include "frobby.h"
20 #include "tests.h"
21 #include "BigIdeal.h"
22 #include "IdealFactory.h"
23 #include "LibTest.h"
24 
25 TEST_SUITE2(LibraryInterface, StandardProgram)
26 
27 TEST(StandardProgram, TypicalNonNegative) {
28  vector<mpz_class> grading(4);
29  grading[0] = 0;
30  grading[1] = 100;
31  grading[2] = 10000;
32  grading[3] = "1000000000000000000000000000000000000";
35 
36  bool returnValue =
38  (ideal, castLibArray(grading), consumer);
39 
40  ASSERT_TRUE(returnValue);
41  ASSERT_EQ(consumer.getIdeal(), IdealFactory::z());
42 }
43 
44 TEST(StandardProgram, TypicalNegative) {
45  vector<mpz_class> grading(4);
46  grading[0] = 0;
47  grading[1] = 100;
48  grading[2] = -10000;
49  grading[3] = "1000000000000000000000000000000000000";
52 
53  bool returnValue =
54  Frobby::solveStandardMonomialProgram(ideal, castLibArray(grading), consumer);
55 
56  ASSERT_TRUE(returnValue);
57  ASSERT_EQ(consumer.getIdeal(), IdealFactory::xy());
58 }
59 
60 TEST(StandardProgram, ZeroIdeal) {
61  vector<mpz_class> grading(3);
62  grading[0] = 0;
63  grading[1] = 100;
64  grading[2] = -10000;
65 
66  for (size_t varCount = 0; varCount <= 3; ++varCount) {
67  Frobby::Ideal ideal(varCount);
68  LibIdealConsumer consumer((VarNames(varCount)));
69 
70  bool returnValue =
72  (ideal, castLibArray(grading), consumer);
73 
74  if (varCount == 0) {
75  ASSERT_TRUE(returnValue);
76  ASSERT_EQ(consumer.getIdeal(), IdealFactory::wholeRing(varCount));
77  } else {
78  ASSERT_FALSE(returnValue);
79  ASSERT_EQ(consumer.getIdeal(), IdealFactory::zeroIdeal(varCount));
80  }
81  }
82 }
83 
84 TEST(StandardProgram, WholeRing) {
85  vector<mpz_class> grading(3);
86  grading[0] = 0;
87  grading[1] = 100;
88  grading[2] = -10000;
89 
90  for (size_t varCount = 0; varCount <= 3; ++varCount) {
92  LibIdealConsumer consumer((VarNames(varCount)));
93 
94  bool returnValue =
96  (ideal, castLibArray(grading), consumer);
97 
98  ASSERT_FALSE(returnValue);
99  ASSERT_EQ(consumer.getIdeal(), IdealFactory::zeroIdeal(varCount));
100  }
101 }
TEST(StandardProgram, TypicalNonNegative)
const mpz_t * castLibArray(const vector< mpz_class > &vect)
Returns a pointer to an array of mpt_t that represents the entries in the mpz_class.
Definition: LibTest.cpp:41
Frobby::Ideal toLibIdeal(const BigIdeal &ideal)
Returns a library interface ideal that corresponds to the parameter ideal.
Definition: LibTest.cpp:26
#define ASSERT_TRUE(VALUE)
Definition: asserts.h:72
#define ASSERT_EQ(A, B)
Definition: asserts.h:147
#define ASSERT_FALSE(VALUE)
Definition: asserts.h:119
static BigIdeal z()
Returns .
static VarNames ring_xyzt()
Returns the ring in the four variables , , and .
static BigIdeal xy()
Returns .
static BigIdeal xx_yy_zz_t_xz_yz()
Returns .
static BigIdeal zeroIdeal(size_t varCount)
Returns the ideal in the ring VarNames(varCount).
static BigIdeal wholeRing(size_t varCount)
Returns in the ring VarNames(varCount).
Records library interface output into a BigIdeal.
Definition: LibTest.h:39
const BigIdeal & getIdeal() const
Returns the recorded ideal in a canonical form.
Definition: LibTest.cpp:66
Defines the variables of a polynomial ring and facilities IO involving them.
Definition: VarNames.h:40
#define TEST_SUITE2(PARENT, SUITE)
Definition: macroes.h:28
bool solveStandardMonomialProgram(const Ideal &ideal, const mpz_t *l, IdealConsumer &consumer)
Solve the optimization program.
Definition: frobby.cpp:420