test_indexlist.cpp
Go to the documentation of this file.
1 /*
2  * This file is part of qpOASES.
3  *
4  * qpOASES -- An Implementation of the Online Active Set Strategy.
5  * Copyright (C) 2007-2015 by Hans Joachim Ferreau, Andreas Potschka,
6  * Christian Kirches et al. All rights reserved.
7  *
8  * qpOASES is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License as published by the Free Software Foundation; either
11  * version 2.1 of the License, or (at your option) any later version.
12  *
13  * qpOASES is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16  * See the GNU Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with qpOASES; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21  *
22  */
23 
24 
36 #include <qpOASES.hpp>
37 #include <qpOASES/UnitTesting.hpp>
38 
39 
41 int main()
42 {
44 
45  Indexlist il(10);
46  int_t i, *numbers;
47 
48  il.addNumber(1);
49  il.addNumber(3);
50  il.addNumber(5);
51  il.addNumber(2);
52  il.addNumber(4);
53  il.addNumber(0);
54  il.addNumber(7);
55  il.addNumber(6);
56  il.addNumber(8);
57  il.addNumber(9);
58 
59  il.getNumberArray(&numbers);
60  fprintf(stdFile, "Unsorted numbers: ");
61  for (i = 0; i < 10; i++)
62  fprintf(stdFile, " %2d", (int)(numbers[i]) );
63  fprintf(stdFile, "\n");
64 
65  fprintf(stdFile, "Unsorted index of number 0: %3d\n", (int)(il.getIndex(0)) );
66 
67  QPOASES_TEST_FOR_TRUE( il.getIndex(0) == 5 )
68 
69  il.removeNumber(5);
70  fprintf(stdFile, "Unsorted index of (removed) number 5: %3d\n", (int)(il.getIndex(5)) );
71 
72  QPOASES_TEST_FOR_TRUE( il.getIndex(5) == -1 )
73 
74  il.getNumberArray(&numbers);
75  fprintf(stdFile, "Unsorted numbers: ");
76  for (i = 0; i < 9; i++)
77  fprintf(stdFile, " %2d", (int)(numbers[i]) );
78  fprintf(stdFile, "\n");
79 
80  il.swapNumbers(2, 7);
81 
82  il.getNumberArray(&numbers);
83  fprintf(stdFile, "Unsorted numbers: ");
84  for (i = 0; i < 9; i++)
85  fprintf(stdFile, " %2d", (int)(numbers[i]) );
86  fprintf(stdFile, "\n");
87 
88  QPOASES_TEST_FOR_TRUE( numbers[2] == 7 )
89 
90  return TEST_PASSED;
91 }
92 
93 
94 /*
95  * end of file
96  */
#define stdFile
#define TEST_PASSED
Definition: UnitTesting.hpp:45
int main()
#define QPOASES_TEST_FOR_TRUE(x)
Definition: UnitTesting.hpp:64


acado
Author(s): Milan Vukov, Rien Quirynen
autogenerated on Mon Jun 10 2019 12:35:12