barelymusician/algorithm/context_free_grammar_test.cpp
// Tests that no substitutions are done when there are no rules given for the
// start symbol.
Tests that no substitutions are done when there are no rules given for the
start symbol.
Tests that no substitutions are done when there are no rules given for the start symbol .
TEST(ContextFreeGrammarTest, GenerateSequenceNoStartSymbolRule) {
  const int kStartSymbol = 3;
  ContextFreeGrammar<int> grammar;
  grammar.AddRule(0, {{10, 11, 12}});
  grammar.AddRule(1, {{13}, {14}});
  grammar.AddRule(2, {{15}});
  Random random;
  const auto sequence = grammar.GenerateSequence(kStartSymbol, random);
  EXPECT_THAT(sequence, ElementsAre(kStartSymbol));
}
TEST ( ContextFreeGrammarTest , GenerateSequenceNoStartSymbolRule ) { const int kStartSymbol = 3 ; ContextFreeGrammar < int > grammar ; grammar . AddRule ( 0 , { { 10 , 11 , 12 } } ) ; grammar . AddRule ( 1 , { { 13 } , { 14 } } ) ; grammar . AddRule ( 2 , { { 15 } } ) ; Random random ; const auto sequence = grammar . GenerateSequence ( kStartSymbol , random ) ; EXPECT_THAT ( sequence , ElementsAre ( kStartSymbol ) ) ; }
Tests that no substitutions are done when there are no rules given for the
start symbol.
Tests that no substitutions are done when there are no rules given for the start symbol .