@@ -721,6 +721,76 @@ TEST_F(TestCLI, testEncoding)
721721 // cleanup
722722 ASSERT_TRUE (deleteFile (outputFilePath.c_str ()));
723723}
724+
725+ TEST_F (TestCLI, testDir)
726+ {
727+ static const std::string expectedFilePath = getExpectedFilePath ();
728+ static const std::string outputFilePath = getActualFilePath ();
729+
730+ std::string headerFileName = std::string (" _" ) + ra::gtesthelp::getTestCaseName ().c_str () + " .h" ;
731+ std::string headerFilePath = gGeneratedFilesDir + headerFileName;
732+ std::string cppFilePath = headerFilePath; ra::strings::replace (cppFilePath, " .h" , " .cpp" );
733+
734+ // build command line
735+ std::string cmdline;
736+ cmdline.append (getBin2cppPath ());
737+ cmdline.append (" --dir=generated_files\\ testDir01\\ images" ); // use windows path separator
738+ cmdline.append (" --output=generated_files\\ testDir01\\ sources" );
739+ cmdline.append (" --noheader" );
740+
741+ cmdline.append (" >" );
742+ cmdline.append (outputFilePath.c_str ());
743+
744+ #ifdef __linux__
745+ // fix path separator
746+ ra::strings::replace (cmdline, " \\ " , " /" );
747+ #endif
748+
749+ // build the list of generated files
750+ const char * generated_files_tmp[] = {
751+ " generated_files\\ testDir01\\ sources\\ IMG_0001.h" ,
752+ " generated_files\\ testDir01\\ sources\\ IMG_0002.h" ,
753+ " generated_files\\ testDir01\\ sources\\ IMG_0003.h" ,
754+ " generated_files\\ testDir01\\ sources\\ IMG_0004.h" ,
755+ " generated_files\\ testDir01\\ sources\\ IMG_0005.h" ,
756+ " generated_files\\ testDir01\\ sources\\ IMG_0001.cpp" ,
757+ " generated_files\\ testDir01\\ sources\\ IMG_0002.cpp" ,
758+ " generated_files\\ testDir01\\ sources\\ IMG_0003.cpp" ,
759+ " generated_files\\ testDir01\\ sources\\ IMG_0004.cpp" ,
760+ " generated_files\\ testDir01\\ sources\\ IMG_0005.cpp" ,
761+ };
762+ const size_t num_generated_files = sizeof (generated_files_tmp)/sizeof (generated_files_tmp[0 ]);
763+ ra::strings::StringVector generated_files;
764+ for (size_t i=0 ; i<num_generated_files; i++)
765+ {
766+ generated_files.push_back (generated_files_tmp[i]);
767+ #ifdef __linux__
768+ ra::strings::replace (generated_files[i], " \\ " , " /" ); // fix path separator
769+ #endif
770+ }
771+
772+ // delete generated files
773+ for (size_t i=0 ; i<generated_files.size (); i++)
774+ {
775+ const std::string & generated_file = generated_files[i];
776+ ASSERT_TRUE (deleteFile (generated_file.c_str ()));
777+ }
778+
779+ // run the command
780+ int returnCode = system (cmdline.c_str ());
781+ ASSERT_EQ (0 , returnCode) << " The command line '" << cmdline.c_str () << " ' returned " << returnCode;
782+
783+ // assert that expected files were generated
784+ for (size_t i=0 ; i<generated_files.size (); i++)
785+ {
786+ const std::string & generates_file = generated_files[i];
787+ ASSERT_TRUE (ra::filesystem::fileExists (generates_file.c_str ())) << " File not found: '" << generates_file.c_str () << " '." ;
788+ }
789+
790+ // cleanup
791+ ASSERT_TRUE (deleteFile (outputFilePath.c_str ()));
792+ }
793+
724794TEST_F (TestCLI, testErrorMissingArgumentFileOrDir)
725795{
726796 static const std::string expectedFilePath = getExpectedFilePath ();
0 commit comments