From: Alexandra Ellwood Date: Fri, 24 Oct 2008 19:40:35 +0000 (+0000) Subject: Add test for kim_identity_create_from_components X-Git-Tag: krb5-1.7-alpha1~266 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=9d3a0fa806297b18967f2108c637e65c6904987c;p=krb5.git Add test for kim_identity_create_from_components ticket: new git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@20917 dc483132-0cff-0310-8789-dd5450dbe970 --- diff --git a/src/kim/test/main.c b/src/kim/test/main.c index 4ba1844dd..e3efbd7f6 100644 --- a/src/kim/test/main.c +++ b/src/kim/test/main.c @@ -40,6 +40,8 @@ int main (int argc, const char * argv[]) test_kim_identity_create_from_string (state); + test_kim_identity_create_from_components (state); + test_kim_identity_copy (state); test_kim_identity_compare (state); diff --git a/src/kim/test/test_kim_identity.c b/src/kim/test/test_kim_identity.c index e799aade2..2f1ac089f 100644 --- a/src/kim/test/test_kim_identity.c +++ b/src/kim/test/test_kim_identity.c @@ -159,6 +159,56 @@ void test_kim_identity_create_from_string (kim_test_state_t state) } +/* ------------------------------------------------------------------------ */ + +void test_kim_identity_create_from_components (kim_test_state_t state) +{ + kim_count i = 0; + + start_test (state, "kim_identity_create_from_components"); + + for (i = 0; test_identities[i].string; i++) { + kim_error err = KIM_NO_ERROR; + kim_identity identity = NULL; + kim_string string = NULL; + + printf ("."); + + if (!err) { + err = kim_identity_create_from_components (&identity, + test_identities[i].realm, + test_identities[i].components[0], + test_identities[i].components[1], + test_identities[i].components[2], + test_identities[i].components[3], + test_identities[i].components[4], + NULL); + fail_if_error (state, "kim_identity_create_from_components", err, + "while creating the identity for %s", + test_identities[i].string); + } + + if (!err) { + err = kim_identity_get_string (identity, &string); + fail_if_error (state, "kim_identity_get_string", err, + "while getting the string for %s", + test_identities[i].string); + } + + if (!err && strcmp (string, test_identities[i].string)) { + log_failure (state, "Unexpected string (got '%s', expected '%s')", + string, test_identities[i].string); + } + + kim_string_free (&string); + kim_identity_free (&identity); + } + + printf ("\n"); + + end_test (state); +} + /* ------------------------------------------------------------------------ */ void test_kim_identity_copy (kim_test_state_t state) diff --git a/src/kim/test/test_kim_identity.h b/src/kim/test/test_kim_identity.h index a294c2c3d..cb7b29055 100644 --- a/src/kim/test/test_kim_identity.h +++ b/src/kim/test/test_kim_identity.h @@ -33,6 +33,8 @@ void test_kim_identity_create_from_krb5_principal (kim_test_state_t state); void test_kim_identity_create_from_string (kim_test_state_t state); +void test_kim_identity_create_from_components (kim_test_state_t state); + void test_kim_identity_copy (kim_test_state_t state); void test_kim_identity_compare (kim_test_state_t state);