Fix 2 new sets of clang compiler warnings.
Fix issues that are flagged by -Wfloat-equal and -Wmissing-noreturn.
In the case of -Wfloat-equal the current cases in regular code are deliberate,
so the change is to silence the warning. For gtest code the appropriate fix is
to switch from EXPECT_EQ to EXPECT_(FLOAT|DOUBLE)_EQ.
The -Wmissing-noreturn warning isn't enabled due to a missing noreturn in
gtest. This issue has been reported to gtest.
Change-Id: Id84c70c21c542716c9ee0c41492e8ff8788c4ef8
diff --git a/runtime/mirror/object_test.cc b/runtime/mirror/object_test.cc
index 1aeba74..a2a0626 100644
--- a/runtime/mirror/object_test.cc
+++ b/runtime/mirror/object_test.cc
@@ -248,12 +248,6 @@
TEST_F(ObjectTest, PrimitiveArray_Char_Alloc) {
TestPrimitiveArray<CharArray>(class_linker_);
}
-TEST_F(ObjectTest, PrimitiveArray_Double_Alloc) {
- TestPrimitiveArray<DoubleArray>(class_linker_);
-}
-TEST_F(ObjectTest, PrimitiveArray_Float_Alloc) {
- TestPrimitiveArray<FloatArray>(class_linker_);
-}
TEST_F(ObjectTest, PrimitiveArray_Int_Alloc) {
TestPrimitiveArray<IntArray>(class_linker_);
}
@@ -264,6 +258,67 @@
TestPrimitiveArray<ShortArray>(class_linker_);
}
+TEST_F(ObjectTest, PrimitiveArray_Double_Alloc) {
+ typedef DoubleArray ArrayT;
+ ScopedObjectAccess soa(Thread::Current());
+ typedef typename ArrayT::ElementType T;
+
+ ArrayT* a = ArrayT::Alloc(soa.Self(), 2);
+ EXPECT_EQ(2, a->GetLength());
+ EXPECT_DOUBLE_EQ(0, a->Get(0));
+ EXPECT_DOUBLE_EQ(0, a->Get(1));
+ a->Set(0, T(123));
+ EXPECT_DOUBLE_EQ(T(123), a->Get(0));
+ EXPECT_DOUBLE_EQ(0, a->Get(1));
+ a->Set(1, T(321));
+ EXPECT_DOUBLE_EQ(T(123), a->Get(0));
+ EXPECT_DOUBLE_EQ(T(321), a->Get(1));
+
+ Class* aioobe = class_linker_->FindSystemClass(soa.Self(),
+ "Ljava/lang/ArrayIndexOutOfBoundsException;");
+
+ EXPECT_DOUBLE_EQ(0, a->Get(-1));
+ EXPECT_TRUE(soa.Self()->IsExceptionPending());
+ EXPECT_EQ(aioobe, soa.Self()->GetException(NULL)->GetClass());
+ soa.Self()->ClearException();
+
+ EXPECT_DOUBLE_EQ(0, a->Get(2));
+ EXPECT_TRUE(soa.Self()->IsExceptionPending());
+ EXPECT_EQ(aioobe, soa.Self()->GetException(NULL)->GetClass());
+ soa.Self()->ClearException();
+}
+
+TEST_F(ObjectTest, PrimitiveArray_Float_Alloc) {
+ typedef FloatArray ArrayT;
+ ScopedObjectAccess soa(Thread::Current());
+ typedef typename ArrayT::ElementType T;
+
+ ArrayT* a = ArrayT::Alloc(soa.Self(), 2);
+ EXPECT_FLOAT_EQ(2, a->GetLength());
+ EXPECT_FLOAT_EQ(0, a->Get(0));
+ EXPECT_FLOAT_EQ(0, a->Get(1));
+ a->Set(0, T(123));
+ EXPECT_FLOAT_EQ(T(123), a->Get(0));
+ EXPECT_FLOAT_EQ(0, a->Get(1));
+ a->Set(1, T(321));
+ EXPECT_FLOAT_EQ(T(123), a->Get(0));
+ EXPECT_FLOAT_EQ(T(321), a->Get(1));
+
+ Class* aioobe = class_linker_->FindSystemClass(soa.Self(),
+ "Ljava/lang/ArrayIndexOutOfBoundsException;");
+
+ EXPECT_FLOAT_EQ(0, a->Get(-1));
+ EXPECT_TRUE(soa.Self()->IsExceptionPending());
+ EXPECT_EQ(aioobe, soa.Self()->GetException(NULL)->GetClass());
+ soa.Self()->ClearException();
+
+ EXPECT_FLOAT_EQ(0, a->Get(2));
+ EXPECT_TRUE(soa.Self()->IsExceptionPending());
+ EXPECT_EQ(aioobe, soa.Self()->GetException(NULL)->GetClass());
+ soa.Self()->ClearException();
+}
+
+
TEST_F(ObjectTest, CheckAndAllocArrayFromCode) {
// pretend we are trying to call 'new char[3]' from String.toCharArray
ScopedObjectAccess soa(Thread::Current());