lua/getfield.c: Revise error messages
[libquvi.git] / tests / verify.c
blob0c14fc1b1f5e4765d854e872dfed9799127f2698
1 /* libquvi
2 * Copyright (C) 2012 Toni Gundogdu <legatvs@gmail.com>
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17 * 02110-1301 USA
20 #include "config.h"
22 #include <string.h>
23 #include <glib.h>
24 #include <quvi.h>
26 #include "tests.h"
28 #define chk_len(p)\
29 do {\
30 gchar *s = NULL;\
31 quvi_verify_get(qv, p, &s);\
32 g_assert(s != NULL);\
33 g_test_message("%s=%s", #p, s);\
34 g_assert_cmpint(strlen(s), >, 1);\
35 } while (0)
37 #define chk_val(p)\
38 do {\
39 gdouble n = -1;\
40 quvi_verify_get(qv, p, &n);\
41 g_test_message("%s=%f", #p, n);\
42 g_assert_cmpfloat(n, >, -1);\
43 } while (0)
45 static void test_verify()
47 static const gchar URL[] = "http://is.gd/SKyg8m";
49 quvi_verify_t qv;
50 quvi_t q;
51 gchar *v;
53 if (chk_internet() == FALSE)
54 return;
56 if (chk_skip(__func__) == TRUE)
57 return;
59 q = quvi_new();
60 g_assert(q != NULL);
61 g_assert_cmpint(qerr(q), ==, QUVI_OK);
63 chk_verbose(q);
65 qv = quvi_verify_new(q, URL);
66 g_assert_cmpint(qerr_m(q, URL), ==, QUVI_OK);
67 g_assert(qv != NULL);
69 quvi_verify_get(qv, QUVI_VERIFY_PROPERTY_FILE_EXTENSION-1, &v);
70 g_assert_cmpint(qerr(q), ==, QUVI_ERROR_INVALID_ARG);
72 quvi_verify_get(qv, QUVI_VERIFY_PROPERTY_LENGTH_BYTES+1, &v);
73 g_assert_cmpint(qerr(q), ==, QUVI_ERROR_INVALID_ARG);
75 chk_len(QUVI_VERIFY_PROPERTY_FILE_EXTENSION);
76 chk_len(QUVI_VERIFY_PROPERTY_CONTENT_TYPE);
78 chk_val(QUVI_VERIFY_PROPERTY_LENGTH_BYTES);
80 quvi_verify_free(qv);
81 quvi_free(q);
84 gint main(gint argc, gchar **argv)
86 g_test_init(&argc, &argv, NULL);
87 g_test_add_func("/quvi/verify", test_verify);
88 return (g_test_run());
91 /* vim: set ts=2 sw=2 tw=72 expandtab: */