freebsd-dev/contrib/ntp/tests/libntp/atoint.c
Gleb Smirnoff 9034852c84 MFV ntp-4.2.8p4 (r289715)
Security:       VuXML: c4a18a12-77fc-11e5-a687-206a8a720317
Security:	CVE-2015-7871
Security:	CVE-2015-7855
Security:	CVE-2015-7854
Security:	CVE-2015-7853
Security:	CVE-2015-7852
Security:	CVE-2015-7851
Security:	CVE-2015-7850
Security:	CVE-2015-7849
Security:	CVE-2015-7848
Security:	CVE-2015-7701
Security:	CVE-2015-7703
Security:	CVE-2015-7704, CVE-2015-7705
Security:	CVE-2015-7691, CVE-2015-7692, CVE-2015-7702
Security:	http://support.ntp.org/bin/view/Main/SecurityNotice#October_2015_NTP_Security_Vulner
Sponsored by:	Nginx, Inc.
2015-10-22 19:42:57 +00:00

61 lines
1.2 KiB
C

#include "config.h"
#include "ntp_stdlib.h"
#include "ntp_calendar.h"
#include "unity.h"
void test_RegularPositive(void);
void test_RegularNegative(void);
void test_PositiveOverflowBoundary(void);
void test_NegativeOverflowBoundary(void);
void test_PositiveOverflowBig(void);
void test_IllegalCharacter(void);
void test_RegularPositive(void) {
const char *str = "17";
long val;
TEST_ASSERT_TRUE(atoint(str, &val));
TEST_ASSERT_EQUAL(17, val);
}
void test_RegularNegative(void) {
const char *str = "-20";
long val;
TEST_ASSERT_TRUE(atoint(str, &val));
TEST_ASSERT_EQUAL(-20, val);
}
void test_PositiveOverflowBoundary(void) {
const char *str = "2147483648";
long val;
TEST_ASSERT_FALSE(atoint(str, &val));
}
void test_NegativeOverflowBoundary(void) {
const char *str = "-2147483649";
long val;
TEST_ASSERT_FALSE(atoint(str, &val));
}
void test_PositiveOverflowBig(void) {
const char *str = "2300000000";
long val;
TEST_ASSERT_FALSE(atoint(str, &val));
}
void test_IllegalCharacter(void) {
const char *str = "4500l";
long val;
TEST_ASSERT_FALSE(atoint(str, &val));
}