2 * Copyright (c) 2023 Samsung Electronics Co., Ltd. All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 #include "QuantizerLoader.h"
19 #include <gtest/gtest.h>
21 using namespace onert::odc;
23 // Test QuantizerLoader singleton
24 TEST(odc_QuantizerLoader, singleton)
26 QuantizerLoader &loader1 = QuantizerLoader::instance();
27 QuantizerLoader &loader2 = QuantizerLoader::instance();
28 ASSERT_EQ(&loader1, &loader2);
31 // Test load quantizer library
32 TEST(odc_QuantizerLoader, load)
34 QuantizerLoader &loader = QuantizerLoader::instance();
35 // Unload because it may be loaded on previous tests
36 ASSERT_EQ(loader.unloadLibrary(), 0);
38 if (loader.loadLibrary() == 0)
40 // Load twice to check if it is thread-safe
41 ASSERT_EQ(loader.loadLibrary(), 0);
45 // Get quantizer function without loading quantizer library
46 TEST(odc_QuantizerLoader, neg_get)
48 QuantizerLoader &loader = QuantizerLoader::instance();
49 // Unload because it may be loaded on previous tests
50 ASSERT_EQ(loader.unloadLibrary(), 0);
51 ASSERT_EQ(loader.get(), nullptr);
54 // Check quantizer function pointer when QuantizerLoader is unloaded
55 TEST(odc_QuantizerLoader, neg_unload)
57 QuantizerLoader &loader = QuantizerLoader::instance();
58 if (loader.loadLibrary() == 0)
59 ASSERT_NE(loader.get(), nullptr);
61 ASSERT_EQ(loader.unloadLibrary(), 0);
62 ASSERT_EQ(loader.get(), nullptr);