From cb50d6dd5fb0454e58a8eaee9264c020824bd4d5 Mon Sep 17 00:00:00 2001 From: Jeff Donahue Date: Mon, 12 Jan 2015 13:42:51 -0800 Subject: [PATCH] Add unit test for LayerRegistry::CreateLayer --- src/caffe/test/test_layer_factory.cpp | 33 +++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 src/caffe/test/test_layer_factory.cpp diff --git a/src/caffe/test/test_layer_factory.cpp b/src/caffe/test/test_layer_factory.cpp new file mode 100644 index 00000000000..3ad635a792a --- /dev/null +++ b/src/caffe/test/test_layer_factory.cpp @@ -0,0 +1,33 @@ +#include +#include + +#include "gtest/gtest.h" + +#include "caffe/common.hpp" +#include "caffe/layer.hpp" +#include "caffe/layer_factory.hpp" + +#include "caffe/test/test_caffe_main.hpp" + +namespace caffe { + +template +class LayerFactoryTest : public MultiDeviceTest {}; + +TYPED_TEST_CASE(LayerFactoryTest, TestDtypesAndDevices); + +TYPED_TEST(LayerFactoryTest, TestCreateLayer) { + typedef typename TypeParam::Dtype Dtype; + typename LayerRegistry::CreatorRegistry& registry = + LayerRegistry::Registry(); + shared_ptr > layer; + LayerParameter layer_param; + for (typename LayerRegistry::CreatorRegistry::iterator iter = + registry.begin(); iter != registry.end(); ++iter) { + layer_param.set_type(iter->first); + layer.reset(LayerRegistry::CreateLayer(layer_param)); + EXPECT_EQ(iter->first, layer->type()); + } +} + +} // namespace caffe