Skip to content

Commit df91013

Browse files
committed
Fixed unit tests for changes implemented in ef523a2.
1 parent 49de81b commit df91013

File tree

3 files changed

+38
-35
lines changed

3 files changed

+38
-35
lines changed

test/bin2cpp_unittest/TestCLI.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -954,9 +954,13 @@ TEST_F(TestCLI, testAutomaticIdentifierHeaderfile)
954954
std::string cppFilePath = headerFilePath; ra::strings::Replace(cppFilePath, ".h", ".cpp");
955955

956956
//build the expected generated class
957-
std::string expectedClassDeclaration = ra::filesystem::GetFilename(bin2cppPath.c_str());
958-
expectedClassDeclaration = ra::strings::CapitalizeFirstCharacter(expectedClassDeclaration);
959-
expectedClassDeclaration.insert(0, "class ");
957+
std::string expectedClassDeclaration;
958+
std::string name = ra::filesystem::GetFilenameWithoutExtension(bin2cppPath.c_str());
959+
std::string ext = ra::filesystem::GetFileExtention(bin2cppPath.c_str());
960+
name = ra::strings::CapitalizeFirstCharacter(name);
961+
ext = ra::strings::CapitalizeFirstCharacter(ext );
962+
expectedClassDeclaration = "class ";
963+
expectedClassDeclaration += (name + ext);
960964
expectedClassDeclaration += "File";
961965
ra::strings::Replace(expectedClassDeclaration, ".", ""); // remove the dot from bin2cpp.exe on Windows
962966
ra::strings::Replace(expectedClassDeclaration, "-", ""); // remove the dash from bin2cpp-d.exe on Windows

test/bin2cpp_unittest/TestCommon.cpp

Lines changed: 29 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -54,21 +54,21 @@ TEST_F(TestCommon, testGetFunctionIdentifierFromPath)
5454

5555
path = www_directory + "\\static\\css\\theme.dark.css";
5656
ra::filesystem::NormalizePath(path);
57-
ASSERT_EQ("themedarkcss", bin2cpp::getFunctionIdentifierFromPath(path));
57+
ASSERT_EQ("ThemedarkCss", bin2cpp::getFunctionIdentifierFromPath(path));
5858

5959
//test running twice returns the same value
6060
path = www_directory + "\\static\\css\\theme.dark.css";
6161
ra::filesystem::NormalizePath(path);
62-
ASSERT_EQ("themedarkcss", bin2cpp::getFunctionIdentifierFromPath(path));
62+
ASSERT_EQ("ThemedarkCss", bin2cpp::getFunctionIdentifierFromPath(path));
6363

6464
//test with only a filename
65-
ASSERT_EQ("themedarkcss", bin2cpp::getFunctionIdentifierFromPath("theme.dark.css"));
65+
ASSERT_EQ("ThemedarkCss", bin2cpp::getFunctionIdentifierFromPath("theme.dark.css"));
6666

6767
//test valid special characters
68-
ASSERT_EQ("hello_world_1234567890", bin2cpp::getFunctionIdentifierFromPath("hello_world_1234567890"));
68+
ASSERT_EQ("Hello_world_1234567890", bin2cpp::getFunctionIdentifierFromPath("hello_world_1234567890"));
6969

7070
//test more invalid characters
71-
ASSERT_EQ("index1234bangdollars", bin2cpp::getFunctionIdentifierFromPath("index.1234.bang!.dollars$"));
71+
ASSERT_EQ("Index1234bangDollars", bin2cpp::getFunctionIdentifierFromPath("index.1234.bang!.dollars$"));
7272
}
7373

7474
TEST_F(TestCommon, testGetUniqueFunctionIdentifierFromPath)
@@ -81,48 +81,47 @@ TEST_F(TestCommon, testGetUniqueFunctionIdentifierFromPath)
8181
path = www_directory + "\\static\\css\\theme.dark.css";
8282
ra::filesystem::NormalizePath(path);
8383

84-
ASSERT_EQ("themedarkcss", bin2cpp::getUniqueFunctionIdentifierFromPath(path, tmp));
84+
ASSERT_EQ("ThemedarkCss", bin2cpp::getUniqueFunctionIdentifierFromPath(path, tmp));
8585

8686
//test duplicates
87-
ASSERT_EQ("themedarkcss_1", bin2cpp::getUniqueFunctionIdentifierFromPath(path, tmp));
88-
ASSERT_EQ("themedarkcss_2", bin2cpp::getUniqueFunctionIdentifierFromPath(path, tmp));
89-
ASSERT_EQ("themedarkcss_3", bin2cpp::getUniqueFunctionIdentifierFromPath(path, tmp));
90-
ASSERT_EQ("themedarkcss_4", bin2cpp::getUniqueFunctionIdentifierFromPath(path, tmp));
91-
ASSERT_EQ("themedarkcss_5", bin2cpp::getUniqueFunctionIdentifierFromPath(path, tmp));
87+
ASSERT_EQ("ThemedarkCss_1", bin2cpp::getUniqueFunctionIdentifierFromPath(path, tmp));
88+
ASSERT_EQ("ThemedarkCss_2", bin2cpp::getUniqueFunctionIdentifierFromPath(path, tmp));
89+
ASSERT_EQ("ThemedarkCss_3", bin2cpp::getUniqueFunctionIdentifierFromPath(path, tmp));
90+
ASSERT_EQ("ThemedarkCss_4", bin2cpp::getUniqueFunctionIdentifierFromPath(path, tmp));
91+
ASSERT_EQ("ThemedarkCss_5", bin2cpp::getUniqueFunctionIdentifierFromPath(path, tmp));
9292
}
9393

9494
//test behavior with files that ends with numbers
9595
{
9696
path = temp_directory + "\\index.001";
9797
ra::filesystem::NormalizePath(path);
9898

99-
ASSERT_EQ("index001", bin2cpp::getUniqueFunctionIdentifierFromPath(path, tmp));
99+
ASSERT_EQ("Index001", bin2cpp::getUniqueFunctionIdentifierFromPath(path, tmp));
100100

101101
//test duplicates
102-
ASSERT_EQ("index001_1", bin2cpp::getUniqueFunctionIdentifierFromPath(path, tmp));
103-
ASSERT_EQ("index001_2", bin2cpp::getUniqueFunctionIdentifierFromPath(path, tmp));
104-
ASSERT_EQ("index001_3", bin2cpp::getUniqueFunctionIdentifierFromPath(path, tmp));
105-
ASSERT_EQ("index001_4", bin2cpp::getUniqueFunctionIdentifierFromPath(path, tmp));
106-
ASSERT_EQ("index001_5", bin2cpp::getUniqueFunctionIdentifierFromPath(path, tmp));
102+
ASSERT_EQ("Index001_1", bin2cpp::getUniqueFunctionIdentifierFromPath(path, tmp));
103+
ASSERT_EQ("Index001_2", bin2cpp::getUniqueFunctionIdentifierFromPath(path, tmp));
104+
ASSERT_EQ("Index001_3", bin2cpp::getUniqueFunctionIdentifierFromPath(path, tmp));
105+
ASSERT_EQ("Index001_4", bin2cpp::getUniqueFunctionIdentifierFromPath(path, tmp));
106+
ASSERT_EQ("Index001_5", bin2cpp::getUniqueFunctionIdentifierFromPath(path, tmp));
107107
}
108108

109109
//try to bug the system: get an identifier from a file which is already a duplicate identifer.
110-
ASSERT_EQ("themedarkcss_3_1", bin2cpp::getUniqueFunctionIdentifierFromPath("themedarkcss_3", tmp));
110+
ASSERT_EQ("ThemedarkCss_3_1", bin2cpp::getUniqueFunctionIdentifierFromPath("ThemedarkCss_3", tmp));
111111

112112
//test getting duplicate identifiers because of invalid characters
113113
{
114114
path = www_directory + "\\static\\js";
115115
ra::filesystem::NormalizePath(path);
116116
path += slash;
117117

118-
ASSERT_EQ("jqueryjs", bin2cpp::getUniqueFunctionIdentifierFromPath(path + "jquery.js", tmp));
118+
ASSERT_EQ("JqueryJs", bin2cpp::getUniqueFunctionIdentifierFromPath(path + "jquery.js", tmp));
119119

120120
//test duplicates
121-
ASSERT_EQ("jqueryjs_1", bin2cpp::getUniqueFunctionIdentifierFromPath(path + "j.query.js" , tmp));
122-
ASSERT_EQ("jqueryjs_2", bin2cpp::getUniqueFunctionIdentifierFromPath(path + "j!qu!ery.js" , tmp));
123-
ASSERT_EQ("jqueryjs_3", bin2cpp::getUniqueFunctionIdentifierFromPath(path + "j-query.js" , tmp));
124-
ASSERT_EQ("jqueryjs_4", bin2cpp::getUniqueFunctionIdentifierFromPath(path + "jqu.er.y.js" , tmp));
125-
ASSERT_EQ("jqueryjs_5", bin2cpp::getUniqueFunctionIdentifierFromPath(path + "jqueryjs" , tmp));
121+
ASSERT_EQ("JqueryJs_1", bin2cpp::getUniqueFunctionIdentifierFromPath(path + "j.query.js" , tmp));
122+
ASSERT_EQ("JqueryJs_2", bin2cpp::getUniqueFunctionIdentifierFromPath(path + "j!qu!ery.js" , tmp));
123+
ASSERT_EQ("JqueryJs_3", bin2cpp::getUniqueFunctionIdentifierFromPath(path + "j-query.js" , tmp));
124+
ASSERT_EQ("JqueryJs_4", bin2cpp::getUniqueFunctionIdentifierFromPath(path + "jqu.er.y.js" , tmp));
126125
}
127126

128127
//test getting duplicates from different directories
@@ -131,14 +130,14 @@ TEST_F(TestCommon, testGetUniqueFunctionIdentifierFromPath)
131130
ra::filesystem::NormalizePath(path);
132131
path += slash;
133132

134-
ASSERT_EQ("indexhtml", bin2cpp::getUniqueFunctionIdentifierFromPath(path + "index.html", tmp));
133+
ASSERT_EQ("IndexHtml", bin2cpp::getUniqueFunctionIdentifierFromPath(path + "index.html", tmp));
135134

136135
//test duplicates
137-
ASSERT_EQ("indexhtml_1", bin2cpp::getUniqueFunctionIdentifierFromPath(path + "home" + slash + "index.html" , tmp));
138-
ASSERT_EQ("indexhtml_2", bin2cpp::getUniqueFunctionIdentifierFromPath(path + "blog" + slash + "index.html" , tmp));
139-
ASSERT_EQ("indexhtml_3", bin2cpp::getUniqueFunctionIdentifierFromPath(path + "blog" + slash + "how-to-create-a-web-site" + slash + "index.html" , tmp));
140-
ASSERT_EQ("indexhtml_4", bin2cpp::getUniqueFunctionIdentifierFromPath(path + "contact" + slash + "index.html" , tmp));
141-
ASSERT_EQ("indexhtml_5", bin2cpp::getUniqueFunctionIdentifierFromPath(path + "blog" + slash + "using-bin2cpp" + slash + "index.html" , tmp));
136+
ASSERT_EQ("IndexHtml_1", bin2cpp::getUniqueFunctionIdentifierFromPath(path + "home" + slash + "index.html" , tmp));
137+
ASSERT_EQ("IndexHtml_2", bin2cpp::getUniqueFunctionIdentifierFromPath(path + "blog" + slash + "index.html" , tmp));
138+
ASSERT_EQ("IndexHtml_3", bin2cpp::getUniqueFunctionIdentifierFromPath(path + "blog" + slash + "how-to-create-a-web-site" + slash + "index.html" , tmp));
139+
ASSERT_EQ("IndexHtml_4", bin2cpp::getUniqueFunctionIdentifierFromPath(path + "contact" + slash + "index.html" , tmp));
140+
ASSERT_EQ("IndexHtml_5", bin2cpp::getUniqueFunctionIdentifierFromPath(path + "blog" + slash + "using-bin2cpp" + slash + "index.html" , tmp));
142141
}
143142
}
144143

test/bin2cpp_unittest/TestExtraction.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -598,15 +598,15 @@ TEST_F(TestExtraction, testIssue56a)
598598
std::string path = "generated_files/testIssue56a/compiled_sources/_testIssue56a.index.1234.h";
599599
ra::filesystem::NormalizePath(path);
600600
ASSERT_TRUE( ra::filesystem::FileExists(path.c_str()) ) << "File '" << path.c_str() << "' not found!";
601-
ASSERT_TRUE( ra::testing::FindInFile(path.c_str(), "get_testIssue56aindex1234cssFile()", line, index) );
601+
ASSERT_TRUE( ra::testing::FindInFile(path.c_str(), "get_testIssue56aindex1234CssFile()", line, index) );
602602
}
603603

604604
//_testIssue56a.index.4321.h
605605
{
606606
std::string path = "generated_files/testIssue56a/compiled_sources/_testIssue56a.index.4321.h";
607607
ra::filesystem::NormalizePath(path);
608608
ASSERT_TRUE( ra::filesystem::FileExists(path.c_str()) ) << "File '" << path.c_str() << "' not found!";
609-
ASSERT_TRUE( ra::testing::FindInFile(path.c_str(), "get_testIssue56aindex4321cssFile()", line, index) );
609+
ASSERT_TRUE( ra::testing::FindInFile(path.c_str(), "get_testIssue56aindex4321CssFile()", line, index) );
610610
}
611611
}
612612

0 commit comments

Comments
 (0)