Assuming I have 2 roles set up:

rid 1 = 'Customer'
rid 2 = 'Management'

$newUser = array(
      'name' => $name,
      'pass' => $password,
      'mail' => $mail,
      'status' => 1,
      'roles' => array(1 => 'Management'),
      'notify' => 1
      );
$user = user_save(null, $newUser);

The above code would still validate and assign the customer permission to the user although the role title does not match the role id.