45 lines
906 B
C
45 lines
906 B
C
/*
|
|
* Copyright (c) 2009, 2010 Petri Lehtinen <petri@digip.org>
|
|
*
|
|
* Jansson is free software; you can redistribute it and/or modify
|
|
* it under the terms of the MIT license. See LICENSE for details.
|
|
*/
|
|
|
|
#include <jansson.h>
|
|
#include "util.h"
|
|
|
|
int main()
|
|
{
|
|
json_t *integer, *real;
|
|
int i;
|
|
double d;
|
|
|
|
integer = json_integer(5);
|
|
real = json_real(100.1);
|
|
|
|
if(!integer)
|
|
fail("unable to create integer");
|
|
if(!real)
|
|
fail("unable to create real");
|
|
|
|
i = json_integer_value(integer);
|
|
if(i != 5)
|
|
fail("wrong integer value");
|
|
|
|
d = json_real_value(real);
|
|
if(d != 100.1)
|
|
fail("wrong real value");
|
|
|
|
d = json_number_value(integer);
|
|
if(d != 5.0)
|
|
fail("wrong number value");
|
|
d = json_number_value(real);
|
|
if(d != 100.1)
|
|
fail("wrong number value");
|
|
|
|
json_decref(integer);
|
|
json_decref(real);
|
|
|
|
return 0;
|
|
}
|