Skip to content

Commit

Permalink
Added tests
Browse files Browse the repository at this point in the history
  • Loading branch information
anutosh491 committed Sep 30, 2023
1 parent 7f910c3 commit e534b48
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
3 changes: 2 additions & 1 deletion symengine/cwrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ using SymEngine::ComplexDouble;
using SymEngine::CSRMatrix;
using SymEngine::DenseMatrix;
using SymEngine::down_cast;
using SymEngine::E;
using SymEngine::function_symbol;
using SymEngine::FunctionSymbol;
using SymEngine::has_symbol;
Expand Down Expand Up @@ -309,7 +310,7 @@ int basic_is_Log(const basic s)
int basic_is_Exp(const basic s)
{
SYMENGINE_ASSERT(basic_is_Pow(s) == 1);
return (down_cast<const SymEngine::Pow &>(*(s->m))).get_exp() == SymEngine::E ? 1 : 0;
return (down_cast<const SymEngine::Pow &>(*(s->m))).get_exp() == E ? 1 : 0;
}

CWRAPPER_OUTPUT_TYPE integer_set_si(basic s, long i)
Expand Down
2 changes: 2 additions & 0 deletions symengine/cwrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,8 @@ int basic_is_Mul(const basic s);
int basic_is_Pow(const basic s);
//! Returns 1 if `s` is of type Log; 0 otherwise
int basic_is_Log(const basic s);
//! Returns 1 if `s` is of type Exp; 0 otherwise
int basic_is_Exp(const basic s);

//! Assign to s, a long.
CWRAPPER_OUTPUT_TYPE integer_set_si(basic s, long i);
Expand Down
5 changes: 5 additions & 0 deletions symengine/tests/cwrapper/test_cwrapper.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,12 @@ void test_cwrapper()
SYMENGINE_C_ASSERT(basic_has_symbol(e, y) == 0);
SYMENGINE_C_ASSERT(basic_has_symbol(e, z) == 0);
basic_add(e, e, x);
SYMENGINE_C_ASSERT(basic_is_Add(e) == 1);
SYMENGINE_C_ASSERT(basic_has_symbol(e, x) == 1);
SYMENGINE_C_ASSERT(basic_has_symbol(e, y) == 0);
SYMENGINE_C_ASSERT(basic_has_symbol(e, z) == 0);
basic_mul(e, e, y);
SYMENGINE_C_ASSERT(basic_is_Mul(e) == 1);
SYMENGINE_C_ASSERT(basic_has_symbol(e, x) == 1);
SYMENGINE_C_ASSERT(basic_has_symbol(e, y) == 1);
SYMENGINE_C_ASSERT(basic_has_symbol(e, z) == 0);
Expand Down Expand Up @@ -102,7 +104,9 @@ void test_cwrapper()

integer_set_ui(e, 123);
basic_sqrt(e, e);
SYMENGINE_C_ASSERT(basic_is_Pow(e) == 1);
basic_exp(e, e);
SYMENGINE_C_ASSERT(basic_is_Exp(e) == 1);

s = basic_str(e);
SYMENGINE_C_ASSERT(strcmp(s, "exp(sqrt(123))") == 0);
Expand Down Expand Up @@ -1389,6 +1393,7 @@ void test_functions()

integer_set_ui(res, 2);
basic_log(res, res);
SYMENGINE_C_ASSERT(basic_is_Log(res) == 1);
SYMENGINE_C_ASSERT(basic_eq(res, ans));

real_double_set_d(res, 1.1);
Expand Down

0 comments on commit e534b48

Please sign in to comment.