Skip to content

Instantly share code, notes, and snippets.

@aruslan
Created January 24, 2012 20:13
Show Gist options
  • Save aruslan/1672293 to your computer and use it in GitHub Desktop.
Save aruslan/1672293 to your computer and use it in GitHub Desktop.
// Вырезка из набора простых boundary test cases парсера C++ комментариев
// 2003-2005 (ц) Руслан "aruslan" Абдикеев
// Константы
std::cout << "C1. This is /* not a comment */\n";
std::cout << "C2. This is // not a comment\n";
std::cout << "C3. This is \" /* not a comment as well*/ \"\n";
std::cout << "C4. This is \" // not a comment as well \"\n";
std::cout << "C5. Let's print some random numbers: " << '/*' << '*/' << '\n';
std::cout << "C6. Let's print a random number: " << '//' << '\n';
std::cout << "C7. This is\" '/*' not a comment '*/' \"\n";
std::cout << "C8. This is\" '//' not a comment \"\n";
// Конец строки
std::cout << "F5. This is "
// line-continuation character: \
"SOMETHING ERRONEOUS BUT" // */
" not a comment\n";
// Триграфы + конец строки
std::cout << "H5. This is obviously "
// Триграфы?! - это что такое???????/
"SOMETHING ERRONEOUS BUT"
" not a comment\n";
// Триграфы + константы
#ifndef __GNUC__ // gcc up to 3.2.3 fails to handle trigraphs in these contexts
std::cout << "J1. This is ??/" /* not a comment */ ??/"\n";
std::cout << "J2. This is ??/" // not a comment at all */ ??/"\n";
std::cout << "??/" '??/' '/*J3. Yeah, baby, this is NOT a comment*/' ??/"\n";
#endif
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment