add test suite for Ambefilereader, fix a bug where last word was not read #60

feature/NewVoices
Geoffrey Merck 2 months ago
parent 737d09ad9e
commit 455d829f2f

@ -141,7 +141,7 @@ bool CAMBEFileReader::readIndex()
unsigned long start = std::stoul(strt);
unsigned long length = std::stoul(leng);
if (start >= m_ambeLength || (start + length) >= m_ambeLength)
if (start >= m_ambeLength || (start + length) > m_ambeLength)
CLog::logInfo("The start or end for *%s* is out of range, start: %lu, end: %lu\n", name.c_str(), start, start + length);
else
m_index[name] = new CIndexRecord(name, start + SILENCE_LENGTH, length);

@ -0,0 +1,20 @@
bonjour 0 66
cinq 66 50
deux 116 43
dix 159 53
et_demie 212 52
et_quart 264 53
heure 317 44
heures 361 44
huit 405 49
il_est 454 44
midi 498 50
minuit 548 50
moins_le_quart 598 64
neuf 662 51
onze 713 47
quatre 760 49
sept 809 46
six 855 52
trois 907 41
une 948 45

@ -71,30 +71,47 @@ namespace AMBEFileReaderTests
std::vector<CAMBEData *> data;
res = reader.lookup("0", data);
EXPECT_FALSE(res) << "read shall return false on non existent file";
for(auto d : data) {
delete d;
}
for(auto d : data) delete d;
}
TEST_F(AMBEFileReader_lookup, validId)
class AMBEFileReader_lookup_Param : public ::testing::TestWithParam<std::string> {};
TEST_P(AMBEFileReader_lookup_Param, validId)
{
std::string indexFile = std::string(std::filesystem::current_path()) + "/AMBEFileReader/fr_FR.indx";
std::string ambeFile = std::string(std::filesystem::current_path()) + "/AMBEFileReader/fr_FR.ambe";
std::string indexFile = (std::filesystem::current_path() / "AMBEFileReader/TIME_fr_FR2.indx").string();
std::string ambeFile = (std::filesystem::current_path() / "AMBEFileReader/TIME_fr_FR2.ambe").string();
CAMBEFileReader reader(indexFile, ambeFile);
bool res = reader.read();
EXPECT_TRUE(res) << "read shall return true on existent files";
ASSERT_TRUE(res) << "read shall return true on existent files";
std::vector<CAMBEData *> data;
res = reader.lookup("0", data);
EXPECT_TRUE(res) << "read shall return true on existent files and valid Id";
EXPECT_NE(data.size(), 0U) << "Vector shall contain data";
std::vector<CAMBEData*> data;
const std::string& id = GetParam();
for(auto d : data) {
delete d;
}
res = reader.lookup(id, data);
EXPECT_TRUE(res) << "lookup shall return true on valid Id: " << id;
EXPECT_NE(data.size(), 0U) << "Vector shall contain data for Id: " << id;
for (auto* d : data) delete d;
}
static std::string ParamName(
const ::testing::TestParamInfo<std::string>& info)
{
return info.param;
}
INSTANTIATE_TEST_SUITE_P(
AmbeFileReader_lookup_validIds,
AMBEFileReader_lookup_Param,
::testing::Values(
"bonjour", "cinq", "deux", "dix", "et_demie", "et_quart",
"heure", "heures", "huit", "il_est", "midi", "minuit",
"moins_le_quart", "neuf", "onze", "quatre", "sept",
"six", "trois", "une"
),
ParamName
);
TEST_F(AMBEFileReader_lookup, invalidId)
{
std::string indexFile = std::string(std::filesystem::current_path()) + "/AMBEFileReader/fr_FR.indx";

Loading…
Cancel
Save

Powered by TurnKey Linux.