am c372a778: Merge "libbase_test: get it building for Windows"

* commit 'c372a778626dffdf6d1be5f98eafa966a95be082':
  libbase_test: get it building for Windows
This commit is contained in:
Elliott Hughes 2015-09-12 03:24:43 +00:00 committed by Android Git Automerger
commit a2d380af88
2 changed files with 19 additions and 18 deletions

View file

@ -98,6 +98,7 @@ include $(BUILD_NATIVE_TEST)
include $(CLEAR_VARS)
LOCAL_MODULE := libbase_test
LOCAL_MODULE_HOST_OS := darwin linux windows
LOCAL_SRC_FILES := $(libbase_test_src_files)
LOCAL_C_INCLUDES := $(LOCAL_PATH)
LOCAL_CPPFLAGS := $(libbase_cppflags)

View file

@ -20,49 +20,49 @@
TEST(parseint, signed_smoke) {
int i;
ASSERT_EQ(false, android::base::ParseInt("x", &i));
ASSERT_EQ(false, android::base::ParseInt("123x", &i));
ASSERT_FALSE(android::base::ParseInt("x", &i));
ASSERT_FALSE(android::base::ParseInt("123x", &i));
ASSERT_EQ(true, android::base::ParseInt("123", &i));
ASSERT_TRUE(android::base::ParseInt("123", &i));
ASSERT_EQ(123, i);
ASSERT_EQ(true, android::base::ParseInt("-123", &i));
ASSERT_TRUE(android::base::ParseInt("-123", &i));
ASSERT_EQ(-123, i);
short s;
ASSERT_EQ(true, android::base::ParseInt("1234", &s));
ASSERT_TRUE(android::base::ParseInt("1234", &s));
ASSERT_EQ(1234, s);
ASSERT_EQ(true, android::base::ParseInt("12", &i, 0, 15));
ASSERT_TRUE(android::base::ParseInt("12", &i, 0, 15));
ASSERT_EQ(12, i);
ASSERT_EQ(false, android::base::ParseInt("-12", &i, 0, 15));
ASSERT_EQ(false, android::base::ParseInt("16", &i, 0, 15));
ASSERT_FALSE(android::base::ParseInt("-12", &i, 0, 15));
ASSERT_FALSE(android::base::ParseInt("16", &i, 0, 15));
}
TEST(parseint, unsigned_smoke) {
unsigned int i;
ASSERT_EQ(false, android::base::ParseUint("x", &i));
ASSERT_EQ(false, android::base::ParseUint("123x", &i));
ASSERT_FALSE(android::base::ParseUint("x", &i));
ASSERT_FALSE(android::base::ParseUint("123x", &i));
ASSERT_EQ(true, android::base::ParseUint("123", &i));
ASSERT_TRUE(android::base::ParseUint("123", &i));
ASSERT_EQ(123u, i);
ASSERT_EQ(false, android::base::ParseUint("-123", &i));
ASSERT_FALSE(android::base::ParseUint("-123", &i));
unsigned short s;
ASSERT_EQ(true, android::base::ParseUint("1234", &s));
ASSERT_TRUE(android::base::ParseUint("1234", &s));
ASSERT_EQ(1234u, s);
ASSERT_EQ(true, android::base::ParseUint("12", &i, 15u));
ASSERT_TRUE(android::base::ParseUint("12", &i, 15u));
ASSERT_EQ(12u, i);
ASSERT_EQ(false, android::base::ParseUint("-12", &i, 15u));
ASSERT_EQ(false, android::base::ParseUint("16", &i, 15u));
ASSERT_FALSE(android::base::ParseUint("-12", &i, 15u));
ASSERT_FALSE(android::base::ParseUint("16", &i, 15u));
}
TEST(parseint, no_implicit_octal) {
int i;
ASSERT_EQ(true, android::base::ParseInt("0123", &i));
ASSERT_TRUE(android::base::ParseInt("0123", &i));
ASSERT_EQ(123, i);
unsigned int u;
ASSERT_EQ(true, android::base::ParseUint("0123", &u));
ASSERT_TRUE(android::base::ParseUint("0123", &u));
ASSERT_EQ(123u, u);
}