Publishing 2019 R1 content
[platform/upstream/dldt.git] / inference-engine / tests / unit / inference_engine_tests / caslesseq_tests.cpp
1 // Copyright (C) 2018-2019 Intel Corporation
2 // SPDX-License-Identifier: Apache-2.0
3 //
4
5 #include <gtest/gtest.h>
6 #include <unordered_map>
7 #include "details/caseless.hpp"
8 #include "debug.h"
9
10 using namespace std;
11 using namespace InferenceEngine::details;
12
13 class CaselessTests : public ::testing::Test {
14  protected:
15     virtual void TearDown() {
16     }
17
18     virtual void SetUp() {
19     }
20
21  public:
22
23 };
24
25 TEST_F(CaselessTests, emptyAreEqual) {
26     ASSERT_TRUE(InferenceEngine::details::equal("", ""));
27 }
28
29 TEST_F(CaselessTests, canIgnoreCase) {
30     ASSERT_TRUE(InferenceEngine::details::equal("abc", "ABC"));
31 }
32
33 TEST_F(CaselessTests, emptyIsNotEqualNotEmpty) {
34     ASSERT_FALSE(InferenceEngine::details::equal("", "abc"));
35 }
36
37 TEST_F(CaselessTests, canFindCaslessInMap) {
38     caseless_map<string, int> storage = {
39         {"Abc", 1},
40         {"bC", 2},
41         {"AbcD", 3},
42     };
43     ASSERT_EQ(storage["abc"], 1);
44     ASSERT_EQ(storage["ABC"], 1);
45     ASSERT_EQ(storage["BC"], 2);
46     ASSERT_EQ(storage["aBCd"], 3);
47     ASSERT_EQ(storage.find("aBd"), storage.end());
48     ASSERT_EQ(storage.find(""), storage.end());
49 }
50
51 TEST_F(CaselessTests, canFindCaslessInUnordered) {
52
53     caseless_unordered_map <string, int> storage = {
54         {"Abc", 1},
55         {"bC", 2},
56         {"AbcD", 3},
57     };
58     ASSERT_EQ(storage["abc"], 1);
59     ASSERT_EQ(storage["ABC"], 1);
60     ASSERT_EQ(storage["BC"], 2);
61     ASSERT_EQ(storage["aBCd"], 3);
62     ASSERT_EQ(storage.find("aBd"), storage.end());
63     ASSERT_EQ(storage.find(""), storage.end());
64 }