aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorElie Kheirallah <khei@google.com>2023-04-12 02:11:06 +0000
committerAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2023-04-12 02:11:06 +0000
commit576e9926bb37b1785f25b610aa8730c4a25de89b (patch)
tree7725e464591aaeb1667060bdb77d122f85e4d745
parentd0e614aaf4361822eb1c25f100949b4ed8618451 (diff)
parent04eccfca8fff4bfbb11ed03fae8e874f0597af35 (diff)
downloadaidl-576e9926bb37b1785f25b610aa8730c4a25de89b.tar.gz
aidl: add support for float/double constants am: 2c596b0028 am: ee7482a99b am: 04eccfca8f
Original change: https://android-review.googlesource.com/c/platform/system/tools/aidl/+/2516415 Change-Id: Ie8c27298901a69d2ade1ccc662e79714a60b3cdf Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
-rw-r--r--aidl_language.cpp3
-rw-r--r--aidl_unittest.cpp90
-rw-r--r--generate_cpp.cpp4
-rw-r--r--generate_ndk.cpp5
-rw-r--r--generate_rust.cpp3
-rw-r--r--tests/aidl_test_client_primitives.cpp29
-rw-r--r--tests/android/aidl/tests/ITestService.aidl18
-rw-r--r--tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/ITestService.h16
-rw-r--r--tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/ITestService.java16
-rw-r--r--tests/golden_output/aidl-test-interface-ndk-source/gen/include/aidl/android/aidl/tests/ITestService.h16
-rw-r--r--tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/ITestService.rs16
-rw-r--r--tests/java/src/android/aidl/tests/TestServiceClient.java22
-rw-r--r--tests/rust/test_client.rs18
13 files changed, 254 insertions, 2 deletions
diff --git a/aidl_language.cpp b/aidl_language.cpp
index 1b992086..67208181 100644
--- a/aidl_language.cpp
+++ b/aidl_language.cpp
@@ -1066,7 +1066,8 @@ bool AidlConstantDeclaration::CheckValid(const AidlTypenames& typenames) const {
valid = valid && !ValueString(AidlConstantValueDecorator).empty();
if (!valid) return false;
- const static set<string> kSupportedConstTypes = {"String", "byte", "int", "long"};
+ const static set<string> kSupportedConstTypes = {"String", "byte", "int",
+ "long", "float", "double"};
if (kSupportedConstTypes.find(type_->Signature()) == kSupportedConstTypes.end()) {
AIDL_ERROR(this) << "Constant of type " << type_->Signature() << " is not supported.";
return false;
diff --git a/aidl_unittest.cpp b/aidl_unittest.cpp
index 2d401143..7111a863 100644
--- a/aidl_unittest.cpp
+++ b/aidl_unittest.cpp
@@ -88,6 +88,10 @@ p/Foo.aidl :
} // namespace
+const string INVALID_INT8_VALUE = "Invalid type specifier for an int8 literal";
+const string INVALID_FLOAT_VALUE = "Invalid type specifier for a literal float";
+const string INVALID_OPERATION = "Cannot perform operation";
+
class AidlTest : public ::testing::TestWithParam<Options::Language> {
protected:
AidlDefinedType* Parse(const string& path, const string& contents, AidlTypenames& typenames_,
@@ -129,6 +133,22 @@ class AidlTest : public ::testing::TestWithParam<Options::Language> {
return defined_types.front().get();
}
+ void EvaluateInvalidAssignment(string content, string expected_stderr, AidlTypenames& typenames_,
+ Options::Language lang) {
+ AidlError error;
+ CaptureStderr();
+ EXPECT_EQ(nullptr, Parse("a/IFoo.aidl", content, typenames_, lang, &error));
+ EXPECT_THAT(GetCapturedStderr(), HasSubstr(expected_stderr));
+ };
+
+ void EvaluateValidAssignment(string content, string expected_stderr, AidlTypenames& typenames_,
+ Options::Language lang) {
+ AidlError error;
+ CaptureStderr();
+ EXPECT_NE(nullptr, Parse("a/IFoo.aidl", content, typenames_, lang, &error));
+ EXPECT_THAT(GetCapturedStderr(), HasSubstr(expected_stderr));
+ };
+
Options::Language GetLanguage() { return GetParam(); }
FakeIoDelegate io_delegate_;
@@ -1502,6 +1522,76 @@ TEST_P(AidlTest, FailOnMalformedQualifiedNameAsIdentifier) {
EXPECT_EQ(AidlError::PARSE_ERROR, error);
}
+TEST_P(AidlTest, FailOnAssigningDoubleInFloatConst) {
+ EvaluateInvalidAssignment(R"(package a; interface IFoo { const float DOUBLE_VALUE = 1.1; })",
+ INVALID_FLOAT_VALUE, typenames_, GetLanguage());
+}
+
+TEST_P(AidlTest, FailOnAssigningFloatInDoubleConst) {
+ EvaluateValidAssignment(R"(package a; interface IFoo { const double FLOAT_VALUE = 1.1f; })", "",
+ typenames_, GetLanguage());
+}
+
+TEST_P(AidlTest, FailOnAssigningIntInFloatConst) {
+ EvaluateInvalidAssignment(R"(package a; interface IFoo { const float INT_VALUE = 1; })",
+ INVALID_INT8_VALUE, typenames_, GetLanguage());
+}
+
+TEST_P(AidlTest, FailOnAssigningFloatInIntConst) {
+ EvaluateInvalidAssignment(R"(package a; interface IFoo { const int FLOAT_VALUE = 1.1f; })",
+ INVALID_FLOAT_VALUE, typenames_, GetLanguage());
+}
+
+TEST_P(AidlTest, FailOnAssigningIntInDoubleConst) {
+ EvaluateInvalidAssignment(R"(package a; interface IFoo { const double INT_VALUE = 1; })",
+ INVALID_INT8_VALUE, typenames_, GetLanguage());
+}
+
+TEST_P(AidlTest, FailOnAssigningDoubleInIntConst) {
+ EvaluateInvalidAssignment(R"(package a; interface IFoo { const int DOUBLE_VALUE = 1.1; })",
+ INVALID_FLOAT_VALUE, typenames_, GetLanguage());
+}
+
+TEST_P(AidlTest, FailOnAssigningFloatPlusIntConst) {
+ EvaluateInvalidAssignment(R"(package a; interface IFoo { const float FLOAT_VALUE = 1.1f + 1; })",
+ INVALID_OPERATION, typenames_, GetLanguage());
+}
+
+TEST_P(AidlTest, FailOnAssigningIntPlusFloatConst) {
+ EvaluateInvalidAssignment(R"(package a; interface IFoo { const float FLOAT_VALUE = 1 + 1.1f; })",
+ INVALID_OPERATION, typenames_, GetLanguage());
+}
+
+TEST_P(AidlTest, FailOnAssigningDoublePlusIntConst) {
+ EvaluateInvalidAssignment(R"(package a; interface IFoo { const double DOUBLE_VALUE = 1.1 + 1; })",
+ INVALID_OPERATION, typenames_, GetLanguage());
+}
+
+TEST_P(AidlTest, FailOnAssigningIntPlusDoubleConst) {
+ EvaluateInvalidAssignment(R"(package a; interface IFoo { const double DOUBLE_VALUE = 1 + 1.1; })",
+ INVALID_OPERATION, typenames_, GetLanguage());
+}
+
+TEST_P(AidlTest, FailOnAssigningTooLargeFloatConst) {
+ EvaluateInvalidAssignment(R"(package a; interface IFoo { const float DOUBLE_VALUE = 1e50f; })",
+ INVALID_FLOAT_VALUE, typenames_, GetLanguage());
+}
+
+TEST_P(AidlTest, FailOnAssigningTooLargeDoubleConst) {
+ EvaluateInvalidAssignment(R"(package a; interface IFoo { const double DOUBLE_VALUE = 1e310; })",
+ INVALID_FLOAT_VALUE, typenames_, GetLanguage());
+}
+
+TEST_P(AidlTest, PassOnAssigningLargeFloatConst) {
+ EvaluateValidAssignment(R"(package a; interface IFoo { const float DOUBLE_VALUE = 1e20f; })", "",
+ typenames_, GetLanguage());
+}
+
+TEST_P(AidlTest, PassOnAssigningLargeDoubleConst) {
+ EvaluateValidAssignment(R"(package a; interface IFoo { const double DOUBLE_VALUE = 1e150; })", "",
+ typenames_, GetLanguage());
+}
+
TEST_P(AidlTest, FailOnMalformedQualifiedNameAsPackage) {
AidlError error;
const string expected_stderr =
diff --git a/generate_cpp.cpp b/generate_cpp.cpp
index fcbe0072..874fa138 100644
--- a/generate_cpp.cpp
+++ b/generate_cpp.cpp
@@ -436,6 +436,10 @@ void GenerateConstantDeclarations(CodeWriter& out, const AidlDefinedType& type,
out << "static const " << cpp_type << "& " << constant->GetName() << "()";
GenerateDeprecated(out, *constant);
out << ";\n";
+ } else if (type.Signature() == "float" || type.Signature() == "double") {
+ out << "static constexpr " << cpp_type << " " << constant->GetName();
+ GenerateDeprecated(out, *constant);
+ out << " = " << constant->ValueString(ConstantValueDecorator) << ";\n";
} else {
out << "enum : " << cpp_type << " { " << constant->GetName();
GenerateDeprecated(out, *constant);
diff --git a/generate_ndk.cpp b/generate_ndk.cpp
index 09168ed3..bd554e74 100644
--- a/generate_ndk.cpp
+++ b/generate_ndk.cpp
@@ -425,6 +425,11 @@ static void GenerateConstantDeclarations(CodeWriter& out, const AidlTypenames& t
out << "static const char*";
cpp::GenerateDeprecated(out, *constant);
out << " " << constant->GetName() << ";\n";
+ } else if (type.Signature() == "float" || type.Signature() == "double") {
+ out << "static constexpr " << NdkNameOf(types, type, StorageMode::STACK) << " ";
+ out << constant->GetName();
+ cpp::GenerateDeprecated(out, *constant);
+ out << " = " << constant->ValueString(ConstantValueDecorator) << ";\n";
} else {
out << "enum : " << NdkNameOf(types, type, StorageMode::STACK) << " { ";
out << constant->GetName();
diff --git a/generate_rust.cpp b/generate_rust.cpp
index ec21ffd1..17beb366 100644
--- a/generate_rust.cpp
+++ b/generate_rust.cpp
@@ -548,7 +548,8 @@ void GenerateConstantDeclarations(CodeWriter& out, const TypeWithConstants& type
if (type.Signature() == "String") {
const_type = "&str";
} else if (type.Signature() == "byte" || type.Signature() == "int" ||
- type.Signature() == "long") {
+ type.Signature() == "long" || type.Signature() == "float" ||
+ type.Signature() == "double") {
const_type = RustNameOf(type, typenames, StorageMode::VALUE, Lifetime::NONE);
} else {
AIDL_FATAL(value) << "Unrecognized constant type: " << type.Signature();
diff --git a/tests/aidl_test_client_primitives.cpp b/tests/aidl_test_client_primitives.cpp
index eff67c4d..040804d9 100644
--- a/tests/aidl_test_client_primitives.cpp
+++ b/tests/aidl_test_client_primitives.cpp
@@ -120,6 +120,31 @@ TEST_F(AidlPrimitiveTest, longConstants) {
}
}
+TEST_F(AidlPrimitiveTest, floatConstants) {
+ constexpr float consts[] = {
+ ITestService::FLOAT_TEST_CONSTANT, ITestService::FLOAT_TEST_CONSTANT2,
+ ITestService::FLOAT_TEST_CONSTANT3, ITestService::FLOAT_TEST_CONSTANT4,
+ ITestService::FLOAT_TEST_CONSTANT5, ITestService::FLOAT_TEST_CONSTANT6,
+ ITestService::FLOAT_TEST_CONSTANT7,
+ };
+ for (auto sent : consts) {
+ DoTest(&ITestService::RepeatFloat, sent);
+ }
+}
+
+TEST_F(AidlPrimitiveTest, doubleConstants) {
+ constexpr double consts[] = {
+ ITestService::DOUBLE_TEST_CONSTANT, ITestService::DOUBLE_TEST_CONSTANT2,
+ ITestService::DOUBLE_TEST_CONSTANT3, ITestService::DOUBLE_TEST_CONSTANT4,
+ ITestService::DOUBLE_TEST_CONSTANT5, ITestService::DOUBLE_TEST_CONSTANT6,
+ ITestService::DOUBLE_TEST_CONSTANT7, ITestService::DOUBLE_TEST_CONSTANT8,
+ ITestService::DOUBLE_TEST_CONSTANT9,
+ };
+ for (auto sent : consts) {
+ DoTest(&ITestService::RepeatDouble, sent);
+ }
+}
+
TEST_F(AidlPrimitiveTest, strings) {
std::vector<String16> strings = {
String16("Deliver us from evil."), String16(), String16("\0\0", 2),
@@ -336,4 +361,8 @@ TEST_F(AidlPrimitiveTest, constantExpressions) {
EXPECT_THAT(ITestService::A55, Eq(1));
EXPECT_THAT(ITestService::A56, Eq(1));
EXPECT_THAT(ITestService::A57, Eq(1));
+ EXPECT_THAT(ITestService::FLOAT_TEST_CONSTANT4, Eq(2.2f));
+ EXPECT_THAT(ITestService::FLOAT_TEST_CONSTANT5, Eq(-2.2f));
+ EXPECT_THAT(ITestService::DOUBLE_TEST_CONSTANT4, Eq(2.2));
+ EXPECT_THAT(ITestService::DOUBLE_TEST_CONSTANT5, Eq(-2.2));
}
diff --git a/tests/android/aidl/tests/ITestService.aidl b/tests/android/aidl/tests/ITestService.aidl
index 8bee759f..fd8b6b55 100644
--- a/tests/android/aidl/tests/ITestService.aidl
+++ b/tests/android/aidl/tests/ITestService.aidl
@@ -69,6 +69,24 @@ interface ITestService {
const String STRING_TEST_CONSTANT = "foo";
const String STRING_TEST_CONSTANT2 = "bar";
+ const float FLOAT_TEST_CONSTANT = 1.0f;
+ const float FLOAT_TEST_CONSTANT2 = -1.0f;
+ const float FLOAT_TEST_CONSTANT3 = +1.0f;
+ const float FLOAT_TEST_CONSTANT4 = +2.2f;
+ const float FLOAT_TEST_CONSTANT5 = -2.2f;
+ const float FLOAT_TEST_CONSTANT6 = -0.0f;
+ const float FLOAT_TEST_CONSTANT7 = +0.0f;
+
+ const double DOUBLE_TEST_CONSTANT = 1.0;
+ const double DOUBLE_TEST_CONSTANT2 = -1.0;
+ const double DOUBLE_TEST_CONSTANT3 = +1.0;
+ const double DOUBLE_TEST_CONSTANT4 = +2.2;
+ const double DOUBLE_TEST_CONSTANT5 = -2.2;
+ const double DOUBLE_TEST_CONSTANT6 = -0.0;
+ const double DOUBLE_TEST_CONSTANT7 = +0.0;
+ const double DOUBLE_TEST_CONSTANT8 = 1.1f;
+ const double DOUBLE_TEST_CONSTANT9 = -1.1f;
+
const @utf8InCpp String STRING_TEST_CONSTANT_UTF8 = "baz";
// This is to emulate a method that is added after the service is implemented.
diff --git a/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/ITestService.h b/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/ITestService.h
index ed0afc32..cbf30fcc 100644
--- a/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/ITestService.h
+++ b/tests/golden_output/aidl-test-interface-cpp-source/gen/include/android/aidl/tests/ITestService.h
@@ -346,6 +346,22 @@ public:
enum : int64_t { LONG_TEST_CONSTANT = 1099511627776L };
static const ::android::String16& STRING_TEST_CONSTANT();
static const ::android::String16& STRING_TEST_CONSTANT2();
+ static constexpr float FLOAT_TEST_CONSTANT = 1.000000f;
+ static constexpr float FLOAT_TEST_CONSTANT2 = -1.000000f;
+ static constexpr float FLOAT_TEST_CONSTANT3 = 1.000000f;
+ static constexpr float FLOAT_TEST_CONSTANT4 = 2.200000f;
+ static constexpr float FLOAT_TEST_CONSTANT5 = -2.200000f;
+ static constexpr float FLOAT_TEST_CONSTANT6 = -0.000000f;
+ static constexpr float FLOAT_TEST_CONSTANT7 = 0.000000f;
+ static constexpr double DOUBLE_TEST_CONSTANT = 1.000000;
+ static constexpr double DOUBLE_TEST_CONSTANT2 = -1.000000;
+ static constexpr double DOUBLE_TEST_CONSTANT3 = 1.000000;
+ static constexpr double DOUBLE_TEST_CONSTANT4 = 2.200000;
+ static constexpr double DOUBLE_TEST_CONSTANT5 = -2.200000;
+ static constexpr double DOUBLE_TEST_CONSTANT6 = -0.000000;
+ static constexpr double DOUBLE_TEST_CONSTANT7 = 0.000000;
+ static constexpr double DOUBLE_TEST_CONSTANT8 = 1.100000;
+ static constexpr double DOUBLE_TEST_CONSTANT9 = -1.100000;
static const ::std::string& STRING_TEST_CONSTANT_UTF8();
enum : int32_t { A1 = 1 };
enum : int32_t { A2 = 1 };
diff --git a/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/ITestService.java b/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/ITestService.java
index 480489a3..650d907e 100644
--- a/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/ITestService.java
+++ b/tests/golden_output/aidl-test-interface-java-source/gen/android/aidl/tests/ITestService.java
@@ -3558,6 +3558,22 @@ public interface ITestService extends android.os.IInterface
public static final long LONG_TEST_CONSTANT = 1099511627776L;
public static final String STRING_TEST_CONSTANT = "foo";
public static final String STRING_TEST_CONSTANT2 = "bar";
+ public static final float FLOAT_TEST_CONSTANT = 1.000000f;
+ public static final float FLOAT_TEST_CONSTANT2 = -1.000000f;
+ public static final float FLOAT_TEST_CONSTANT3 = 1.000000f;
+ public static final float FLOAT_TEST_CONSTANT4 = 2.200000f;
+ public static final float FLOAT_TEST_CONSTANT5 = -2.200000f;
+ public static final float FLOAT_TEST_CONSTANT6 = -0.000000f;
+ public static final float FLOAT_TEST_CONSTANT7 = 0.000000f;
+ public static final double DOUBLE_TEST_CONSTANT = 1.000000;
+ public static final double DOUBLE_TEST_CONSTANT2 = -1.000000;
+ public static final double DOUBLE_TEST_CONSTANT3 = 1.000000;
+ public static final double DOUBLE_TEST_CONSTANT4 = 2.200000;
+ public static final double DOUBLE_TEST_CONSTANT5 = -2.200000;
+ public static final double DOUBLE_TEST_CONSTANT6 = -0.000000;
+ public static final double DOUBLE_TEST_CONSTANT7 = 0.000000;
+ public static final double DOUBLE_TEST_CONSTANT8 = 1.100000;
+ public static final double DOUBLE_TEST_CONSTANT9 = -1.100000;
public static final String STRING_TEST_CONSTANT_UTF8 = "baz";
// All these constant expressions should be equal to 1
public static final int A1 = 1;
diff --git a/tests/golden_output/aidl-test-interface-ndk-source/gen/include/aidl/android/aidl/tests/ITestService.h b/tests/golden_output/aidl-test-interface-ndk-source/gen/include/aidl/android/aidl/tests/ITestService.h
index 09e36a71..c23f776a 100644
--- a/tests/golden_output/aidl-test-interface-ndk-source/gen/include/aidl/android/aidl/tests/ITestService.h
+++ b/tests/golden_output/aidl-test-interface-ndk-source/gen/include/aidl/android/aidl/tests/ITestService.h
@@ -361,6 +361,22 @@ public:
enum : int64_t { LONG_TEST_CONSTANT = 1099511627776L };
static const char* STRING_TEST_CONSTANT;
static const char* STRING_TEST_CONSTANT2;
+ static constexpr float FLOAT_TEST_CONSTANT = 1.000000f;
+ static constexpr float FLOAT_TEST_CONSTANT2 = -1.000000f;
+ static constexpr float FLOAT_TEST_CONSTANT3 = 1.000000f;
+ static constexpr float FLOAT_TEST_CONSTANT4 = 2.200000f;
+ static constexpr float FLOAT_TEST_CONSTANT5 = -2.200000f;
+ static constexpr float FLOAT_TEST_CONSTANT6 = -0.000000f;
+ static constexpr float FLOAT_TEST_CONSTANT7 = 0.000000f;
+ static constexpr double DOUBLE_TEST_CONSTANT = 1.000000;
+ static constexpr double DOUBLE_TEST_CONSTANT2 = -1.000000;
+ static constexpr double DOUBLE_TEST_CONSTANT3 = 1.000000;
+ static constexpr double DOUBLE_TEST_CONSTANT4 = 2.200000;
+ static constexpr double DOUBLE_TEST_CONSTANT5 = -2.200000;
+ static constexpr double DOUBLE_TEST_CONSTANT6 = -0.000000;
+ static constexpr double DOUBLE_TEST_CONSTANT7 = 0.000000;
+ static constexpr double DOUBLE_TEST_CONSTANT8 = 1.100000;
+ static constexpr double DOUBLE_TEST_CONSTANT9 = -1.100000;
static const char* STRING_TEST_CONSTANT_UTF8;
enum : int32_t { A1 = 1 };
enum : int32_t { A2 = 1 };
diff --git a/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/ITestService.rs b/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/ITestService.rs
index b924f9bf..b9b36d37 100644
--- a/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/ITestService.rs
+++ b/tests/golden_output/aidl-test-interface-rust-source/gen/android/aidl/tests/ITestService.rs
@@ -761,6 +761,22 @@ pub const r#BYTE_TEST_CONSTANT: i8 = 17;
pub const r#LONG_TEST_CONSTANT: i64 = 1099511627776;
pub const r#STRING_TEST_CONSTANT: &str = "foo";
pub const r#STRING_TEST_CONSTANT2: &str = "bar";
+pub const r#FLOAT_TEST_CONSTANT: f32 = 1.000000f32;
+pub const r#FLOAT_TEST_CONSTANT2: f32 = -1.000000f32;
+pub const r#FLOAT_TEST_CONSTANT3: f32 = 1.000000f32;
+pub const r#FLOAT_TEST_CONSTANT4: f32 = 2.200000f32;
+pub const r#FLOAT_TEST_CONSTANT5: f32 = -2.200000f32;
+pub const r#FLOAT_TEST_CONSTANT6: f32 = -0.000000f32;
+pub const r#FLOAT_TEST_CONSTANT7: f32 = 0.000000f32;
+pub const r#DOUBLE_TEST_CONSTANT: f64 = 1.000000f64;
+pub const r#DOUBLE_TEST_CONSTANT2: f64 = -1.000000f64;
+pub const r#DOUBLE_TEST_CONSTANT3: f64 = 1.000000f64;
+pub const r#DOUBLE_TEST_CONSTANT4: f64 = 2.200000f64;
+pub const r#DOUBLE_TEST_CONSTANT5: f64 = -2.200000f64;
+pub const r#DOUBLE_TEST_CONSTANT6: f64 = -0.000000f64;
+pub const r#DOUBLE_TEST_CONSTANT7: f64 = 0.000000f64;
+pub const r#DOUBLE_TEST_CONSTANT8: f64 = 1.100000f64;
+pub const r#DOUBLE_TEST_CONSTANT9: f64 = -1.100000f64;
pub const r#STRING_TEST_CONSTANT_UTF8: &str = "baz";
pub const r#A1: i32 = 1;
pub const r#A2: i32 = 1;
diff --git a/tests/java/src/android/aidl/tests/TestServiceClient.java b/tests/java/src/android/aidl/tests/TestServiceClient.java
index 4dd383cf..6f298864 100644
--- a/tests/java/src/android/aidl/tests/TestServiceClient.java
+++ b/tests/java/src/android/aidl/tests/TestServiceClient.java
@@ -134,6 +134,28 @@ public class TestServiceClient {
}
@Test
+ public void testConstFloatRepeat() throws RemoteException {
+ float query[] = {ITestService.FLOAT_TEST_CONSTANT, ITestService.FLOAT_TEST_CONSTANT2,
+ ITestService.FLOAT_TEST_CONSTANT3, ITestService.FLOAT_TEST_CONSTANT4,
+ ITestService.FLOAT_TEST_CONSTANT5, ITestService.FLOAT_TEST_CONSTANT6,
+ ITestService.FLOAT_TEST_CONSTANT7};
+ for (int i = 0; i < query.length; i++) {
+ assertThat(service.RepeatFloat(query[i]), is(query[i]));
+ }
+ }
+
+ @Test
+ public void testConstDoubleRepeat() throws RemoteException {
+ double query[] = {ITestService.DOUBLE_TEST_CONSTANT, ITestService.DOUBLE_TEST_CONSTANT2,
+ ITestService.DOUBLE_TEST_CONSTANT3, ITestService.DOUBLE_TEST_CONSTANT4,
+ ITestService.DOUBLE_TEST_CONSTANT5, ITestService.DOUBLE_TEST_CONSTANT6,
+ ITestService.DOUBLE_TEST_CONSTANT7};
+ for (int i = 0; i < query.length; i++) {
+ assertThat(service.RepeatDouble(query[i]), is(query[i]));
+ }
+ }
+
+ @Test
public void testLongRepeat() throws RemoteException {
long query = 1L << 60;
assertThat(service.RepeatLong(query), is(query));
diff --git a/tests/rust/test_client.rs b/tests/rust/test_client.rs
index a22f094e..cd24eaea 100644
--- a/tests/rust/test_client.rs
+++ b/tests/rust/test_client.rs
@@ -121,6 +121,10 @@ fn test_constants() {
assert_eq!(ITestService::A55, 1);
assert_eq!(ITestService::A56, 1);
assert_eq!(ITestService::A57, 1);
+ assert_eq!(ITestService::FLOAT_TEST_CONSTANT4, 2.2_f32);
+ assert_eq!(ITestService::FLOAT_TEST_CONSTANT5, -2.2_f32);
+ assert_eq!(ITestService::DOUBLE_TEST_CONSTANT4, 2.2_f64);
+ assert_eq!(ITestService::DOUBLE_TEST_CONSTANT5, -2.2_f64);
}
#[test]
@@ -165,6 +169,20 @@ test_primitive! {test_primitive_long_constant, RepeatLong, ITestService::LONG_TE
test_primitive! {test_primitive_byte_enum, RepeatByteEnum, ByteEnum::FOO}
test_primitive! {test_primitive_int_enum, RepeatIntEnum, IntEnum::BAR}
test_primitive! {test_primitive_long_enum, RepeatLongEnum, LongEnum::FOO}
+test_primitive! {test_primitive_float_constant, RepeatFloat, ITestService::FLOAT_TEST_CONSTANT}
+test_primitive! {test_primitive_float_constant2, RepeatFloat, ITestService::FLOAT_TEST_CONSTANT2}
+test_primitive! {test_primitive_float_constant3, RepeatFloat, ITestService::FLOAT_TEST_CONSTANT3}
+test_primitive! {test_primitive_float_constant4, RepeatFloat, ITestService::FLOAT_TEST_CONSTANT4}
+test_primitive! {test_primitive_float_constant5, RepeatFloat, ITestService::FLOAT_TEST_CONSTANT5}
+test_primitive! {test_primitive_float_constant6, RepeatFloat, ITestService::FLOAT_TEST_CONSTANT6}
+test_primitive! {test_primitive_float_constant7, RepeatFloat, ITestService::FLOAT_TEST_CONSTANT7}
+test_primitive! {test_primitive_double_constant, RepeatDouble, ITestService::DOUBLE_TEST_CONSTANT}
+test_primitive! {test_primitive_double_constant2, RepeatDouble, ITestService::DOUBLE_TEST_CONSTANT2}
+test_primitive! {test_primitive_double_constant3, RepeatDouble, ITestService::DOUBLE_TEST_CONSTANT3}
+test_primitive! {test_primitive_double_constant4, RepeatDouble, ITestService::DOUBLE_TEST_CONSTANT4}
+test_primitive! {test_primitive_double_constant5, RepeatDouble, ITestService::DOUBLE_TEST_CONSTANT5}
+test_primitive! {test_primitive_double_constant6, RepeatDouble, ITestService::DOUBLE_TEST_CONSTANT6}
+test_primitive! {test_primitive_double_constant7, RepeatDouble, ITestService::DOUBLE_TEST_CONSTANT7}
#[test]
fn test_repeat_string() {