Rolf Badorek | ef2bf51 | 2019-08-20 11:17:15 +0300 | [diff] [blame] | 1 | /* |
| 2 | Copyright (c) 2018-2019 Nokia. |
| 3 | |
| 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 |
| 7 | |
| 8 | http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | |
| 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. |
| 15 | */ |
| 16 | |
| 17 | #include <gtest/gtest.h> |
| 18 | #include "private/namespacevalidator.hpp" |
| 19 | #include <sdl/invalidnamespace.hpp> |
| 20 | #include <sdl/emptynamespace.hpp> |
| 21 | |
| 22 | using namespace shareddatalayer; |
| 23 | |
| 24 | TEST(NamespaceValidatorTest, CanGetDisallowedCharactersInNamespace) |
| 25 | { |
| 26 | EXPECT_EQ(",{}", getDisallowedCharactersInNamespace()); |
| 27 | } |
| 28 | |
| 29 | TEST(NamespaceValidatorTest, CanAcceptValidNamespaceSyntax) |
| 30 | { |
| 31 | EXPECT_TRUE(isValidNamespaceSyntax("someValidNamespace")); |
| 32 | EXPECT_TRUE(isValidNamespaceSyntax("")); |
| 33 | } |
| 34 | |
| 35 | TEST(ValidateNamespaceTest, CanDetectDisallowedCharactersInNamespaceSyntax) |
| 36 | { |
| 37 | EXPECT_FALSE(isValidNamespaceSyntax("some,IllegalNamespace")); |
| 38 | EXPECT_FALSE(isValidNamespaceSyntax("someIllegal{Namespace")); |
| 39 | EXPECT_FALSE(isValidNamespaceSyntax("someIllegalNamespace}")); |
| 40 | } |
| 41 | |
| 42 | TEST(NamespaceValidatorTest, CanAcceptValidNamespace) |
| 43 | { |
| 44 | EXPECT_NO_THROW(validateNamespace("someValidNamespace")); |
| 45 | EXPECT_TRUE(isValidNamespace("someValidNamespace")); |
| 46 | } |
| 47 | |
| 48 | TEST(NamespaceValidatorTest, WillNotAcceptEmptyNamespace) |
| 49 | { |
| 50 | EXPECT_THROW(validateNamespace(""), EmptyNamespace); |
| 51 | EXPECT_FALSE(isValidNamespace("")); |
| 52 | } |
| 53 | |
| 54 | TEST(NamespaceValidatorTest, WillNotAcceptNamespaceContainingDisallowedCharacters) |
| 55 | { |
| 56 | EXPECT_THROW(validateNamespace("some,IllegalNamespace"), InvalidNamespace); |
| 57 | EXPECT_FALSE(isValidNamespace("some,IllegalNamespace")); |
| 58 | EXPECT_THROW(validateNamespace("someIllegal{Namespace}"), InvalidNamespace); |
| 59 | EXPECT_FALSE(isValidNamespace("someIllegal{Namespace}")); |
| 60 | EXPECT_THROW(validateNamespace("some,Illegal{Namespace}"), InvalidNamespace); |
| 61 | EXPECT_FALSE(isValidNamespace("some,Illegal{Namespace}")); |
| 62 | } |