barelymusician/algorithm/context_free_grammar_test.cpp
// Tests that the expected sequence is generated with a given set of nested
// substitution rules.
Tests that the expected sequence is generated with a given set of nested
substitution rules.
Tests that the expected sequence is generated with a given set of nested substitution rules .
TEST(ContextFreeGrammarTest, GenerateSequenceNestedRules) {
  ContextFreeGrammar<std::string> grammar;
  grammar.AddRule("Start", {{"Intro", "Body", "Outro"}});
  grammar.AddRule("Body", {{"Verse", "Chorus", "Bridge"}});
  grammar.AddRule("Bridge", {{"Break", "Chorus"}});
  Random random;
  const auto sequence = grammar.GenerateSequence("Start", random);
  EXPECT_THAT(sequence, ElementsAre("Intro", "Verse", "Chorus", "Break",
                                    "Chorus", "Outro"));
}
TEST ( ContextFreeGrammarTest , GenerateSequenceNestedRules ) { ContextFreeGrammar < std :: string > grammar ; grammar . AddRule ( " " , { { " " , " " , " " } } ) ; grammar . AddRule ( " " , { { " " , " " , " " } } ) ; grammar . AddRule ( " " , { { " " , " " } } ) ; Random random ; const auto sequence = grammar . GenerateSequence ( " " , random ) ; EXPECT_THAT ( sequence , ElementsAre ( " " , " " , " " , " " , " " , " " ) ) ; }
Tests that the expected sequence is generated with a given set of nested
substitution rules.
Tests that the expected sequence is generated with a given set of nested substitution rules .