Merge "Allow spaces in DAB frequency labels and make it up to 7 characters long."

This commit is contained in:
Tomasz Wasilczyk 2018-01-19 19:38:13 +00:00 committed by Android (Google) Code Review
commit d773e954a4
2 changed files with 7 additions and 3 deletions

View file

@ -215,7 +215,9 @@ struct DabTableEntry {
/**
* Channel name, i.e. 5A, 7B.
*
* It must match the following regular expression: /^[A-Z0-9]{2,5}$/.
* It must match the following regular expression:
* /^[A-Z0-9][A-Z0-9 ]{0,5}[A-Z0-9]$/ (2-7 uppercase alphanumeric characters
* without spaces allowed at the beginning nor end).
*/
string label;

View file

@ -342,11 +342,13 @@ TEST_F(BroadcastRadioHalTest, GetDabRegionConfig) {
}
ASSERT_EQ(Result::OK, halResult);
std::regex re("^[A-Z0-9]{2,5}$");
std::regex re("^[A-Z0-9][A-Z0-9 ]{0,5}[A-Z0-9]$");
// double-check correctness of the test
ASSERT_TRUE(std::regex_match("5A", re));
ASSERT_FALSE(std::regex_match("5a", re));
ASSERT_FALSE(std::regex_match("123ABC", re));
ASSERT_FALSE(std::regex_match("1234ABCD", re));
ASSERT_TRUE(std::regex_match("CN 12D", re));
ASSERT_FALSE(std::regex_match(" 5A", re));
for (auto&& entry : config) {
EXPECT_TRUE(std::regex_match(std::string(entry.label), re));