misc: Replace struct cr_NVREA * with cr_NVREA *
authorTomas Mlcoch <tmlcoch@redhat.com>
Wed, 16 Jul 2014 12:27:24 +0000 (14:27 +0200)
committerTomas Mlcoch <tmlcoch@redhat.com>
Wed, 16 Jul 2014 12:27:40 +0000 (14:27 +0200)
src/misc.c
src/misc.h
tests/test_misc.c

index d203d46..ef2e682 100644 (file)
@@ -984,10 +984,10 @@ cr_slist_free_full(GSList *list, GDestroyNotify free_f)
 }
 
 
-struct cr_NVREA *
+cr_NVREA *
 cr_split_rpm_filename(const char *filename)
 {
-    struct cr_NVREA *res = NULL;
+    cr_NVREA *res = NULL;
     gchar *str, *copy;
     size_t len;
     int i;
@@ -995,7 +995,7 @@ cr_split_rpm_filename(const char *filename)
     if (!filename)
         return res;
 
-    res = g_malloc0(sizeof(struct cr_NVREA));
+    res = g_new0(cr_NVREA, 1);
     str = g_strdup(filename);
     copy = str;
     len = strlen(str);
@@ -1051,7 +1051,7 @@ cr_split_rpm_filename(const char *filename)
 
 
 void
-cr_nvrea_free(struct cr_NVREA *nvrea)
+cr_nvrea_free(cr_NVREA *nvrea)
 {
     if (!nvrea)
         return;
index f074e11..4bbf333 100644 (file)
@@ -63,13 +63,13 @@ typedef struct {
 
 /** Name-Version-Release-Epoch-Arch representation.
  */
-struct cr_NVREA {
+typedef struct {
     char *name;         /*!< name */
     char *version;      /*!< version */
     char *release;      /*!< release */
     char *epoch;        /*!< epoch */
     char *arch;         /*!< arch */
-};
+} cr_NVREA;
 
 typedef struct {
     char *name;
@@ -302,16 +302,16 @@ void cr_log_fn(const gchar *log_domain,
  */
 void cr_slist_free_full(GSList *list, GDestroyNotify free_f);
 
-/** Split filename into the NVREA structure.
+/** Split filename into the NVREA.
  * @param filename      filename
- * @return              struct cr_NVREA
+ * @return              cr_NVREA
  */
-struct cr_NVREA *cr_split_rpm_filename(const char *filename);
+cr_NVREA *cr_split_rpm_filename(const char *filename);
 
-/** Free struct cr_NVREA.
- * @param nvrea         struct cr_NVREA
+/** Free cr_NVREA.
+ * @param nvrea         cr_NVREA
  */
-void cr_nvrea_free(struct cr_NVREA *nvrea);
+void cr_nvrea_free(cr_NVREA *nvrea);
 
 /** Compare evr of two cr_NVREA. Name and arch are ignored.
  * @param A     pointer to first cr_NVREA
index 80dfacd..edafa3a 100644 (file)
 static void
 test_cr_str_to_evr(void)
 {
-    struct cr_EVR evr;
+    cr_EVR *evr;
 
     // V
 
     evr = cr_str_to_evr("5.0.0", NULL);
-    g_assert_cmpstr(evr.epoch, ==, "0");
-    g_assert_cmpstr(evr.version, ==, "5.0.0");
-    g_assert_cmpstr(evr.release, ==, NULL);
-    free(evr.epoch);
-    free(evr.version);
-    free(evr.release);
+    g_assert_cmpstr(evr->epoch, ==, "0");
+    g_assert_cmpstr(evr->version, ==, "5.0.0");
+    g_assert_cmpstr(evr->release, ==, NULL);
+    cr_evr_free(evr);
 
     evr = cr_str_to_evr("6.1", NULL);
-    g_assert_cmpstr(evr.epoch, ==, "0");
-    g_assert_cmpstr(evr.version, ==, "6.1");
-    g_assert_cmpstr(evr.release, ==, NULL);
-    free(evr.epoch);
-    free(evr.version);
-    free(evr.release);
+    g_assert_cmpstr(evr->epoch, ==, "0");
+    g_assert_cmpstr(evr->version, ==, "6.1");
+    g_assert_cmpstr(evr->release, ==, NULL);
+    cr_evr_free(evr);
 
     evr = cr_str_to_evr("7", NULL);
-    g_assert_cmpstr(evr.epoch, ==, "0");
-    g_assert_cmpstr(evr.version, ==, "7");
-    g_assert_cmpstr(evr.release, ==, NULL);
-    free(evr.epoch);
-    free(evr.version);
-    free(evr.release);
+    g_assert_cmpstr(evr->epoch, ==, "0");
+    g_assert_cmpstr(evr->version, ==, "7");
+    g_assert_cmpstr(evr->release, ==, NULL);
+    cr_evr_free(evr);
 
     // VR
 
     evr = cr_str_to_evr("5.0.0-2", NULL);
-    g_assert_cmpstr(evr.epoch, ==, "0");
-    g_assert_cmpstr(evr.version, ==, "5.0.0");
-    g_assert_cmpstr(evr.release, ==, "2");
-    free(evr.epoch);
-    free(evr.version);
-    free(evr.release);
+    g_assert_cmpstr(evr->epoch, ==, "0");
+    g_assert_cmpstr(evr->version, ==, "5.0.0");
+    g_assert_cmpstr(evr->release, ==, "2");
+    cr_evr_free(evr);
 
     evr = cr_str_to_evr("6.1-3", NULL);
-    g_assert_cmpstr(evr.epoch, ==, "0");
-    g_assert_cmpstr(evr.version, ==, "6.1");
-    g_assert_cmpstr(evr.release, ==, "3");
-    free(evr.epoch);
-    free(evr.version);
-    free(evr.release);
+    g_assert_cmpstr(evr->epoch, ==, "0");
+    g_assert_cmpstr(evr->version, ==, "6.1");
+    g_assert_cmpstr(evr->release, ==, "3");
+    cr_evr_free(evr);
 
     evr = cr_str_to_evr("7-4", NULL);
-    g_assert_cmpstr(evr.epoch, ==, "0");
-    g_assert_cmpstr(evr.version, ==, "7");
-    g_assert_cmpstr(evr.release, ==, "4");
-    free(evr.epoch);
-    free(evr.version);
-    free(evr.release);
+    g_assert_cmpstr(evr->epoch, ==, "0");
+    g_assert_cmpstr(evr->version, ==, "7");
+    g_assert_cmpstr(evr->release, ==, "4");
+    cr_evr_free(evr);
 
     // EV
 
     evr = cr_str_to_evr("1:5.0.0", NULL);
-    g_assert_cmpstr(evr.epoch, ==, "1");
-    g_assert_cmpstr(evr.version, ==, "5.0.0");
-    g_assert_cmpstr(evr.release, ==, NULL);
-    free(evr.epoch);
-    free(evr.version);
-    free(evr.release);
+    g_assert_cmpstr(evr->epoch, ==, "1");
+    g_assert_cmpstr(evr->version, ==, "5.0.0");
+    g_assert_cmpstr(evr->release, ==, NULL);
+    cr_evr_free(evr);
 
     evr = cr_str_to_evr("2:6.1", NULL);
-    g_assert_cmpstr(evr.epoch, ==, "2");
-    g_assert_cmpstr(evr.version, ==, "6.1");
-    g_assert_cmpstr(evr.release, ==, NULL);
-    free(evr.epoch);
-    free(evr.version);
-    free(evr.release);
+    g_assert_cmpstr(evr->epoch, ==, "2");
+    g_assert_cmpstr(evr->version, ==, "6.1");
+    g_assert_cmpstr(evr->release, ==, NULL);
+    cr_evr_free(evr);
 
     evr = cr_str_to_evr("3:7", NULL);
-    g_assert_cmpstr(evr.epoch, ==, "3");
-    g_assert_cmpstr(evr.version, ==, "7");
-    g_assert_cmpstr(evr.release, ==, NULL);
-    free(evr.epoch);
-    free(evr.version);
-    free(evr.release);
+    g_assert_cmpstr(evr->epoch, ==, "3");
+    g_assert_cmpstr(evr->version, ==, "7");
+    g_assert_cmpstr(evr->release, ==, NULL);
+    cr_evr_free(evr);
 
     //cr_EVR
 
     evr = cr_str_to_evr("1:5.0.0-11", NULL);
-    g_assert_cmpstr(evr.epoch, ==, "1");
-    g_assert_cmpstr(evr.version, ==, "5.0.0");
-    g_assert_cmpstr(evr.release, ==, "11");
-    free(evr.epoch);
-    free(evr.version);
-    free(evr.release);
+    g_assert_cmpstr(evr->epoch, ==, "1");
+    g_assert_cmpstr(evr->version, ==, "5.0.0");
+    g_assert_cmpstr(evr->release, ==, "11");
+    cr_evr_free(evr);
 
     evr = cr_str_to_evr("2:6.1-22", NULL);
-    g_assert_cmpstr(evr.epoch, ==, "2");
-    g_assert_cmpstr(evr.version, ==, "6.1");
-    g_assert_cmpstr(evr.release, ==, "22");
-    free(evr.epoch);
-    free(evr.version);
-    free(evr.release);
+    g_assert_cmpstr(evr->epoch, ==, "2");
+    g_assert_cmpstr(evr->version, ==, "6.1");
+    g_assert_cmpstr(evr->release, ==, "22");
+    cr_evr_free(evr);
 
     evr = cr_str_to_evr("3:7-33", NULL);
-    g_assert_cmpstr(evr.epoch, ==, "3");
-    g_assert_cmpstr(evr.version, ==, "7");
-    g_assert_cmpstr(evr.release, ==, "33");
-    free(evr.epoch);
-    free(evr.version);
-    free(evr.release);
+    g_assert_cmpstr(evr->epoch, ==, "3");
+    g_assert_cmpstr(evr->version, ==, "7");
+    g_assert_cmpstr(evr->release, ==, "33");
+    cr_evr_free(evr);
 
     // Bad strings
 
     evr = cr_str_to_evr(":", NULL);
-    g_assert_cmpstr(evr.epoch, ==, "0");
-    g_assert_cmpstr(evr.version, ==, "");
-    g_assert_cmpstr(evr.release, ==, NULL);
-    free(evr.epoch);
-    free(evr.version);
-    free(evr.release);
+    g_assert_cmpstr(evr->epoch, ==, "0");
+    g_assert_cmpstr(evr->version, ==, "");
+    g_assert_cmpstr(evr->release, ==, NULL);
+    cr_evr_free(evr);
 
     evr = cr_str_to_evr(":-", NULL);
-    g_assert_cmpstr(evr.epoch, ==, "0");
-    g_assert_cmpstr(evr.version, ==, "");
-    g_assert_cmpstr(evr.release, ==, NULL);
-    free(evr.epoch);
-    free(evr.version);
-    free(evr.release);
+    g_assert_cmpstr(evr->epoch, ==, "0");
+    g_assert_cmpstr(evr->version, ==, "");
+    g_assert_cmpstr(evr->release, ==, NULL);
+    cr_evr_free(evr);
 
     // Really bad values
 
     evr = cr_str_to_evr(NULL, NULL);
-    g_assert_cmpstr(evr.epoch, ==, NULL);
-    g_assert_cmpstr(evr.version, ==, NULL);
-    g_assert_cmpstr(evr.release, ==, NULL);
-    free(evr.epoch);
-    free(evr.version);
-    free(evr.release);
+    g_assert_cmpstr(evr->epoch, ==, NULL);
+    g_assert_cmpstr(evr->version, ==, NULL);
+    g_assert_cmpstr(evr->release, ==, NULL);
+    cr_evr_free(evr);
 
     evr = cr_str_to_evr("", NULL);
-    g_assert_cmpstr(evr.epoch, ==, NULL);
-    g_assert_cmpstr(evr.version, ==, NULL);
-    g_assert_cmpstr(evr.release, ==, NULL);
-    free(evr.epoch);
-    free(evr.version);
-    free(evr.release);
+    g_assert_cmpstr(evr->epoch, ==, NULL);
+    g_assert_cmpstr(evr->version, ==, NULL);
+    g_assert_cmpstr(evr->release, ==, NULL);
+    cr_evr_free(evr);
 
     evr = cr_str_to_evr("-", NULL);
-    g_assert_cmpstr(evr.epoch, ==, "0");
-    g_assert_cmpstr(evr.version, ==, "");
-    g_assert_cmpstr(evr.release, ==, NULL);
-    free(evr.epoch);
-    free(evr.version);
-    free(evr.release);
+    g_assert_cmpstr(evr->epoch, ==, "0");
+    g_assert_cmpstr(evr->version, ==, "");
+    g_assert_cmpstr(evr->release, ==, NULL);
+    cr_evr_free(evr);
 
     evr = cr_str_to_evr("-:", NULL);
-    g_assert_cmpstr(evr.epoch, ==, "0");
-    g_assert_cmpstr(evr.version, ==, "");
-    g_assert_cmpstr(evr.release, ==, NULL);
-    free(evr.epoch);
-    free(evr.version);
-    free(evr.release);
+    g_assert_cmpstr(evr->epoch, ==, "0");
+    g_assert_cmpstr(evr->version, ==, "");
+    g_assert_cmpstr(evr->release, ==, NULL);
+    cr_evr_free(evr);
 
     evr = cr_str_to_evr("foo:bar", NULL);
-    g_assert_cmpstr(evr.epoch, ==, "0");
-    g_assert_cmpstr(evr.version, ==, "bar");
-    g_assert_cmpstr(evr.release, ==, NULL);
-    free(evr.epoch);
-    free(evr.version);
-    free(evr.release);
+    g_assert_cmpstr(evr->epoch, ==, "0");
+    g_assert_cmpstr(evr->version, ==, "bar");
+    g_assert_cmpstr(evr->release, ==, NULL);
+    cr_evr_free(evr);
 }
 
 
 static void
 test_cr_str_to_evr_with_chunk(void)
 {
-    struct cr_EVR evr;
+    cr_EVR *evr;
     GStringChunk *chunk;
     chunk = g_string_chunk_new(512);
 
     // V
 
     evr = cr_str_to_evr("5.0.0", chunk);
-    g_assert_cmpstr(evr.epoch, ==, "0");
-    g_assert_cmpstr(evr.version, ==, "5.0.0");
-    g_assert_cmpstr(evr.release, ==, NULL);
+    g_assert_cmpstr(evr->epoch, ==, "0");
+    g_assert_cmpstr(evr->version, ==, "5.0.0");
+    g_assert_cmpstr(evr->release, ==, NULL);
+    g_free(evr);
 
     evr = cr_str_to_evr("6.1", chunk);
-    g_assert_cmpstr(evr.epoch, ==, "0");
-    g_assert_cmpstr(evr.version, ==, "6.1");
-    g_assert_cmpstr(evr.release, ==, NULL);
+    g_assert_cmpstr(evr->epoch, ==, "0");
+    g_assert_cmpstr(evr->version, ==, "6.1");
+    g_assert_cmpstr(evr->release, ==, NULL);
+    g_free(evr);
 
     evr = cr_str_to_evr("7", chunk);
-    g_assert_cmpstr(evr.epoch, ==, "0");
-    g_assert_cmpstr(evr.version, ==, "7");
-    g_assert_cmpstr(evr.release, ==, NULL);
+    g_assert_cmpstr(evr->epoch, ==, "0");
+    g_assert_cmpstr(evr->version, ==, "7");
+    g_assert_cmpstr(evr->release, ==, NULL);
+    g_free(evr);
 
     // VR
 
     evr = cr_str_to_evr("5.0.0-2", chunk);
-    g_assert_cmpstr(evr.epoch, ==, "0");
-    g_assert_cmpstr(evr.version, ==, "5.0.0");
-    g_assert_cmpstr(evr.release, ==, "2");
+    g_assert_cmpstr(evr->epoch, ==, "0");
+    g_assert_cmpstr(evr->version, ==, "5.0.0");
+    g_assert_cmpstr(evr->release, ==, "2");
+    g_free(evr);
 
     evr = cr_str_to_evr("6.1-3", chunk);
-    g_assert_cmpstr(evr.epoch, ==, "0");
-    g_assert_cmpstr(evr.version, ==, "6.1");
-    g_assert_cmpstr(evr.release, ==, "3");
+    g_assert_cmpstr(evr->epoch, ==, "0");
+    g_assert_cmpstr(evr->version, ==, "6.1");
+    g_assert_cmpstr(evr->release, ==, "3");
+    g_free(evr);
 
     evr = cr_str_to_evr("7-4", chunk);
-    g_assert_cmpstr(evr.epoch, ==, "0");
-    g_assert_cmpstr(evr.version, ==, "7");
-    g_assert_cmpstr(evr.release, ==, "4");
+    g_assert_cmpstr(evr->epoch, ==, "0");
+    g_assert_cmpstr(evr->version, ==, "7");
+    g_assert_cmpstr(evr->release, ==, "4");
+    g_free(evr);
 
     // EV
 
     evr = cr_str_to_evr("1:5.0.0", chunk);
-    g_assert_cmpstr(evr.epoch, ==, "1");
-    g_assert_cmpstr(evr.version, ==, "5.0.0");
-    g_assert_cmpstr(evr.release, ==, NULL);
+    g_assert_cmpstr(evr->epoch, ==, "1");
+    g_assert_cmpstr(evr->version, ==, "5.0.0");
+    g_assert_cmpstr(evr->release, ==, NULL);
+    g_free(evr);
 
     evr = cr_str_to_evr("2:6.1", chunk);
-    g_assert_cmpstr(evr.epoch, ==, "2");
-    g_assert_cmpstr(evr.version, ==, "6.1");
-    g_assert_cmpstr(evr.release, ==, NULL);
+    g_assert_cmpstr(evr->epoch, ==, "2");
+    g_assert_cmpstr(evr->version, ==, "6.1");
+    g_assert_cmpstr(evr->release, ==, NULL);
+    g_free(evr);
 
     evr = cr_str_to_evr("3:7", chunk);
-    g_assert_cmpstr(evr.epoch, ==, "3");
-    g_assert_cmpstr(evr.version, ==, "7");
-    g_assert_cmpstr(evr.release, ==, NULL);
+    g_assert_cmpstr(evr->epoch, ==, "3");
+    g_assert_cmpstr(evr->version, ==, "7");
+    g_assert_cmpstr(evr->release, ==, NULL);
+    g_free(evr);
 
     //cr_EVR
 
     evr = cr_str_to_evr("1:5.0.0-11", chunk);
-    g_assert_cmpstr(evr.epoch, ==, "1");
-    g_assert_cmpstr(evr.version, ==, "5.0.0");
-    g_assert_cmpstr(evr.release, ==, "11");
+    g_assert_cmpstr(evr->epoch, ==, "1");
+    g_assert_cmpstr(evr->version, ==, "5.0.0");
+    g_assert_cmpstr(evr->release, ==, "11");
+    g_free(evr);
 
     evr = cr_str_to_evr("2:6.1-22", chunk);
-    g_assert_cmpstr(evr.epoch, ==, "2");
-    g_assert_cmpstr(evr.version, ==, "6.1");
-    g_assert_cmpstr(evr.release, ==, "22");
+    g_assert_cmpstr(evr->epoch, ==, "2");
+    g_assert_cmpstr(evr->version, ==, "6.1");
+    g_assert_cmpstr(evr->release, ==, "22");
+    g_free(evr);
 
     evr = cr_str_to_evr("3:7-33", chunk);
-    g_assert_cmpstr(evr.epoch, ==, "3");
-    g_assert_cmpstr(evr.version, ==, "7");
-    g_assert_cmpstr(evr.release, ==, "33");
+    g_assert_cmpstr(evr->epoch, ==, "3");
+    g_assert_cmpstr(evr->version, ==, "7");
+    g_assert_cmpstr(evr->release, ==, "33");
+    g_free(evr);
 
     // Bad strings
 
     evr = cr_str_to_evr(":", chunk);
-    g_assert_cmpstr(evr.epoch, ==, "0");
-    g_assert_cmpstr(evr.version, ==, "");
-    g_assert_cmpstr(evr.release, ==, NULL);
+    g_assert_cmpstr(evr->epoch, ==, "0");
+    g_assert_cmpstr(evr->version, ==, "");
+    g_assert_cmpstr(evr->release, ==, NULL);
+    g_free(evr);
 
     evr = cr_str_to_evr(":-", chunk);
-    g_assert_cmpstr(evr.epoch, ==, "0");
-    g_assert_cmpstr(evr.version, ==, "");
-    g_assert_cmpstr(evr.release, ==, NULL);
+    g_assert_cmpstr(evr->epoch, ==, "0");
+    g_assert_cmpstr(evr->version, ==, "");
+    g_assert_cmpstr(evr->release, ==, NULL);
+    g_free(evr);
 
     // Really bad values
 
     evr = cr_str_to_evr(NULL, chunk);
-    g_assert_cmpstr(evr.epoch, ==, NULL);
-    g_assert_cmpstr(evr.version, ==, NULL);
-    g_assert_cmpstr(evr.release, ==, NULL);
+    g_assert_cmpstr(evr->epoch, ==, NULL);
+    g_assert_cmpstr(evr->version, ==, NULL);
+    g_assert_cmpstr(evr->release, ==, NULL);
+    g_free(evr);
 
     evr = cr_str_to_evr("", chunk);
-    g_assert_cmpstr(evr.epoch, ==, NULL);
-    g_assert_cmpstr(evr.version, ==, NULL);
-    g_assert_cmpstr(evr.release, ==, NULL);
+    g_assert_cmpstr(evr->epoch, ==, NULL);
+    g_assert_cmpstr(evr->version, ==, NULL);
+    g_assert_cmpstr(evr->release, ==, NULL);
+    g_free(evr);
 
     evr = cr_str_to_evr("-", chunk);
-    g_assert_cmpstr(evr.epoch, ==, "0");
-    g_assert_cmpstr(evr.version, ==, "");
-    g_assert_cmpstr(evr.release, ==, NULL);
+    g_assert_cmpstr(evr->epoch, ==, "0");
+    g_assert_cmpstr(evr->version, ==, "");
+    g_assert_cmpstr(evr->release, ==, NULL);
+    g_free(evr);
 
     evr = cr_str_to_evr("-:", chunk);
-    g_assert_cmpstr(evr.epoch, ==, "0");
-    g_assert_cmpstr(evr.version, ==, "");
-    g_assert_cmpstr(evr.release, ==, NULL);
+    g_assert_cmpstr(evr->epoch, ==, "0");
+    g_assert_cmpstr(evr->version, ==, "");
+    g_assert_cmpstr(evr->release, ==, NULL);
+    g_free(evr);
 
     evr = cr_str_to_evr("foo:bar", chunk);
-    g_assert_cmpstr(evr.epoch, ==, "0");
-    g_assert_cmpstr(evr.version, ==, "bar");
-    g_assert_cmpstr(evr.release, ==, NULL);
+    g_assert_cmpstr(evr->epoch, ==, "0");
+    g_assert_cmpstr(evr->version, ==, "bar");
+    g_assert_cmpstr(evr->release, ==, NULL);
+    g_free(evr);
 
     g_string_chunk_free(chunk);
 }
@@ -978,7 +959,7 @@ test_cr_cmp_version_str(void)
 static void
 test_cr_split_rpm_filename(void)
 {
-    struct cr_NVREA *res;
+    cr_NVREA *res;
 
     res = cr_split_rpm_filename(NULL);
     g_assert(!res);
@@ -1037,7 +1018,7 @@ test_cr_str_to_nevr(void)
     g_assert(!res->epoch);
     cr_nevr_free(res);
 
-    res = cr_str_to_nevr("bar:4-9-123a");
+    res = cr_str_to_nevr("bar-4:9-123a");
     g_assert(res);
     g_assert_cmpstr(res->name, ==, "bar");
     g_assert_cmpstr(res->version, ==, "9");
@@ -1061,8 +1042,41 @@ test_cr_str_to_nevr(void)
     g_assert(!res->epoch);
     cr_nevr_free(res);
 
+    res = cr_str_to_nevr("b-1-2");
+    g_assert(res);
+    g_assert_cmpstr(res->name, ==, "b");
+    g_assert_cmpstr(res->version, ==, "1");
+    g_assert_cmpstr(res->release, ==, "2");
+    g_assert(!res->epoch);
+    cr_nevr_free(res);
 }
 
+static void
+test_cr_str_to_nevra(void)
+{
+    cr_NEVRA *res;
+
+    res = cr_str_to_nevra(NULL);
+    g_assert(!res);
+
+    res = cr_str_to_nevra("crypto-utils-0:2.4.1-52.fc20.x86_64");
+    g_assert(res);
+    g_assert_cmpstr(res->name, ==, "crypto-utils");
+    g_assert_cmpstr(res->version, ==, "2.4.1");
+    g_assert_cmpstr(res->release, ==, "52.fc20");
+    g_assert_cmpstr(res->epoch, ==, "0");
+    g_assert_cmpstr(res->arch, ==, "x86_64");
+    cr_nevra_free(res);
+
+    res = cr_str_to_nevra("crypto-utils-2.4.1-52.fc20.x86_64");
+    g_assert(res);
+    g_assert_cmpstr(res->name, ==, "crypto-utils");
+    g_assert_cmpstr(res->version, ==, "2.4.1");
+    g_assert_cmpstr(res->release, ==, "52.fc20");
+    g_assert(!res->epoch);
+    g_assert_cmpstr(res->arch, ==, "x86_64");
+    cr_nevra_free(res);
+}
 
 static void
 test_cr_cmp_evr(void)
@@ -1169,6 +1183,8 @@ main(int argc, char *argv[])
             test_cr_split_rpm_filename);
     g_test_add_func("/misc/test_cr_str_to_nevr",
             test_cr_str_to_nevr);
+    g_test_add_func("/misc/test_cr_str_to_nevra",
+            test_cr_str_to_nevra);
     g_test_add_func("/misc/test_cr_cmp_evr",
             test_cr_cmp_evr);