bitWrite on an int

I’ve got the following code that I would expect would write all of the bits of the 16-bit int to 1’s, giving me a value of 65535 when I write it to serial. Instead, I get a value of -1. If I change the serial print to Serial.println(test, BIN); I see the value 1111111111111111, so it seems to be doing the right thing, just returning a -1.

void setup() {
  Serial.begin(9600);
}

void loop() {

  int test = 0;
  
  for (int i; i < 16; i++) {
    bitWrite(test, i, 1);
  }
  
  Serial.println(test);
  
  delay(1000);

}

If you want test to be treated as unsigned you have to declare it unsigned.

Thanks for that. Didn't know that.