Improve ssh_options_get(ssh_session, enum ssh_options_e, char**).

* Use SSH_ERROR and SSH_OK instead of `-1` and `0`.
 * Re-factor for code duplication
 * No longer call `ssh_set_error_invalid(ssh_session)` when the
   ssh_session is NULL.
This commit is contained in:
Lee Hambley
2011-10-28 22:52:03 +02:00
committed by Andreas Schneider
parent 2c04994443
commit 17f396ffab
2 changed files with 20 additions and 35 deletions

View File

@@ -83,7 +83,7 @@ static void torture_options_get_user(void **state) {
char* user = NULL;
int rc;
rc = ssh_options_set(session, SSH_OPTIONS_USER, "magicaltrevor");
assert_true(rc == 0);
assert_true(rc == SSH_OK);
rc = ssh_options_get(session, SSH_OPTIONS_USER, &user);
assert_string_equal(user, "magicaltrevor");
}
@@ -98,7 +98,7 @@ static void torture_options_set_fd(void **state) {
assert_true(session->fd == fd);
rc = ssh_options_set(session, SSH_OPTIONS_FD, NULL);
assert_true(rc == -1);
assert_true(rc == SSH_ERROR);
assert_true(session->fd == SSH_INVALID_SOCKET);
}
@@ -161,14 +161,14 @@ static void torture_options_get_identity(void **state) {
rc = ssh_options_set(session, SSH_OPTIONS_ADD_IDENTITY, "identity1");
assert_true(rc == 0);
rc = ssh_options_get(session, SSH_OPTIONS_IDENTITY, &identity);
assert_true(rc == 0);
assert_true(rc == SSH_OK);
assert_string_equal(identity, "identity1");
rc = ssh_options_set(session, SSH_OPTIONS_IDENTITY, "identity2");
assert_true(rc == 0);
assert_string_equal(session->identity->root->data, "identity2");
rc = ssh_options_get(session, SSH_OPTIONS_IDENTITY, &identity);
assert_true(rc == 0);
assert_true(rc == SSH_OK);
assert_string_equal(identity, "identity2");
}