utils_test.cpp
Go to the documentation of this file.
1 /*
2  * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
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  * A copy of the License is located at
7  *
8  * http://aws.amazon.com/apache2.0
9  *
10  * or in the "license" file accompanying this file. This file is distributed
11  * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
12  * express or implied. See the License for the specific language governing
13  * permissions and limitations under the License.
14  */
15 #include <string>
16 
17 #include <gtest/gtest.h>
18 
19 #include <s3_common/utils.h>
20 
21 TEST(S3CommonUtilsTest, TestGetFileNameEmptyStringReturnsEmptyString)
22 {
23  EXPECT_EQ("", GetFileName(""));
24 }
25 
26 TEST(S3CommonUtilsTest, TestGetFileNameDirectoryReturnsEmptyString)
27 {
28  EXPECT_EQ("", GetFileName("TestDir/"));
29 }
30 
31 TEST(S3CommonUtilsTest, TestGetFileNameNoDirectoryReturnsFileName)
32 {
33  EXPECT_EQ("TestFile", GetFileName("TestFile"));
34 }
35 
36 TEST(S3CommonUtilsTest, TestGetFileNameWithDirectoryReturnsFileName)
37 {
38  EXPECT_EQ("TestFile", GetFileName("TestDir/TestFile"));
39 }
40 
41 TEST(S3CommonUtilsTest, TestGenerateObjectKeyEmptyPrefixReturnsFileName)
42 {
43  EXPECT_EQ("TestFile", GenerateObjectKey("TestFile", ""));
44 }
45 
46 TEST(S3CommonUtilsTest, TestGenerateObjectKeyOnlyUsesFileName)
47 {
48  EXPECT_EQ("prefix/file", GenerateObjectKey("path/to/file", "prefix"));
49 }
50 
51 TEST(S3CommonUtilsTest, TestGenerateObjectKeyInsertSlash)
52 {
53  EXPECT_EQ("prefix/file", GenerateObjectKey("file", "prefix"));
54 }
55 
56 TEST(S3CommonUtilsTest, TestGenerateObjectKeyDoesntInsertExtraSlash)
57 {
58  EXPECT_EQ("prefix/file", GenerateObjectKey("file", "prefix/"));
59 }
std::string GetFileName(const std::string &file_path)
Definition: utils.cpp:4
std::string GenerateObjectKey(const std::string &file_path, const std::string &prefix)
Definition: utils.cpp:14
TEST(S3CommonUtilsTest, TestGetFileNameEmptyStringReturnsEmptyString)
Definition: utils_test.cpp:21


s3_common
Author(s): AWS RoboMaker
autogenerated on Tue Jun 1 2021 02:51:29