summaryrefslogtreecommitdiff
path: root/android/PhoneNumberUtilsTest.cpp
diff options
context:
space:
mode:
authorDmitri Plotnikov <dplotnikov@google.com>2011-01-06 13:48:50 -0800
committerDmitri Plotnikov <dplotnikov@google.com>2011-01-06 13:49:18 -0800
commit46bdb5c49f8374539ec89e85cbb1a9ee7b3a2b10 (patch)
tree9967bac9881d54cf6d5690dd1a7be2b002c7e225 /android/PhoneNumberUtilsTest.cpp
parent95c34edce550d0869113085e0cd1b6b09e8fe38b (diff)
DO NOT MERGE. Adding a custom function to support legacy API compatibility
Bug: 3210604 Change-Id: Ie65c053ec5178d6cd991f69a5a2b6d5d51938ade
Diffstat (limited to 'android/PhoneNumberUtilsTest.cpp')
-rw-r--r--android/PhoneNumberUtilsTest.cpp38
1 files changed, 36 insertions, 2 deletions
diff --git a/android/PhoneNumberUtilsTest.cpp b/android/PhoneNumberUtilsTest.cpp
index 3445652..cf67286 100644
--- a/android/PhoneNumberUtilsTest.cpp
+++ b/android/PhoneNumberUtilsTest.cpp
@@ -29,6 +29,8 @@
using namespace android;
+#define PHONE_NUMBER_BUFFER_SIZE 6
+
#define EXPECT(function, input1, input2, expected, total, error) \
({ \
const char *i1_cache = input1; \
@@ -47,14 +49,30 @@ using namespace android;
})
#define EXPECT_EQ(input1, input2) \
- EXPECT(phone_number_compare_strict, (input1), (input2), true, \
+ EXPECT(phone_number_compare_strict, (input1), (input2), true, \
(total), (error))
#define EXPECT_NE(input1, input2) \
- EXPECT(phone_number_compare_strict, (input1), (input2), false, \
+ EXPECT(phone_number_compare_strict, (input1), (input2), false, \
(total), (error))
+#define ASSERT_STRIPPED_REVERSE(input, expected) \
+ ({ \
+ char out[PHONE_NUMBER_BUFFER_SIZE]; \
+ int outlen; \
+ (total)++; \
+ phone_number_stripped_reversed_inter((input), \
+ out, \
+ PHONE_NUMBER_BUFFER_SIZE, \
+ &outlen); \
+ out[outlen] = 0; \
+ if (strcmp((expected), (out)) != 0) { \
+ printf("Expected: %s actual: %s\n", (expected), (out)); \
+ (error)++; \
+ } \
+ })
+
int main() {
int total = 0;
int error = 0;
@@ -152,6 +170,22 @@ int main() {
// but there is no sensible way to know it now (as of 2009-6-12)...
// EXPECT_NE("290-1234-5678", "+819012345678");
+ ASSERT_STRIPPED_REVERSE("", "");
+ ASSERT_STRIPPED_REVERSE("123", "321");
+ ASSERT_STRIPPED_REVERSE("123*N#", "#N*321");
+
+ // Buffer overflow
+ ASSERT_STRIPPED_REVERSE("1234567890", "098765");
+
+ // Only one plus is copied
+ ASSERT_STRIPPED_REVERSE("1+2+", "+21");
+
+ // Pause/wait in the phone number
+ ASSERT_STRIPPED_REVERSE("12;34", "21");
+
+ // Ignoring non-dialable
+ ASSERT_STRIPPED_REVERSE("1A2 3?4", "4321");
+
printf("total: %d, error: %d\n\n", total, error);
if (error == 0) {
printf("Success!\n");