Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix uninitialized memory bug in TParameter::copy
- Loading branch information
Showing
3 changed files
with
88 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/* | ||
* THIS IS A GENERATED FILE! DO NOT CHANGE THIS FILE! CHANGE THE | ||
* CORRESPONDING TEMPLATE FILE, PLEASE! | ||
*/ | ||
|
||
#include <shogun/lib/DynamicObjectArray.h> | ||
#include <shogun/base/class_list.h> | ||
#include <gtest/gtest.h> | ||
|
||
using namespace shogun; | ||
|
||
{% set ignores = ['Set', 'ParseBuffer', 'TreeMachine'] %} | ||
|
||
{% for class in classes %} | ||
{% if class in ignores or class.startswith('GUI') %} | ||
TEST(DynamicObjectArray,DISABLED_array_{{class}}_clone_equals) | ||
{% else %} | ||
TEST(DynamicObjectArray,array_{{class}}_clone_equals) | ||
{% endif %} | ||
{ | ||
const char* class_name="{{class}}"; | ||
|
||
/* create source array and fill with {{class}} type objects */ | ||
index_t length=2; | ||
CDynamicObjectArray* array1=new CDynamicObjectArray(); | ||
for (index_t i=0; i<length; ++i) | ||
array1->push_back(new_sgserializable(class_name, PT_NOT_GENERIC)); | ||
|
||
/* test for clone and equals */ | ||
CDynamicObjectArray* array2=dynamic_cast<CDynamicObjectArray*>(array1->clone()); | ||
EXPECT_TRUE(array1->equals(array2)); | ||
|
||
/* cleanup */ | ||
SG_UNREF(array1); | ||
SG_UNREF(array2); | ||
} | ||
{% endfor %} | ||
|
||
{% for class in template_classes %} | ||
{% for type in types %} | ||
{% if class in ignores %} | ||
TEST(DynamicObjectArray,DISABLED_array_{{class}}_{{type}}_clone_equals) | ||
{% else %} | ||
TEST(DynamicObjectArray,array_{{class}}_{{type}}_clone_equals) | ||
{% endif %} | ||
{ | ||
const char* class_name="{{class}}"; | ||
|
||
/* create source array and fill with {{class}} type objects */ | ||
index_t length=2; | ||
CDynamicObjectArray* array1=new CDynamicObjectArray(); | ||
for (index_t i=0; i<length; ++i) | ||
array1->push_back(new_sgserializable(class_name, {{type}})); | ||
|
||
/* test for clone and equals */ | ||
CDynamicObjectArray* array2=dynamic_cast<CDynamicObjectArray*>(array1->clone()); | ||
EXPECT_TRUE(array1->equals(array2)); | ||
|
||
/* cleanup */ | ||
SG_UNREF(array1); | ||
SG_UNREF(array2); | ||
} | ||
{% endfor %} | ||
{% endfor %} | ||
|