"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "lib/testUnits.c" between
udunits-2.2.26.tar.gz and udunits-2.2.28.tar.gz

About: UDUNITS supports units of physical quantities. Its C library provides for arithmetic manipulation of units and for conversion of numeric values between compatible units.

testUnits.c  (udunits-2.2.26):testUnits.c  (udunits-2.2.28)
/* /*
* Copyright 2014 University Corporation for Atmospheric Research * Copyright 2020 University Corporation for Atmospheric Research
* *
* This file is part of the UDUNITS-2 package. See the file COPYRIGHT * This file is part of the UDUNITS-2 package. See the file COPYRIGHT
* in the top-level source-directory of the package for copying and * in the top-level source-directory of the package for copying and
* redistribution conditions. * redistribution conditions.
*/ */
#ifndef _XOPEN_SOURCE #include "config.h"
# define _XOPEN_SOURCE 500
#endif #include "udunits2.h"
#include <float.h> #include <float.h>
#include <glob.h> #include <glob.h>
#include <math.h> #include <math.h>
#include <stdarg.h> #include <stdarg.h>
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include <unistd.h> #include <unistd.h>
#include <CUnit/CUnit.h> #include <CUnit/CUnit.h>
#include <CUnit/Basic.h> #include <CUnit/Basic.h>
#include "udunits2.h"
static const char* xmlPath; static const char* xmlPath;
static ut_system* unitSystem; static ut_system* unitSystem;
static ut_unit* kilogram; static ut_unit* kilogram;
static ut_unit* meter; static ut_unit* meter;
static ut_unit* radian; static ut_unit* radian;
static ut_unit* kelvin; static ut_unit* kelvin;
static ut_unit* second; static ut_unit* second;
static ut_unit* minute; static ut_unit* minute;
static ut_unit* kilometer; static ut_unit* kilometer;
static ut_unit* micron; static ut_unit* micron;
skipping to change at line 1989 skipping to change at line 1987
} }
static void static void
test_xml(void) test_xml(void)
{ {
ut_system* xmlSystem; ut_system* xmlSystem;
glob_t files; glob_t files;
int status; int status;
ut_unit* unit1; ut_unit* unit1;
ut_unit* unit2; ut_unit* unit2;
cv_converter* converter; cv_converter* converter;
char* spec; char* spec;
ut_unit* unit; ut_unit* unit;
ut_set_error_message_handler(ut_write_to_stderr); ut_set_error_message_handler(ut_write_to_stderr);
xmlSystem = ut_read_xml(xmlPath); xmlSystem = ut_read_xml(xmlPath);
CU_ASSERT_PTR_NOT_NULL_FATAL(xmlSystem); CU_ASSERT_PTR_NOT_NULL_FATAL(xmlSystem);
spec = "seconds@1970-01-01T00:00:00Z"; spec = "seconds@1970-01-01T00:00:00Z";
unit = ut_parse(xmlSystem, spec, UT_ASCII); unit = ut_parse(xmlSystem, spec, UT_ASCII);
CU_ASSERT_PTR_NOT_NULL(unit); CU_ASSERT_PTR_NOT_NULL(unit);
ut_free(unit); ut_free(unit);
skipping to change at line 2243 skipping to change at line 2241
ut_format(unit2, actual, 128, UT_ASCII); ut_format(unit2, actual, 128, UT_ASCII);
CU_ASSERT_STRING_EQUAL(actual, expect); CU_ASSERT_STRING_EQUAL(actual, expect);
if (strcmp(actual, expect)) if (strcmp(actual, expect))
fprintf(stderr, "(%s)/(%s) = \"%s\"\n", spec, spec, actual); fprintf(stderr, "(%s)/(%s) = \"%s\"\n", spec, spec, actual);
ut_free(unit1); ut_free(unit1);
ut_free(unit2); ut_free(unit2);
ut_free_system(xmlSystem); ut_free_system(xmlSystem);
} }
static void
test_timeResolution(void)
{
ut_system* xmlSystem;
ut_set_error_message_handler(ut_write_to_stderr);
xmlSystem = ut_read_xml(xmlPath);
CU_ASSERT_PTR_NOT_NULL_FATAL(xmlSystem);
// Maximum temporal resolution:
const char string[] = "day since 2001-01-01 00:00:00.000000000 UTC";
ut_unit* unit = ut_parse(xmlSystem, string, UT_ASCII);
CU_ASSERT_PTR_NOT_NULL_FATAL(unit);
char buf[128];
int len = ut_format(unit, buf, sizeof(buf), UT_ASCII | UT_NAMES);
CU_ASSERT_NOT_EQUAL_FATAL(len, -1);
printf("test_timeResolution() unit=\"%s\"", buf);
CU_ASSERT_STRING_EQUAL(buf, string);
ut_free(unit);
}
int int
main( main(
const int argc, const int argc,
const char* const* argv) const char* const* argv)
{ {
int exitCode = EXIT_FAILURE; int exitCode = EXIT_FAILURE;
xmlPath = argv[1] xmlPath = argv[1]
? argv[1] ? argv[1]
: getenv("UDUNITS2_XML_PATH"); : getenv("UDUNITS2_XML_PATH");
skipping to change at line 2294 skipping to change at line 2315
CU_ADD_TEST(testSuite, test_utSameSystem); CU_ADD_TEST(testSuite, test_utSameSystem);
CU_ADD_TEST(testSuite, test_utIsDimensionless); CU_ADD_TEST(testSuite, test_utIsDimensionless);
CU_ADD_TEST(testSuite, test_utClone); CU_ADD_TEST(testSuite, test_utClone);
CU_ADD_TEST(testSuite, test_utAreConvertible); CU_ADD_TEST(testSuite, test_utAreConvertible);
CU_ADD_TEST(testSuite, test_utGetConverter); CU_ADD_TEST(testSuite, test_utGetConverter);
CU_ADD_TEST(testSuite, test_utSetEncoding); CU_ADD_TEST(testSuite, test_utSetEncoding);
CU_ADD_TEST(testSuite, test_utCompare); CU_ADD_TEST(testSuite, test_utCompare);
CU_ADD_TEST(testSuite, test_parsing); CU_ADD_TEST(testSuite, test_parsing);
CU_ADD_TEST(testSuite, test_visitor); CU_ADD_TEST(testSuite, test_visitor);
CU_ADD_TEST(testSuite, test_xml); CU_ADD_TEST(testSuite, test_xml);
CU_ADD_TEST(testSuite, test_timeResolution);
/* /*
*/ */
ut_set_error_message_handler(ut_ignore); ut_set_error_message_handler(ut_ignore);
if (CU_basic_run_tests() == CUE_SUCCESS) { if (CU_basic_run_tests() == CUE_SUCCESS) {
if (CU_get_number_of_tests_failed() == 0) if (CU_get_number_of_tests_failed() == 0)
exitCode = EXIT_SUCCESS; exitCode = EXIT_SUCCESS;
} }
} }
 End of changes. 6 change blocks. 
9 lines changed or deleted 31 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)