aboutsummaryrefslogtreecommitdiff
path: root/tests/src/test_gensvm_copy.c
diff options
context:
space:
mode:
Diffstat (limited to 'tests/src/test_gensvm_copy.c')
-rw-r--r--tests/src/test_gensvm_copy.c69
1 files changed, 24 insertions, 45 deletions
diff --git a/tests/src/test_gensvm_copy.c b/tests/src/test_gensvm_copy.c
index 0064eb9..ff5b86d 100644
--- a/tests/src/test_gensvm_copy.c
+++ b/tests/src/test_gensvm_copy.c
@@ -66,10 +66,9 @@ char *test_copy_model_poly_1()
from_model->kappa = 1.0;
from_model->weight_idx = 2;
from_model->kerneltype = K_POLY;
- from_model->kernelparam = Calloc(double, 3);
- from_model->kernelparam[0] = 1.0;
- from_model->kernelparam[1] = 2.0;
- from_model->kernelparam[2] = 3.0;
+ from_model->gamma = 1.0;
+ from_model->coef = 2.0;
+ from_model->degree = 3.0;
gensvm_copy_model(from_model, to_model);
@@ -79,12 +78,9 @@ char *test_copy_model_poly_1()
mu_assert(to_model->kappa == 1.0, "to->kappa incorrect.");
mu_assert(to_model->weight_idx == 2, "to->weight_idx incorrect.");
mu_assert(to_model->kerneltype == K_POLY, "to->kerneltype incorrect");
- mu_assert(to_model->kernelparam[0] == 1.0,
- "to->kernelparam[0] is incorrect.");
- mu_assert(to_model->kernelparam[1] == 2.0,
- "to->kernelparam[1] is incorrect.");
- mu_assert(to_model->kernelparam[2] == 3.0,
- "to->kernelparam[2] is incorrect.");
+ mu_assert(to_model->gamma == 1.0, "to->gamma is incorrect.");
+ mu_assert(to_model->coef == 2.0, "to->coef is incorrect.");
+ mu_assert(to_model->degree == 3.0, "to->degree is incorrect.");
gensvm_free_model(from_model);
gensvm_free_model(to_model);
@@ -103,11 +99,9 @@ char *test_copy_model_poly_2()
from_model->kappa = 1.0;
from_model->weight_idx = 2;
from_model->kerneltype = K_POLY;
- from_model->kernelparam = Calloc(double, 3);
- from_model->kernelparam[0] = 1.0;
- from_model->kernelparam[1] = 2.0;
- from_model->kernelparam[2] = 3.0;
- to_model->kernelparam = Calloc(double, 3);
+ from_model->gamma = 1.0;
+ from_model->coef = 2.0;
+ from_model->degree = 3.0;
gensvm_copy_model(from_model, to_model);
@@ -118,12 +112,9 @@ char *test_copy_model_poly_2()
mu_assert(to_model->weight_idx == 2,
"to_model->weight_idx incorrect.");
mu_assert(to_model->kerneltype == K_POLY, "to->kerneltype incorrect");
- mu_assert(to_model->kernelparam[0] == 1.0,
- "to->kernelparam[0] is incorrect.");
- mu_assert(to_model->kernelparam[1] == 2.0,
- "to->kernelparam[1] is incorrect.");
- mu_assert(to_model->kernelparam[2] == 3.0,
- "to->kernelparam[2] is incorrect.");
+ mu_assert(to_model->gamma == 1.0, "to->gamma is incorrect.");
+ mu_assert(to_model->coef == 2.0, "to->coef is incorrect.");
+ mu_assert(to_model->degree == 3.0, "to->degree is incorrect.");
gensvm_free_model(from_model);
gensvm_free_model(to_model);
@@ -142,8 +133,7 @@ char *test_copy_model_rbf_1()
from_model->kappa = 1.0;
from_model->weight_idx = 2;
from_model->kerneltype = K_RBF;
- from_model->kernelparam = Calloc(double, 1);
- from_model->kernelparam[0] = 5.0;
+ from_model->gamma = 5.0;
gensvm_copy_model(from_model, to_model);
@@ -154,8 +144,7 @@ char *test_copy_model_rbf_1()
mu_assert(to_model->weight_idx == 2,
"to_model->weight_idx incorrect.");
mu_assert(to_model->kerneltype == K_RBF, "to->kerneltype incorrect");
- mu_assert(to_model->kernelparam[0] == 5.0,
- "to->kernelparam[0] is incorrect.");
+ mu_assert(to_model->gamma == 5.0, "to->gamma is incorrect.");
gensvm_free_model(from_model);
gensvm_free_model(to_model);
@@ -174,9 +163,7 @@ char *test_copy_model_rbf_2()
from_model->kappa = 1.0;
from_model->weight_idx = 2;
from_model->kerneltype = K_RBF;
- from_model->kernelparam = Calloc(double, 1);
- from_model->kernelparam[0] = 5.0;
- to_model->kernelparam = Calloc(double, 1);
+ from_model->gamma = 5.0;
gensvm_copy_model(from_model, to_model);
@@ -187,8 +174,7 @@ char *test_copy_model_rbf_2()
mu_assert(to_model->weight_idx == 2,
"to_model->weight_idx incorrect.");
mu_assert(to_model->kerneltype == K_RBF, "to->kerneltype incorrect");
- mu_assert(to_model->kernelparam[0] == 5.0,
- "to->kernelparam[0] is incorrect.");
+ mu_assert(to_model->gamma == 5.0, "to->gamma is incorrect.");
gensvm_free_model(from_model);
gensvm_free_model(to_model);
@@ -207,9 +193,8 @@ char *test_copy_model_sigmoid_1()
from_model->kappa = 1.0;
from_model->weight_idx = 2;
from_model->kerneltype = K_SIGMOID;
- from_model->kernelparam = Calloc(double, 2);
- from_model->kernelparam[0] = 5.0;
- from_model->kernelparam[1] = 10.0;
+ from_model->gamma = 5.0;
+ from_model->coef = 10.0;
gensvm_copy_model(from_model, to_model);
@@ -221,10 +206,8 @@ char *test_copy_model_sigmoid_1()
"to_model->weight_idx incorrect.");
mu_assert(to_model->kerneltype == K_SIGMOID,
"to->kerneltype incorrect");
- mu_assert(to_model->kernelparam[0] == 5.0,
- "to->kernelparam[0] is incorrect.");
- mu_assert(to_model->kernelparam[1] == 10.0,
- "to->kernelparam[1] is incorrect.");
+ mu_assert(to_model->gamma == 5.0, "to->gamma is incorrect.");
+ mu_assert(to_model->coef == 10.0, "to->coef is incorrect.");
gensvm_free_model(from_model);
gensvm_free_model(to_model);
@@ -243,10 +226,8 @@ char *test_copy_model_sigmoid_2()
from_model->kappa = 1.0;
from_model->weight_idx = 2;
from_model->kerneltype = K_SIGMOID;
- from_model->kernelparam = Calloc(double, 2);
- from_model->kernelparam[0] = 5.0;
- from_model->kernelparam[1] = 10.0;
- to_model->kernelparam = Calloc(double, 2);
+ from_model->gamma = 5.0;
+ from_model->coef = 10.0;
gensvm_copy_model(from_model, to_model);
@@ -258,10 +239,8 @@ char *test_copy_model_sigmoid_2()
"to_model->weight_idx incorrect.");
mu_assert(to_model->kerneltype == K_SIGMOID,
"to->kerneltype incorrect");
- mu_assert(to_model->kernelparam[0] == 5.0,
- "to->kernelparam[0] is incorrect.");
- mu_assert(to_model->kernelparam[1] == 10.0,
- "to->kernelparam[1] is incorrect.");
+ mu_assert(to_model->gamma == 5.0, "to->gamma is incorrect.");
+ mu_assert(to_model->coef == 10.0, "to->coef is incorrect.");
gensvm_free_model(from_model);
gensvm_free_model(to_model);