mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-11 05:33:47 +01:00
Fix a silly mistake in the tor_mathlog() documentation. Give it a unit test.
This commit is contained in:
parent
b034d07acd
commit
1dd03fbc77
@ -322,7 +322,7 @@ tor_log_mallinfo(int severity)
|
|||||||
* ===== */
|
* ===== */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the natural logarithm of d base 2. We defined this wrapper here so
|
* Returns the natural logarithm of d base e. We defined this wrapper here so
|
||||||
* to avoid conflicts with old versions of tor_log(), which were named log().
|
* to avoid conflicts with old versions of tor_log(), which were named log().
|
||||||
*/
|
*/
|
||||||
double
|
double
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#include <tchar.h>
|
#include <tchar.h>
|
||||||
#endif
|
#endif
|
||||||
|
#include <math.h>
|
||||||
|
|
||||||
/* XXXX this is a minimal wrapper to make the unit tests compile with the
|
/* XXXX this is a minimal wrapper to make the unit tests compile with the
|
||||||
* changed tor_timegm interface. */
|
* changed tor_timegm interface. */
|
||||||
@ -3240,6 +3241,20 @@ test_util_set_env_var_in_sl(void *ptr)
|
|||||||
smartlist_free(expected_resulting_env_vars);
|
smartlist_free(expected_resulting_env_vars);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
test_util_mathlog(void *arg)
|
||||||
|
{
|
||||||
|
double d;
|
||||||
|
(void) arg;
|
||||||
|
|
||||||
|
d = tor_mathlog(2.718281828);
|
||||||
|
tt_double_op(fabs(d - 1.0), <, .000001);
|
||||||
|
d = tor_mathlog(10);
|
||||||
|
tt_double_op(fabs(d - 2.30258509), <, .000001);
|
||||||
|
done:
|
||||||
|
;
|
||||||
|
}
|
||||||
|
|
||||||
#define UTIL_LEGACY(name) \
|
#define UTIL_LEGACY(name) \
|
||||||
{ #name, legacy_test_helper, 0, &legacy_setup, test_util_ ## name }
|
{ #name, legacy_test_helper, 0, &legacy_setup, test_util_ ## name }
|
||||||
|
|
||||||
@ -3296,6 +3311,7 @@ struct testcase_t util_tests[] = {
|
|||||||
UTIL_TEST(read_file_eof_tiny_limit, 0),
|
UTIL_TEST(read_file_eof_tiny_limit, 0),
|
||||||
UTIL_TEST(read_file_eof_two_loops, 0),
|
UTIL_TEST(read_file_eof_two_loops, 0),
|
||||||
UTIL_TEST(read_file_eof_zero_bytes, 0),
|
UTIL_TEST(read_file_eof_zero_bytes, 0),
|
||||||
|
UTIL_TEST(mathlog, 0),
|
||||||
END_OF_TESTCASES
|
END_OF_TESTCASES
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user