Add test for kim_identity_create_from_components
authorAlexandra Ellwood <lxs@mit.edu>
Fri, 24 Oct 2008 19:40:35 +0000 (19:40 +0000)
committerAlexandra Ellwood <lxs@mit.edu>
Fri, 24 Oct 2008 19:40:35 +0000 (19:40 +0000)
ticket: new

git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@20917 dc483132-0cff-0310-8789-dd5450dbe970

src/kim/test/main.c
src/kim/test/test_kim_identity.c
src/kim/test/test_kim_identity.h

index 4ba1844dd702839034c517b1c72e8c138b6eb8d6..e3efbd7f6a6a65d8e151ba4451394e6004f28704 100644 (file)
@@ -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);
index e799aade2459bee186d22374dbc7243bdd276e0e..2f1ac089f3281bd4d19c5bdc9d15c14525568ba9 100644 (file)
@@ -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)
index a294c2c3d6c1225800f624b80a20da7f6f0cca03..cb7b29055f80e70088a677cd1aba04cc6fe28f56 100644 (file)
@@ -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);