1 #include "gmock/gmock.h" 2 #include "gtest/gtest.h" 7 TEST(OSQP, osqp_c_interface) {
78 OSQPSettings* settings = (OSQPSettings*)malloc(
sizeof(OSQPSettings));
79 OSQPWorkspace* workspace;
80 OSQPData* data = (OSQPData*)malloc(
sizeof(OSQPData));
83 data->P = csc_matrix(data->n, data->n, P_nnz, P_x, P_i, P_p);
85 data->A = csc_matrix(data->m, data->n, A_nnz, A_x, A_i, A_p);
90 osqp_set_default_settings(settings);
92 settings->alpha = 1.0;
94 workspace = osqp_setup(data, settings);
96 osqp_solve(workspace);
98 printf(
"solution: %6.3f, %6.3f\n", workspace->solution->x[0],
99 workspace->solution->x[1]);
101 EXPECT_TRUE(
fpEqual(workspace->solution->x[0], .3, .0001));
102 EXPECT_TRUE(
fpEqual(workspace->solution->x[1], .7, .0001));
104 osqp_cleanup(workspace);
113 m << 1, 2, 3, 4, 5, 6;
115 double* ptr = m.data();
117 double colMajor[6] = {1, 4, 2, 5, 3, 6};
119 for (
size_t i = 0; i < 6; i++) {
120 EXPECT_TRUE(colMajor[i] == ptr[i]);
bool fpEqual(T a, T b, T tol)
typename Eigen::Matrix< T, Eigen::Dynamic, Eigen::Dynamic > DMat
TEST(OSQP, osqp_c_interface)