More tests cases for switch
@@ -93,13 +93,134 @@ void fallthrough_several_cases_including_default()
}
}
+void scoped_match_a_single_case()
+{
+ switch (1)
+ {
+ case 0:
+ {
+ printf("a 0\n");
+ break;
+ }
+ case 1:
+ {
+ printf("a 1\n");
+ break;
+ }
+ case 2:
+ {
+ printf("a 2\n");
+ break;
+ }
+ default:
+ {
+ printf("a default\n");
+ break;
+ }
+ }
+}
+
+void scoped_fallthrough_to_next_case()
+{
+ switch (1)
+ {
+ case 0:
+ {
+ printf("b 0\n");
+ break;
+ }
+ case 1:
+ {
+ printf("b 1\n");
+ }
+ case 2:
+ {
+ printf("b 2\n");
+ break;
+ }
+ default:
+ {
+ printf("b default\n");
+ break;
+ }
+ }
+}
+
+void scoped_match_no_cases()
+{
+ switch (1)
+ {
+ case 5:
+ {
+ printf("c 5\n");
+ break;
+ }
+ case 2:
+ {
+ printf("c 2\n");
+ break;
+ }
+ }
+}
+
+void scoped_match_default()
+{
+ switch (1)
+ {
+ case 5:
+ {
+ printf("d 5\n");
+ break;
+ }
+ case 2:
+ {
+ printf("d 2\n");
+ break;
+ }
+ default:
+ {
+ printf("d default\n");
+ break;
+ }
+ }
+}
+
+void scoped_fallthrough_several_cases_including_default()
+{
+ switch (1)
+ {
+ case 0:
+ {
+ printf("e 0\n");
+ }
+ case 1:
+ {
+ printf("e 1\n");
+ }
+ case 2:
+ {
+ printf("e 2\n");
+ }
+ default:
+ {
+ printf("e default\n");
+ }
+ }
+}
+
int main()
{
- // For each of the tests below there will be an identical case that uses
- // scopes for the case statements.
match_a_single_case();
fallthrough_to_next_case();
match_no_cases();
match_default();
fallthrough_several_cases_including_default();
+
+ // For each of the tests above there will be identical cases that use scopes
+ // for the case statements.
+ scoped_match_a_single_case();
+ scoped_fallthrough_to_next_case();
+ scoped_match_no_cases();
+ scoped_match_default();
+ scoped_fallthrough_several_cases_including_default();
}
