1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88
|
/*
* tst_basic.c - self-tests for liboath basic functions
* Copyright (C) 2009-2026 Simon Josefsson
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, see
* <https://www.gnu.org/licenses/>.
*
*/
#include <config.h>
#include "oath.h"
#include <stdio.h>
int
main (void)
{
oath_rc rc;
/* Check version. */
if (!oath_check_version (OATH_VERSION))
{
printf ("oath_check_version (%s) failed [%s]\n", OATH_VERSION,
oath_check_version (NULL));
return 1;
}
if (oath_check_version (NULL) == NULL)
{
printf ("oath_check_version (NULL) == NULL\n");
return 1;
}
if (oath_check_version ("999.999"))
{
printf ("oath_check_version (999.999) succeeded?!\n");
return 1;
}
if (!oath_check_version ("0"))
{
printf ("oath_check_version (0) didn't fail?!\n");
return 1;
}
if (oath_check_version ("UNKNOWN"))
{
printf ("oath_check_version (UNKNOWN) didn't fail?!\n");
return 1;
}
if (OATH_VERSION_NUMBER < 0x02060300 || OATH_VERSION_NUMBER >= 0x03000000)
{
printf ("OATH_VERSION_NUMBER out of range?!\n");
return 1;
}
rc = oath_init ();
if (rc != OATH_OK)
{
printf ("oath_init: %d\n", rc);
return 1;
}
/* Test deinitialization. */
rc = oath_done ();
if (rc != OATH_OK)
{
printf ("oath_done: %d\n", rc);
return 1;
}
return 0;
}
|