Switch statement executing all cases regardless of value.....

Can someone explain to me how in the world, the following code is printing out this:
5

6

Default

1

2

3

default

Status:False

boolean setMode(int mode)
{
  boolean command_status = false; 
  boolean result = false; 

  int testint = 0; 

  switch(testint){
    case 0:
      Serial.println("5");
    case 1: 
      Serial.println("6");
    default:
      Serial.println("Default");
  }
  
  switch (mode) {
    case 1:
      Serial.println("1");
      // command_status = sendAtCommand("AT+CWMODE=1",2000,false); 
    case 2:
      Serial.println("2");
      // command_status = sendAtCommand("AT+CWMODE=2",2000,false);  
    case 3:
      Serial.println("3");
      // command_status = sendAtCommand("AT+CWMODE=3",2000,false); 
    default: 
      Serial.println("default");
      // command_status = false; 
  }

  Serial.print("Status:");
  if(result)
  {
    Serial.println("True");   
  }
  else
  {
    Serial.println("False"); 
  }
  
     
  if(command_status) 
  {
    if((unsigned int)strstr(gResponse,"no change") != 0 || (unsigned int)strstr(gResponse,"OK") != 0)
    {
      result = true;
    }
  }

  return result;
}

You need a break statement at the end of the code for each case.

Didn't you notice the pile of warning messages pointing out the possible problem?

/Users/john/Documents/Arduino/sketch_jul29a/sketch_jul29a.ino:19:21: warning: this statement may fall through [-Wimplicit-fallthrough=]
       Serial.println("5");
       ~~~~~~~~~~~~~~^~~~~
/Users/john/Documents/Arduino/sketch_jul29a/sketch_jul29a.ino:20:5: note: here
     case 1:
     ^~~~
/Users/john/Documents/Arduino/sketch_jul29a/sketch_jul29a.ino:21:21: warning: this statement may fall through [-Wimplicit-fallthrough=]
       Serial.println("6");
       ~~~~~~~~~~~~~~^~~~~
/Users/john/Documents/Arduino/sketch_jul29a/sketch_jul29a.ino:22:5: note: here
     default:
     ^~~~~~~
/Users/john/Documents/Arduino/sketch_jul29a/sketch_jul29a.ino:29:21: warning: this statement may fall through [-Wimplicit-fallthrough=]
       Serial.println("1");
       ~~~~~~~~~~~~~~^~~~~
/Users/john/Documents/Arduino/sketch_jul29a/sketch_jul29a.ino:31:5: note: here
     case 2:
     ^~~~
/Users/john/Documents/Arduino/sketch_jul29a/sketch_jul29a.ino:32:21: warning: this statement may fall through [-Wimplicit-fallthrough=]
       Serial.println("2");
       ~~~~~~~~~~~~~~^~~~~
/Users/john/Documents/Arduino/sketch_jul29a/sketch_jul29a.ino:34:5: note: here
     case 3:
     ^~~~
/Users/john/Documents/Arduino/sketch_jul29a/sketch_jul29a.ino:35:21: warning: this statement may fall through [-Wimplicit-fallthrough=]
       Serial.println("3");
       ~~~~~~~~~~~~~~^~~~~
/Users/john/Documents/Arduino/sketch_jul29a/sketch_jul29a.ino:37:5: note: here
     default:
     ^~~~~~~

Rule of Thumb: If your sketch acts strangely, make sure the warning level is set to "All" and look at any warnings you get.

Thanks, still getting used to C++, and didn't know the break was required. I will set the warnings to all now as I didn't get that message. Thanks!

There is a language reference that shows the syntax for most of the Arduino functions.

And the cplusplus.com has a reference for C++.